Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation for 'Hello World' effect #40

Open
srid opened this issue Dec 6, 2021 · 6 comments
Open

Documentation for 'Hello World' effect #40

srid opened this issue Dec 6, 2021 · 6 comments

Comments

@srid
Copy link

srid commented Dec 6, 2021

I'm unable to adapt https://docs.hercules-ci.com/hercules-ci-effects/guide/write-a-custom-effect/ for flake.nix

Could we have docs on adding the simplest effect?

Here's what I tried:

https://github.com/srid/haskell.page/commit/0e08e8f0e9eb84c3c6555991a65315925fbb7f29#diff-206b9ce276ab5971a2489d75eb1b12999d4bf3843b7988cbe8d687cfde61dea0R13

image

(I assumed that the agent would iterate all top-level attres looking for 'effect' objects)

But, the agent doesn't seem to recognize any effects?

https://hercules-ci.com/github/srid/haskell.page/jobs/8

image

@roberth
Copy link
Member

roberth commented Dec 6, 2021

The problem is with the traversal. It follows the rules of nix-build and nix-env -q regarding recurseForDerivations aka recurseIntoAttrs.
This will be fixed in the 0.9 release, which can perform a simpler traversal, but until then, you could re-expose the relevant flake attrs with recurseIntoAttrs calls in default.nix.

@roberth
Copy link
Member

roberth commented Dec 6, 2021

Or you could use https://github.com/hercules-ci/flake-compat-ci, even if it's a stop-gap solution.

@srid
Copy link
Author

srid commented Dec 6, 2021

@roberth
Copy link
Member

roberth commented Dec 6, 2021

I've updated flake-compat-ci to expose effects. It expects the flake output:

outputs = { self, ..... }: {
  effects.helloWorld = ....;
} // yourExistingOutputsIncludingFlakeCompatCi;

ie not per system. Generally you want to run effects once per real-world object rather than for all each possible system.

@roberth
Copy link
Member

roberth commented Dec 6, 2021

diff --git a/flake.lock b/flake.lock
index 6eba55d..3f7512d 100644
--- a/flake.lock
+++ b/flake.lock
@@ -40,11 +40,11 @@
     },
     "flake-compat-ci": {
       "locked": {
-        "lastModified": 1629629549,
-        "narHash": "sha256-c6Hipyp52MZ2pTFXEIRdcLK2rtKt9jggCQ7ZOgBS44k=",
+        "lastModified": 1638753619,
+        "narHash": "sha256-uJoNBfbXkn17W5PIrtQDPEk+zfN91oOB9I9XF9pOTmo=",
         "owner": "hercules-ci",
         "repo": "flake-compat-ci",
-        "rev": "ef10daf1cb1823086ed547d39806aaca4c53cc17",
+        "rev": "e950b4e71c711f3311cbf6323394c0aff7b7e4ec",
         "type": "github"
       },
       "original": {
diff --git a/flake.nix b/flake.nix
index 0a95f27..0618268 100644
--- a/flake.nix
+++ b/flake.nix
@@ -23,6 +23,9 @@
         # Example: [ "x86_64-darwin" "aarch64-linux" ];
         systems = [ "x86_64-linux" ];
       };
+
+      effects.helloEffect = self.helloEffect.x86_64-linux;
+
     } //
     flake-utils.lib.eachSystem [ "x86_64-linux" "x86_64-darwin" "aarch64-darwin" ] (system:
       let

@srid
Copy link
Author

srid commented Dec 6, 2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants