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

detect nix flakes config #32

Merged
merged 4 commits into from
Jun 30, 2023

Conversation

blaggacao
Copy link
Contributor

  • feat: read out flake config if a flake
  • feat: make a flakes variant
  • docs: document the new flakes variant

@rickynils
Copy link
Contributor

Zooming the use case still one step out, I have a good idea for opt-in:

uses: nixbuild/nix-quick-install-action@v22-flake

That's fully specified intent at the lowest verbosity level and would include this PR's capabilities.

I'm not sold on the idea of a different tag for this. It is bad for discoverability, and makes maintenance a bit worse (we need to create the extra tags, although I guess it can be automated).

But we could have a setting that, when turned on, would both add the necessary stuff ('nix-commands flakes') and do the config evaluation. Essentially what you have now, except checking an input instead of the ref.

@blaggacao blaggacao force-pushed the detect-nix-flakes-config branch from 5752d21 to 499a2e8 Compare June 30, 2023 01:36
@blaggacao
Copy link
Contributor Author

Enable the experimental features by default (if your Nix version is new enough). Enable config evaluation by default, but add an option for opting-out (for the really time-concerned people, or as a quick fix if it turns out the config evaluation messes up some specific use case).

Barring some more testing, this is now prototypically implemented.

Can you advise on writing/ameding test cases?

@rickynils
Copy link
Contributor

@blaggacao Maybe something like this can be used for testing it:

diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml
index 145a654..05e977d 100644
--- a/.github/workflows/cicd.yml
+++ b/.github/workflows/cicd.yml
@@ -251,6 +251,22 @@ jobs:
           stat ~/.cache/nix/test-path
           nix-store --verify-path ~/.cache/nix/test-path
 
+  test-nix-config-eval:
+    needs: build
+    runs-on: ubuntu-22.04
+    steps:
+      - uses: actions/checkout@v3
+      - uses: actions/download-artifact@v3
+        id: nix-archives
+        with:
+          name: nix-archives-${{ runner.os }}
+      - uses: ./
+        with:
+          nix_archives_url: file://${{steps.nix-archives.outputs.download-path}}
+      - name: Verify Nix config
+        run: |
+          nix show-config | grep -q 'stalled-download-timeout = 333'
+
   release:
     runs-on: ubuntu-latest
     needs:
diff --git a/flake.nix b/flake.nix
index bc794ac..a29d581 100644
--- a/flake.nix
+++ b/flake.nix
@@ -15,6 +15,12 @@
     nixpkgs-nix-2_0_4.flake = false;
   };
 
+  nixConfig = {
+    # We set some dummy Nix config here so we can use it for verification in our
+    # CI test
+    stalled-download-timeout = 333; # default 300
+  }
+
   outputs = {
     self,
     flake-utils,

@blaggacao blaggacao force-pushed the detect-nix-flakes-config branch 16 times, most recently from 6cf48c6 to 1e5f5db Compare June 30, 2023 20:38
@blaggacao blaggacao force-pushed the detect-nix-flakes-config branch from 1e5f5db to 4f4290e Compare June 30, 2023 20:40
@blaggacao blaggacao force-pushed the detect-nix-flakes-config branch from 4f4290e to 10c7cad Compare June 30, 2023 20:41
@rickynils rickynils merged commit a70d958 into nixbuild:master Jun 30, 2023
@blaggacao blaggacao deleted the detect-nix-flakes-config branch June 30, 2023 22:35
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

Successfully merging this pull request may close these issues.

None yet

2 participants