summaryrefslogtreecommitdiff
path: root/.github/workflows/test.yml
diff options
context:
space:
mode:
authorMike Vink <59492084+ivi-vink@users.noreply.github.com>2025-01-16 22:22:34 +0100
committerGitHub <noreply@github.com>2025-01-16 22:22:34 +0100
commit8e7bd91f353caacc0bc4105f573eb3e17f09e03a (patch)
treec5059edcbebd9644290cad7c653c49a36d593021 /.github/workflows/test.yml
parent6bd39d420578aacf7c0bab7de3e7027b952115ae (diff)
parentbd921223ba7cdac346477d7ea5204d6f4736fcc6 (diff)
Merge branch 'LnL7:master' into masterHEADmaster
Diffstat (limited to '.github/workflows/test.yml')
-rw-r--r--.github/workflows/test.yml308
1 files changed, 71 insertions, 237 deletions
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 05eecbe..63c155b 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -2,133 +2,93 @@ name: "Test"
on:
pull_request:
push:
+ branches:
+ - master
env:
- CURRENT_STABLE_CHANNEL: nixpkgs-23.05-darwin
+ NIXPKGS_BRANCH: nixpkgs-unstable
+ NIX_DARWIN_BRANCH: master
+ NIX_VERSION: 2.24.11
jobs:
+ # The `test-stable` and `install-against-stable` job names are
+ # load‐bearing, despite their inaccuracy on the unstable branch, as
+ # they are set as required checks in the repository configuration,
+ # which only repository admins can change.
+ #
+ # TODO: Change them once the repository configuration is updated.
+
test-stable:
- runs-on: macos-12
- timeout-minutes: 30
+ runs-on: macos-13
steps:
- - uses: actions/checkout@v3
- - name: Install nix corresponding to latest stable channel
- uses: cachix/install-nix-action@v23
+ - uses: actions/checkout@v4
+ - name: Install Nix
+ uses: cachix/install-nix-action@v30
with:
- install_url: https://releases.nixos.org/nix/nix-2.13.6/install
- - run: nix-build ./release.nix -I nixpkgs=channel:${{ env.CURRENT_STABLE_CHANNEL }} -I darwin=. -A tests
- - run: nix-build ./release.nix -I nixpkgs=channel:${{ env.CURRENT_STABLE_CHANNEL }} -I darwin=. -A manpages
- - run: nix-build ./release.nix -I nixpkgs=channel:${{ env.CURRENT_STABLE_CHANNEL }} -I darwin=. -A examples.simple
-
- test-unstable:
- runs-on: macos-12
- timeout-minutes: 30
- steps:
- - uses: actions/checkout@v3
- - name: Install nix from current unstable channel
- uses: cachix/install-nix-action@v23
- - run: nix-build ./release.nix -I nixpkgs=channel:nixpkgs-unstable -I darwin=. -A tests
- - run: nix-build ./release.nix -I nixpkgs=channel:nixpkgs-unstable -I darwin=. -A manpages
- - run: nix-build ./release.nix -I nixpkgs=channel:nixpkgs-unstable -I darwin=. -A examples.simple
+ install_url: https://releases.nixos.org/nix/nix-${{ env.NIX_VERSION }}/install
+ - run: nix flake check --override-input nixpkgs nixpkgs/${{ env.NIXPKGS_BRANCH }}
install-against-stable:
- runs-on: macos-12
+ runs-on: macos-13
timeout-minutes: 30
steps:
- - uses: actions/checkout@v3
- - name: Install nix corresponding to latest stable channel
- uses: cachix/install-nix-action@v23
+ - uses: actions/checkout@v4
+ - name: Install Nix
+ uses: cachix/install-nix-action@v30
with:
- install_url: https://releases.nixos.org/nix/nix-2.13.6/install
- nix_path: nixpkgs=channel:${{ env.CURRENT_STABLE_CHANNEL }}
- - name: Install ${{ env.CURRENT_STABLE_CHANNEL }} channel
+ install_url: https://releases.nixos.org/nix/nix-${{ env.NIX_VERSION }}/install
+ nix_path: nixpkgs=channel:${{ env.NIXPKGS_BRANCH }}
+ - name: Install channels
run: |
- nix-channel --add https://nixos.org/channels/${{ env.CURRENT_STABLE_CHANNEL }} nixpkgs
+ nix-channel --add https://github.com/LnL7/nix-darwin/archive/${{ env.NIX_DARWIN_BRANCH }}.tar.gz darwin
+ nix-channel --add https://nixos.org/channels/${{ env.NIXPKGS_BRANCH }} nixpkgs
nix-channel --update
- - name: Install nix-darwin and test
+ - name: Install nix-darwin
run: |
export NIX_PATH=$HOME/.nix-defexpr/channels
- # We run nix-darwin twice to test that it can create darwin-configuration correctly for us
- # but we expect it to fail setting up /etc/nix/nix.conf
- nix-shell -A installer || true
+ mkdir -p ~/.config/nix-darwin
+ cp modules/examples/simple.nix ~/.config/nix-darwin/configuration.nix
nixConfHash=$(shasum -a 256 /etc/nix/nix.conf | cut -d ' ' -f 1)
/usr/bin/sed -i.bak \
- "s/# nix.package = pkgs.nix;/nix.settings.access-tokens = [ \"github.com=\${{ secrets.GITHUB_TOKEN }}\" ]; environment.etc.\"nix\/nix.conf\".knownSha256Hashes = [ \"$nixConfHash\" ];/" \
- ~/.nixpkgs/darwin-configuration.nix
-
- nix-shell -A installer
- nix-shell -A installer.check
- - name: Build and activate default derivation
- run: |
- . /etc/static/bashrc
- darwin-rebuild switch -I darwin=.
- - name: Test uninstallation of nix-darwin
- run: |
- export NIX_PATH=$HOME/.nix-defexpr/channels
- nix-shell -A uninstaller
- nix-shell -A uninstaller.check
- - name: Debugging tmate session
- if: ${{ failure() }}
- uses: mxschmitt/action-tmate@v3
- timeout-minutes: 15
- with:
- limit-access-to-actor: true
+ "s/# programs.fish.enable = true;/nix.settings.access-tokens = [ \"github.com=\${{ secrets.GITHUB_TOKEN }}\" ]; environment.etc.\"nix\/nix.conf\".knownSha256Hashes = [ \"$nixConfHash\" ];/" \
+ ~/.config/nix-darwin/configuration.nix
- install-against-unstable:
- runs-on: macos-12
- timeout-minutes: 30
- steps:
- - uses: actions/checkout@v3
- - name: Install nix from current unstable channel
- uses: cachix/install-nix-action@v23
- with:
- nix_path: nixpkgs=channel:nixpkgs-unstable
- - name: Install nixpkgs-unstable channel
- run: |
- nix-channel --add https://nixos.org/channels/nixpkgs-unstable nixpkgs
- nix-channel --update
- - name: Install nix-darwin and test
+ nix run .#darwin-rebuild \
+ -- switch \
+ -I darwin-config=$HOME/.config/nix-darwin/configuration.nix
+ - name: Switch to new configuration
run: |
- export NIX_PATH=$HOME/.nix-defexpr/channels
-
- # We run nix-darwin twice to test that it can create darwin-configuration correctly for us
- # but we expect it to fail setting up /etc/nix/nix.conf
- nix-shell -A installer || true
+ . /etc/bashrc
- nixConfHash=$(shasum -a 256 /etc/nix/nix.conf | cut -d ' ' -f 1)
/usr/bin/sed -i.bak \
- "s/# nix.package = pkgs.nix;/nix.settings.access-tokens = [ \"github.com=\${{ secrets.GITHUB_TOKEN }}\" ]; environment.etc.\"nix\/nix.conf\".knownSha256Hashes = [ \"$nixConfHash\" ];/" \
- ~/.nixpkgs/darwin-configuration.nix
+ "s/pkgs.vim/pkgs.hello/" \
+ ~/.config/nix-darwin/configuration.nix
- nix-shell -A installer
- nix-shell -A installer.check
- - name: Build and activate default derivation
- run: |
- . /etc/static/bashrc
darwin-rebuild switch -I darwin=.
+
+ hello
- name: Test uninstallation of nix-darwin
run: |
- export NIX_PATH=$HOME/.nix-defexpr/channels
- nix-shell -A uninstaller
- nix-shell -A uninstaller.check
- - name: Debugging tmate session
- if: ${{ failure() }}
- uses: mxschmitt/action-tmate@v3
- timeout-minutes: 15
- with:
- limit-access-to-actor: true
-
- install-flake-against-stable:
- runs-on: macos-12
+ # We need to specify `--extra-experimental-features` because `experimental-features` is set by
+ # `cachix/install-nix-action` but not by our default config above
+ nix run .#darwin-uninstaller \
+ --extra-experimental-features "nix-command flakes" \
+ --override-input nixpkgs nixpkgs/${{ env.NIXPKGS_BRANCH }}
+ nix run .#darwin-uninstaller.tests.uninstaller \
+ --extra-experimental-features "nix-command flakes" \
+ --override-input nixpkgs nixpkgs/${{ env.NIXPKGS_BRANCH }}
+
+ install-flake:
+ runs-on: macos-13
timeout-minutes: 30
steps:
- - uses: actions/checkout@v3
- - name: Install nix version corresponding to latest stable channel
- uses: cachix/install-nix-action@v23
+ - uses: actions/checkout@v4
+ - name: Install Nix
+ uses: cachix/install-nix-action@v30
with:
- install_url: https://releases.nixos.org/nix/nix-2.13.6/install
+ install_url: https://releases.nixos.org/nix/nix-${{ env.NIX_VERSION }}/install
- name: Install nix-darwin
run: |
mkdir -p ~/.config/nix-darwin
@@ -137,156 +97,30 @@ jobs:
nix flake init -t $darwin
nixConfHash=$(shasum -a 256 /etc/nix/nix.conf | cut -d ' ' -f 1)
/usr/bin/sed -i.bak \
- "s/# nix.package = pkgs.nix;/nix.settings.access-tokens = [ \"github.com=\${{ secrets.GITHUB_TOKEN }}\" ]; environment.etc.\"nix\/nix.conf\".knownSha256Hashes = [ \"$nixConfHash\" ];/" \
+ "s/# programs.fish.enable = true;/nix.settings.access-tokens = [ \"github.com=\${{ secrets.GITHUB_TOKEN }}\" ]; environment.etc.\"nix\/nix.conf\".knownSha256Hashes = [ \"$nixConfHash\" ];/" \
flake.nix
- popd
- nix run .#darwin-rebuild -- \
- switch --flake ~/.config/nix-darwin#simple \
- --override-input nix-darwin . \
- --override-input nixpkgs nixpkgs/${{ env.CURRENT_STABLE_CHANNEL }}
- - name: Rebuild and activate simple flake, but this time using nix-darwin's flake interface
- run: |
- . /etc/static/bashrc
- darwin-rebuild build --flake ./modules/examples/flake#simple --override-input nix-darwin . --override-input nixpkgs nixpkgs/${{ env.CURRENT_STABLE_CHANNEL }}
- - name: Test git submodules
- run: |
- . /etc/static/bashrc
-
- mkdir -p /tmp/{test-nix-darwin-submodules,example-submodule}
-
- pushd /tmp/example-submodule
- echo '"hello"' > hello.nix
- git init
- git add .
- git commit -m "add a submodule we will import"
- popd
-
- cp -a ./modules/examples/. /tmp/test-nix-darwin-submodules
- cp -a ./modules/examples/flake/flake.nix /tmp/test-nix-darwin-submodules
-
- pushd /tmp/test-nix-darwin-submodules
- /usr/bin/sed -i.bak \
- '\#modules = \[#s#configuration#configuration ./simple.nix#' \
- ./flake.nix
- /usr/bin/sed -i.bak \
- 's#pkgs.vim#pkgs."${import ./submodule-test/hello.nix}"#' \
- ./simple.nix
- git init
- git add flake.nix simple.nix
- git \
- -c protocol.file.allow=always \
- submodule add /tmp/example-submodule submodule-test
- popd
-
- # Should fail
- darwin-rebuild build \
- --flake /tmp/test-nix-darwin-submodules#simple \
- --override-input nix-darwin . \
- --override-input nixpkgs nixpkgs/${{ env.CURRENT_STABLE_CHANNEL }} \
- && {
- printf 'succeeded while expecting failure due to submodule\n' >/dev/stderr
- exit 1
- }
- # Should also fail
- darwin-rebuild build \
- --flake /tmp/test-nix-darwin-submodules?submodules=0#simple \
- --override-input nix-darwin . \
- --override-input nixpkgs nixpkgs/${{ env.CURRENT_STABLE_CHANNEL }} \
- && {
- printf 'succeeded while expecting failure due to submodule\n' >/dev/stderr
- exit 1
- }
-
- # Should succeed
- darwin-rebuild build \
- --flake /tmp/test-nix-darwin-submodules?submodules=1#simple \
- --override-input nix-darwin . \
- --override-input nixpkgs nixpkgs/${{ env.CURRENT_STABLE_CHANNEL }} \
-
- install-flake-against-unstable:
- runs-on: macos-12
- timeout-minutes: 30
- steps:
- - uses: actions/checkout@v3
- - name: Install nix from current unstable channel
- uses: cachix/install-nix-action@v23
- - name: Install nix-darwin
- run: |
- mkdir -p ~/.config/nix-darwin
- darwin=$(pwd)
- pushd ~/.config/nix-darwin
- nix flake init -t $darwin
- nixConfHash=$(shasum -a 256 /etc/nix/nix.conf | cut -d ' ' -f 1)
/usr/bin/sed -i.bak \
- "s/# nix.package = pkgs.nix;/nix.settings.access-tokens = [ \"github.com=\${{ secrets.GITHUB_TOKEN }}\" ]; environment.etc.\"nix\/nix.conf\".knownSha256Hashes = [ \"$nixConfHash\" ];/" \
+ 's/nixpkgs.hostPlatform = "aarch64-darwin";/nixpkgs.hostPlatform = "'$(nix eval --expr builtins.currentSystem --impure --raw)'";/' \
flake.nix
popd
nix run .#darwin-rebuild -- \
switch --flake ~/.config/nix-darwin#simple \
--override-input nix-darwin . \
- --override-input nixpkgs nixpkgs/nixpkgs-unstable
- - name: Rebuild and activate simple flake, but this time using nix-darwin's flake interface
- run: |
- . /etc/static/bashrc
- darwin-rebuild build --flake ./modules/examples/flake#simple --override-input nix-darwin . --override-input nixpkgs nixpkgs/nixpkgs-unstable
- - name: Test git submodules
+ --override-input nixpkgs nixpkgs/${{ env.NIXPKGS_BRANCH }}
+ - name: Switch to new configuration
run: |
- . /etc/static/bashrc
-
- mkdir -p /tmp/{test-nix-darwin-submodules,example-submodule}
-
- pushd /tmp/example-submodule
- echo '"hello"' > hello.nix
- git init
- git add .
- git commit -m "add a submodule we will import"
- popd
-
- cp -a ./modules/examples/. /tmp/test-nix-darwin-submodules
- cp -a ./modules/examples/flake/flake.nix /tmp/test-nix-darwin-submodules
-
- pushd /tmp/test-nix-darwin-submodules
- /usr/bin/sed -i.bak \
- '\#modules = \[#s#configuration#configuration ./simple.nix#' \
- ./flake.nix
- /usr/bin/sed -i.bak \
- 's#pkgs.vim#pkgs."${import ./submodule-test/hello.nix}"#' \
- ./simple.nix
- git init
- git add flake.nix simple.nix
- git \
- -c protocol.file.allow=always \
- submodule add /tmp/example-submodule submodule-test
- popd
+ . /etc/bashrc
- # Should fail
- darwin-rebuild build \
- --flake /tmp/test-nix-darwin-submodules#simple \
- --override-input nix-darwin . \
- --override-input nixpkgs nixpkgs/nixpkgs-unstable \
- && {
- printf 'succeeded while expecting failure due to submodule\n' >/dev/stderr
- exit 1
- }
-
- # Should also fail
- darwin-rebuild build \
- --flake /tmp/test-nix-darwin-submodules?submodules=0#simple \
- --override-input nix-darwin . \
- --override-input nixpkgs nixpkgs/nixpkgs-unstable \
- && {
- printf 'succeeded while expecting failure due to submodule\n' >/dev/stderr
- exit 1
- }
+ /usr/bin/sed -i.bak \
+ "s/pkgs.vim/pkgs.hello/" \
+ ~/.config/nix-darwin/flake.nix
- # Should succeed
- darwin-rebuild build \
- --flake /tmp/test-nix-darwin-submodules?submodules=1#simple \
+ darwin-rebuild switch --flake ~/.config/nix-darwin#simple \
--override-input nix-darwin . \
- --override-input nixpkgs nixpkgs/nixpkgs-unstable
+ --override-input nixpkgs nixpkgs/${{ env.NIXPKGS_BRANCH }}
- # Should also succeed
- darwin-rebuild build \
- --flake git+file:///tmp/test-nix-darwin-submodules?submodules=1#simple \
- --override-input nix-darwin . \
- --override-input nixpkgs nixpkgs/nixpkgs-unstable
+ hello
+ - name: Test uninstallation of nix-darwin
+ run: |
+ nix run .#darwin-uninstaller --override-input nixpkgs nixpkgs/${{ env.NIXPKGS_BRANCH }}
+ nix run .#darwin-uninstaller.tests.uninstaller --override-input nixpkgs nixpkgs/${{ env.NIXPKGS_BRANCH }}