From 8c9337e28685448882142302b45daef38a127df4 Mon Sep 17 00:00:00 2001 From: Jan Schmitt Date: Wed, 26 Apr 2023 23:00:58 +0200 Subject: [PATCH 1/4] ci: bump actions to most recent version * use checkout@v3 and install-nix-action@20 --- .github/workflows/build.yml | 4 ++-- .github/workflows/debug.yml | 4 ++-- .github/workflows/test.yml | 12 ++++++------ .github/workflows/update-manual.yml | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f9b8f2ae..ed66317e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,7 +12,7 @@ jobs: build: runs-on: macos-12 steps: - - uses: actions/checkout@v2 - - uses: cachix/install-nix-action@v17 + - uses: actions/checkout@v3 + - uses: cachix/install-nix-action@v20 - run: | nix build ${{ github.event.client_payload.args }} -vL diff --git a/.github/workflows/debug.yml b/.github/workflows/debug.yml index 6c4311e5..3abe115b 100644 --- a/.github/workflows/debug.yml +++ b/.github/workflows/debug.yml @@ -12,8 +12,8 @@ jobs: debug: runs-on: macos-12 steps: - - uses: actions/checkout@v2 - - uses: cachix/install-nix-action@v17 + - uses: actions/checkout@v3 + - uses: cachix/install-nix-action@v20 - run: | nix-channel --add https://nixos.org/channels/nixpkgs-unstable nixpkgs nix-channel --update diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index cab17e89..bf5b6498 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -7,8 +7,8 @@ jobs: runs-on: macos-12 timeout-minutes: 30 steps: - - uses: actions/checkout@v2 - - uses: cachix/install-nix-action@v17 + - uses: actions/checkout@v3 + - uses: cachix/install-nix-action@v20 - run: nix-build ./release.nix -I nixpkgs=channel:nixpkgs-22.05-darwin -I darwin=. -A tests - run: nix-build ./release.nix -I nixpkgs=channel:nixpkgs-22.05-darwin -I darwin=. -A manpages - run: nix-build ./release.nix -I nixpkgs=channel:nixpkgs-22.05-darwin -I darwin=. -A examples.simple @@ -16,8 +16,8 @@ jobs: runs-on: macos-12 timeout-minutes: 30 steps: - - uses: actions/checkout@v2 - - uses: cachix/install-nix-action@v17 + - uses: actions/checkout@v3 + - uses: cachix/install-nix-action@v20 - run: | nix-channel --add https://nixos.org/channels/nixpkgs-22.05-darwin nixpkgs nix-channel --update @@ -42,10 +42,10 @@ jobs: runs-on: macos-12 timeout-minutes: 60 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: fetch-depth: 0 - - uses: cachix/install-nix-action@v17 + - uses: cachix/install-nix-action@v20 with: install_url: https://github.com/numtide/nix-flakes-installer/releases/download/nix-2.10.0pre20220808_73fde9e/install extra_nix_config: | diff --git a/.github/workflows/update-manual.yml b/.github/workflows/update-manual.yml index 488ca2f8..6ef90ffe 100644 --- a/.github/workflows/update-manual.yml +++ b/.github/workflows/update-manual.yml @@ -17,7 +17,7 @@ jobs: fetch-depth: 0 - name: Install Nix - uses: cachix/install-nix-action@v17 + uses: cachix/install-nix-action@v20 with: extra_nix_config: | access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} From a379f9afe7f80b137d66fbbeeb81da9b29b519da Mon Sep 17 00:00:00 2001 From: Jan Schmitt Date: Fri, 28 Apr 2023 13:26:04 +0200 Subject: [PATCH 2/4] docs: update flake snippet to 22.11 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 19b5605b..87a9786f 100644 --- a/README.md +++ b/README.md @@ -80,7 +80,7 @@ A minimal example of using an existing configuration.nix: description = "John's darwin system"; inputs = { - nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-22.05-darwin"; + nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-22.11-darwin"; darwin.url = "github:lnl7/nix-darwin/master"; darwin.inputs.nixpkgs.follows = "nixpkgs"; }; From d222200091f2d739bf811b98056fbd0062ea0789 Mon Sep 17 00:00:00 2001 From: Jan Schmitt Date: Fri, 28 Apr 2023 13:26:11 +0200 Subject: [PATCH 3/4] ci: use latest stable channel 22.05 -> 22.11 * use matrix build to run tests against latest stable and unstable channel * add descriptions to github action steps --- .github/workflows/test.yml | 105 ++++++++++++++++++++++------ .github/workflows/update-manual.yml | 2 +- 2 files changed, 83 insertions(+), 24 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index bf5b6498..57cd01b3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -2,33 +2,74 @@ name: "Test" on: pull_request: push: + jobs: tests: + strategy: + fail-fast: true + matrix: + channel: [nixpkgs-22.11-darwin, nixpkgs-unstable] runs-on: macos-12 timeout-minutes: 30 steps: - uses: actions/checkout@v3 - - uses: cachix/install-nix-action@v20 - - run: nix-build ./release.nix -I nixpkgs=channel:nixpkgs-22.05-darwin -I darwin=. -A tests - - run: nix-build ./release.nix -I nixpkgs=channel:nixpkgs-22.05-darwin -I darwin=. -A manpages - - run: nix-build ./release.nix -I nixpkgs=channel:nixpkgs-22.05-darwin -I darwin=. -A examples.simple + - name: Install nix corresponding to latest stable channel + uses: cachix/install-nix-action@v20 + with: + install_url: https://github.com/nix-community/nix-unstable-installer/releases/download/nix-2.10.0pre20220822_7c3ab57/install + extra_nix_config: | + access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} + if: ${{ matrix.channel == 'nixpkgs-22.11-darwin' }} + - name: Install nix from current unstable channel + uses: cachix/install-nix-action@v20 + with: + nix_path: nixpkgs=channel:${{ matrix.channel }} + extra_nix_config: | + access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} + if: ${{ matrix.channel == 'nixpkgs-unstable' }} + - run: nix-build ./release.nix -I nixpkgs=channel:${{ matrix.channel }} -I darwin=. -A tests + - run: nix-build ./release.nix -I nixpkgs=channel:${{ matrix.channel }} -I darwin=. -A manpages + - run: nix-build ./release.nix -I nixpkgs=channel:${{ matrix.channel }} -I darwin=. -A examples.simple + install: + strategy: + fail-fast: true + matrix: + channel: [nixpkgs-22.11-darwin, nixpkgs-unstable] runs-on: macos-12 timeout-minutes: 30 steps: - uses: actions/checkout@v3 - - uses: cachix/install-nix-action@v20 - - run: | - nix-channel --add https://nixos.org/channels/nixpkgs-22.05-darwin nixpkgs + - name: Install nix corresponding to latest stable channel + uses: cachix/install-nix-action@v20 + with: + install_url: https://github.com/nix-community/nix-unstable-installer/releases/download/nix-2.10.0pre20220822_7c3ab57/install + nix_path: nixpkgs=channel:${{ matrix.channel }} + extra_nix_config: | + access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} + if: ${{ matrix.channel == 'nixpkgs-22.11-darwin' }} + - name: Install nix from current unstable channel + uses: cachix/install-nix-action@v20 + with: + nix_path: nixpkgs=channel:${{ matrix.channel }} + extra_nix_config: | + access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} + if: ${{ matrix.channel == 'nixpkgs-unstable' }} + - name: Install ${{ matrix.channel }} channel + run: | + nix-channel --add https://nixos.org/channels/${{ matrix.channel }} nixpkgs nix-channel --update - - run: | + - name: Install nix-darwin and test + run: | export NIX_PATH=$HOME/.nix-defexpr/channels nix-shell -A installer nix-shell -A installer.check - - run: | + - name: Build and activate default derivation + run: | . /etc/static/bashrc darwin-rebuild switch -I darwin=. - - run: | + - name: Test uninstallation of nix-darwin + run: | export NIX_PATH=$HOME/.nix-defexpr/channels nix-shell -A uninstaller nix-shell -A uninstaller.check @@ -38,30 +79,48 @@ jobs: timeout-minutes: 15 with: limit-access-to-actor: true + install-flake: + strategy: + fail-fast: true + matrix: + channel: [nixpkgs-22.11-darwin, nixpkgs-unstable] runs-on: macos-12 - timeout-minutes: 60 + timeout-minutes: 30 steps: - uses: actions/checkout@v3 + - name: Install nix version corresponding to latest stable channel + uses: cachix/install-nix-action@v20 with: - fetch-depth: 0 - - uses: cachix/install-nix-action@v20 + install_url: https://github.com/nix-community/nix-unstable-installer/releases/download/nix-2.10.0pre20220822_7c3ab57/install + nix_path: nixpkgs=channel:${{ matrix.channel }} + extra_nix_config: | + access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} + if: ${{ matrix.channel == 'nixpkgs-22.11-darwin' }} + - name: Install nix from current unstable channel + uses: cachix/install-nix-action@v20 with: - install_url: https://github.com/numtide/nix-flakes-installer/releases/download/nix-2.10.0pre20220808_73fde9e/install - extra_nix_config: | - experimental-features = nix-command flakes - access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} - - run: | - nix-channel --add https://nixos.org/channels/nixpkgs-unstable nixpkgs + nix_path: nixpkgs=channel:${{ matrix.channel }} + extra_nix_config: | + access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} + if: ${{ matrix.channel == 'nixpkgs-unstable' }} + - name: Install ${{ matrix.channel }} channel + run: | + nix-channel --add https://nixos.org/channels/${{ matrix.channel }} nixpkgs nix-channel --update - - run: | + - name: Install nix-darwin and test result + run: | export NIX_PATH=$HOME/.nix-defexpr/channels nix-shell -A installer - - run: | + nix-shell -A installer.check + - name: Build simple flake configuration + run: | nix build ./modules/examples#darwinConfigurations.simple.system --override-input darwin . - - run: | + - name: Activate derivation of simple flake build + run: | ./result/sw/bin/darwin-rebuild switch --flake ./modules/examples#simple --override-input darwin . - - run: | + - name: Rebuild and activate simple flake, but this time using nix-darwins flake interface + run: | . /etc/static/bashrc darwin-rebuild build --flake ./modules/examples#simple --override-input darwin . - name: Test git submodules diff --git a/.github/workflows/update-manual.yml b/.github/workflows/update-manual.yml index 6ef90ffe..b6590640 100644 --- a/.github/workflows/update-manual.yml +++ b/.github/workflows/update-manual.yml @@ -24,7 +24,7 @@ jobs: - name: Build manual run: | - nix-build ./release.nix -I nixpkgs=channel:nixpkgs-22.05-darwin -I darwin=. -A manualHTML + nix-build ./release.nix -I nixpkgs=channel:nixpkgs-22.11-darwin -I darwin=. -A manualHTML - name: Push update to manual run: | From ebdd18cdc169f680a1385c0d26dfe92dc5062ade Mon Sep 17 00:00:00 2001 From: Jan Schmitt Date: Fri, 19 May 2023 13:33:38 +0200 Subject: [PATCH 4/4] ci: refactor to several jobs to enable optional checks --- .github/workflows/test.yml | 207 +++++++++++++++++++++++++++---------- 1 file changed, 153 insertions(+), 54 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 57cd01b3..c117a190 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -3,39 +3,11 @@ on: pull_request: push: -jobs: - tests: - strategy: - fail-fast: true - matrix: - channel: [nixpkgs-22.11-darwin, nixpkgs-unstable] - runs-on: macos-12 - timeout-minutes: 30 - steps: - - uses: actions/checkout@v3 - - name: Install nix corresponding to latest stable channel - uses: cachix/install-nix-action@v20 - with: - install_url: https://github.com/nix-community/nix-unstable-installer/releases/download/nix-2.10.0pre20220822_7c3ab57/install - extra_nix_config: | - access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} - if: ${{ matrix.channel == 'nixpkgs-22.11-darwin' }} - - name: Install nix from current unstable channel - uses: cachix/install-nix-action@v20 - with: - nix_path: nixpkgs=channel:${{ matrix.channel }} - extra_nix_config: | - access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} - if: ${{ matrix.channel == 'nixpkgs-unstable' }} - - run: nix-build ./release.nix -I nixpkgs=channel:${{ matrix.channel }} -I darwin=. -A tests - - run: nix-build ./release.nix -I nixpkgs=channel:${{ matrix.channel }} -I darwin=. -A manpages - - run: nix-build ./release.nix -I nixpkgs=channel:${{ matrix.channel }} -I darwin=. -A examples.simple +env: + CURRENT_STABLE_CHANNEL: nixpkgs-22.11-darwin - install: - strategy: - fail-fast: true - matrix: - channel: [nixpkgs-22.11-darwin, nixpkgs-unstable] +jobs: + test-stable: runs-on: macos-12 timeout-minutes: 30 steps: @@ -44,20 +16,42 @@ jobs: uses: cachix/install-nix-action@v20 with: install_url: https://github.com/nix-community/nix-unstable-installer/releases/download/nix-2.10.0pre20220822_7c3ab57/install - nix_path: nixpkgs=channel:${{ matrix.channel }} extra_nix_config: | access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} - if: ${{ matrix.channel == 'nixpkgs-22.11-darwin' }} + - 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@v20 with: - nix_path: nixpkgs=channel:${{ matrix.channel }} + nix_path: nixpkgs=channel:${{ env.CURRENT_STABLE_CHANNEL }} extra_nix_config: | access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} - if: ${{ matrix.channel == 'nixpkgs-unstable' }} - - name: Install ${{ matrix.channel }} channel + - 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-against-stable: + runs-on: macos-12 + timeout-minutes: 30 + steps: + - uses: actions/checkout@v3 + - name: Install nix corresponding to latest stable channel + uses: cachix/install-nix-action@v20 + with: + install_url: https://github.com/nix-community/nix-unstable-installer/releases/download/nix-2.10.0pre20220822_7c3ab57/install + nix_path: nixpkgs=channel:${{ env.CURRENT_STABLE_CHANNEL }} + extra_nix_config: | + access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} + - name: Install ${{ env.CURRENT_STABLE_CHANNEL }} channel run: | - nix-channel --add https://nixos.org/channels/${{ matrix.channel }} nixpkgs + nix-channel --add https://nixos.org/channels/${{ env.CURRENT_STABLE_CHANNEL }} nixpkgs nix-channel --update - name: Install nix-darwin and test run: | @@ -80,11 +74,43 @@ jobs: with: limit-access-to-actor: true - install-flake: - strategy: - fail-fast: true - matrix: - channel: [nixpkgs-22.11-darwin, nixpkgs-unstable] + 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@v20 + with: + nix_path: nixpkgs=channel:nixpkgs-unstable + extra_nix_config: | + access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} + - 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 + run: | + export NIX_PATH=$HOME/.nix-defexpr/channels + 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 + + install-flake-against-stable: runs-on: macos-12 timeout-minutes: 30 steps: @@ -93,20 +119,93 @@ jobs: uses: cachix/install-nix-action@v20 with: install_url: https://github.com/nix-community/nix-unstable-installer/releases/download/nix-2.10.0pre20220822_7c3ab57/install - nix_path: nixpkgs=channel:${{ matrix.channel }} + nix_path: nixpkgs=channel:${{ env.CURRENT_STABLE_CHANNEL }} extra_nix_config: | access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} - if: ${{ matrix.channel == 'nixpkgs-22.11-darwin' }} - - name: Install nix from current unstable channel - uses: cachix/install-nix-action@v20 - with: - nix_path: nixpkgs=channel:${{ matrix.channel }} - extra_nix_config: | - access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} - if: ${{ matrix.channel == 'nixpkgs-unstable' }} - - name: Install ${{ matrix.channel }} channel + - name: Install ${{ env.CURRENT_STABLE_CHANNEL }} channel run: | - nix-channel --add https://nixos.org/channels/${{ matrix.channel }} nixpkgs + nix-channel --add https://nixos.org/channels/${{ env.CURRENT_STABLE_CHANNEL }} nixpkgs + nix-channel --update + - name: Install nix-darwin and test result + run: | + export NIX_PATH=$HOME/.nix-defexpr/channels + nix-shell -A installer + nix-shell -A installer.check + - name: Build simple flake configuration + run: | + nix build ./modules/examples#darwinConfigurations.simple.system --override-input darwin . + - name: Activate derivation of simple flake build + run: | + ./result/sw/bin/darwin-rebuild switch --flake ./modules/examples#simple --override-input darwin . + - name: Rebuild and activate simple flake, but this time using nix-darwins flake interface + run: | + . /etc/static/bashrc + darwin-rebuild build --flake ./modules/examples#simple --override-input darwin . + - 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 + + pushd /tmp/test-nix-darwin-submodules + /usr/bin/sed -i.bak \ + '\#modules = \[#s#darwin.darwinModules.simple#./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 darwin . \ + && { + 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 darwin . \ + && { + 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 darwin . + + 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@v20 + with: + nix_path: nixpkgs=channel:nixpkgs-unstable + extra_nix_config: | + access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} + - 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 result run: |