From 6ce42cc7684cb59b3a9390256f68909d7dfb9af0 Mon Sep 17 00:00:00 2001 From: Nathan Henrie Date: Thu, 21 Dec 2023 13:15:07 -0700 Subject: [PATCH] Fix CI for darwin nix-darwin is detecting `/etc/nix/nix.conf` from the cachix/install-nix-action and refusing to overwrite it, failing the nix-darwin activation and therefore the rest of CI. This commit `mv`s the existing `nix.conf` to avoid the above, and then adds support for new-style nix commands and flakes to the nix-darwin configuration to allow their subsequent use in CI. It also removes the nix config from the `cachix/install-nix-action` step, which was duplicated effort since we are blowing it away with nix-darwin anyway. Relevant: - https://github.com/LnL7/nix-darwin/issues/149 --- .github/workflows/ci.yaml | 20 ++++++++++++++------ flake.nix | 4 +++- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index b53a3f2..6345634 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -15,21 +15,29 @@ jobs: - run: nix fmt . -- --check - run: nix flake check tests-darwin: - runs-on: macos-11 + runs-on: macos-12 steps: - uses: actions/checkout@v3 - - uses: cachix/install-nix-action@v22 + - uses: cachix/install-nix-action@v24 with: - extra_nix_config: "system-features = nixos-test benchmark big-parallel kvm" + extra_nix_config: | + system-features = nixos-test recursive-nix benchmark big-parallel kvm + extra-experimental-features = recursive-nix nix-command flakes - run: nix build - run: nix build .#doc - run: nix fmt . -- --check - run: nix flake check - name: "Install nix-darwin module" run: | - system=$(nix build --no-link --print-out-paths .#checks.x86_64-darwin.integration) - ${system}/activate-user - sudo ${system}/activate + # https://github.com/ryantm/agenix/pull/230#issuecomment-1867025385 + + sudo mv /etc/nix/nix.conf{,.bak} + nix \ + --extra-experimental-features 'nix-command flakes' \ + build .#checks.x86_64-darwin.integration + + ./result/activate-user + sudo ./result/activate - name: "Test nix-darwin module" run: | sudo /run/current-system/sw/bin/agenix-integration diff --git a/flake.nix b/flake.nix index 4f4ccc7..587138e 100644 --- a/flake.nix +++ b/flake.nix @@ -49,7 +49,9 @@ inherit system; modules = [ ./test/integration_darwin.nix - darwin.darwinModules.simple + + # Allow new-style nix commands in CI + {nix.extraOptions = "experimental-features = nix-command flakes";} home-manager.darwinModules.home-manager {