Skip to content

Commit

Permalink
Fix CI for darwin
Browse files Browse the repository at this point in the history
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:

- LnL7/nix-darwin#149
  • Loading branch information
n8henrie committed Dec 21, 2023
1 parent 4055259 commit 4ab4f55
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
20 changes: 11 additions & 9 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,25 @@ 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
with:
extra_nix_config: |
system-features = nixos-test recursive-nix benchmark big-parallel kvm
extra-experimental-features = recursive-nix nix-command flakes
- uses: cachix/install-nix-action@v24
- 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
Expand Down
4 changes: 3 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,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
{
Expand Down

0 comments on commit 4ab4f55

Please sign in to comment.