From e90894103a9d811b90b3e5950e58d8adcaf19334 Mon Sep 17 00:00:00 2001 From: Wolfgang Walther Date: Mon, 5 May 2025 19:29:11 +0200 Subject: [PATCH 1/8] workflows/lib-tests: rename from eval-lib-tests They are not really related to eval.yml. --- .github/workflows/{eval-lib-tests.yml => lib-tests.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{eval-lib-tests.yml => lib-tests.yml} (100%) diff --git a/.github/workflows/eval-lib-tests.yml b/.github/workflows/lib-tests.yml similarity index 100% rename from .github/workflows/eval-lib-tests.yml rename to .github/workflows/lib-tests.yml From 7097614efd0f7a2c8ddd071a759a10451e02f3a5 Mon Sep 17 00:00:00 2001 From: Wolfgang Walther Date: Mon, 5 May 2025 19:26:47 +0200 Subject: [PATCH 2/8] ci/lib-tests: init This allows running the lib-tests locally in exactly the same way that they are run in CI: nix-build ci -A lib-tests --- .github/workflows/lib-tests.yml | 2 +- ci/default.nix | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/lib-tests.yml b/.github/workflows/lib-tests.yml index 722371ac19a2..0643f980381b 100644 --- a/.github/workflows/lib-tests.yml +++ b/.github/workflows/lib-tests.yml @@ -28,4 +28,4 @@ jobs: - name: Building Nixpkgs lib-tests run: | - nix-build --arg pkgs "(import ./ci/. {}).pkgs" ./lib/tests/release.nix + nix-build ci -A lib-tests diff --git a/ci/default.nix b/ci/default.nix index 67f59d61bfd4..d47608566d58 100644 --- a/ci/default.nix +++ b/ci/default.nix @@ -70,4 +70,7 @@ in requestReviews = pkgs.callPackage ./request-reviews { }; codeownersValidator = pkgs.callPackage ./codeowners-validator { }; eval = pkgs.callPackage ./eval { }; + + # CI jobs + lib-tests = import ../lib/tests/release.nix { inherit pkgs; }; } From 89520b962a78d01b484c139095def6599675d1f3 Mon Sep 17 00:00:00 2001 From: Wolfgang Walther Date: Mon, 5 May 2025 21:28:41 +0200 Subject: [PATCH 3/8] ci/manual-nixos: init The NixOS manual can now be built locally the same way as in CI with: nix-build ci -A manual-nixos --- .github/workflows/manual-nixos-v2.yml | 2 +- ci/default.nix | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/manual-nixos-v2.yml b/.github/workflows/manual-nixos-v2.yml index 26fa03aba9b4..d69cf3bbf409 100644 --- a/.github/workflows/manual-nixos-v2.yml +++ b/.github/workflows/manual-nixos-v2.yml @@ -46,7 +46,7 @@ jobs: - name: Build NixOS manual id: build-manual - run: NIX_PATH=nixpkgs=$(pwd) nix-build --option restrict-eval true nixos/release.nix -A manual.${{ matrix.system }} + run: NIX_PATH=nixpkgs=$(pwd) nix-build --option restrict-eval true ci -A manual --argstr system ${{ matrix.system }} - name: Upload NixOS manual uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 diff --git a/ci/default.nix b/ci/default.nix index d47608566d58..80e5fb382d6e 100644 --- a/ci/default.nix +++ b/ci/default.nix @@ -73,4 +73,5 @@ in # CI jobs lib-tests = import ../lib/tests/release.nix { inherit pkgs; }; + manual-nixos = (import ../nixos/release.nix { }).manual.${system} or null; } From d253ad12b2eb1445a57892031260b034e741eced Mon Sep 17 00:00:00 2001 From: Wolfgang Walther Date: Mon, 5 May 2025 21:35:03 +0200 Subject: [PATCH 4/8] ci/manual-nixpkgs: init The Nixpkgs manual can now be built locally the same way as in CI with: nix-build ci -A manual-nixpkgs -A manual-nixpkgs-tests --- .github/workflows/manual-nixpkgs-v2.yml | 2 +- ci/default.nix | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/manual-nixpkgs-v2.yml b/.github/workflows/manual-nixpkgs-v2.yml index a97bd0aac719..66075b7089db 100644 --- a/.github/workflows/manual-nixpkgs-v2.yml +++ b/.github/workflows/manual-nixpkgs-v2.yml @@ -32,4 +32,4 @@ jobs: authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' - name: Building Nixpkgs manual - run: NIX_PATH=nixpkgs=$(pwd) nix-build --option restrict-eval true pkgs/top-level/release.nix -A manual -A manual.tests + run: NIX_PATH=nixpkgs=$(pwd) nix-build --option restrict-eval true ci -A manual-nixpkgs -A manual-nixpkgs-tests diff --git a/ci/default.nix b/ci/default.nix index 80e5fb382d6e..328194b506d3 100644 --- a/ci/default.nix +++ b/ci/default.nix @@ -74,4 +74,6 @@ in # CI jobs lib-tests = import ../lib/tests/release.nix { inherit pkgs; }; manual-nixos = (import ../nixos/release.nix { }).manual.${system} or null; + manual-nixpkgs = (import ../pkgs/top-level/release.nix { }).manual; + manual-nixpkgs-tests = (import ../pkgs/top-level/release.nix { }).manual.tests; } From 7c16d15d7f188672c1a371dc17de08289e741089 Mon Sep 17 00:00:00 2001 From: Wolfgang Walther Date: Tue, 6 May 2025 21:39:59 +0200 Subject: [PATCH 5/8] ci/shell: init The dev shell can now be built locally the same way as in CI with: nix-build ci -A shell --- .github/workflows/check-shell.yml | 2 +- ci/default.nix | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/check-shell.yml b/.github/workflows/check-shell.yml index d148563c4311..3e8df619dbd1 100644 --- a/.github/workflows/check-shell.yml +++ b/.github/workflows/check-shell.yml @@ -30,4 +30,4 @@ jobs: - uses: cachix/install-nix-action@526118121621777ccd86f79b04685a9319637641 # v31 - name: Build shell - run: nix-build shell.nix + run: nix-build ci -A shell diff --git a/ci/default.nix b/ci/default.nix index 328194b506d3..396fb172df23 100644 --- a/ci/default.nix +++ b/ci/default.nix @@ -76,4 +76,5 @@ in manual-nixos = (import ../nixos/release.nix { }).manual.${system} or null; manual-nixpkgs = (import ../pkgs/top-level/release.nix { }).manual; manual-nixpkgs-tests = (import ../pkgs/top-level/release.nix { }).manual.tests; + shell = import ../shell.nix { inherit nixpkgs system; }; } From a553ef2950e1e7f35491c19c3b61ba22e73a0d08 Mon Sep 17 00:00:00 2001 From: Wolfgang Walther Date: Sat, 10 May 2025 21:55:05 +0200 Subject: [PATCH 6/8] ci/parse: init The nix-parse workflow can now be run locally the same way as in CI. To do this, the CI's workflow was slightly adjusted. Instead of testing only the changed files, we're now testing all files in the repository. This is possible in two ways: 1. By calling nix-instantiate once with all files as arguments. This will be rather fast, but only the first error is shown before it errors out. 2. By calling nix-instantiate once for each file. This will be much slower, but has the advantage that we see all errors at once. To avoid running the long variant every time, we first do a quick check with the fast version. If that fails, we run the slower one to report the errors. This gives us the best of both. --- .github/workflows/nix-parse-v2.yml | 21 ++------------- ci/default.nix | 3 +++ ci/parse.nix | 43 ++++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 19 deletions(-) create mode 100644 ci/parse.nix diff --git a/.github/workflows/nix-parse-v2.yml b/.github/workflows/nix-parse-v2.yml index cc988e20bd6e..706cc34619bb 100644 --- a/.github/workflows/nix-parse-v2.yml +++ b/.github/workflows/nix-parse-v2.yml @@ -15,18 +15,6 @@ jobs: needs: get-merge-commit if: "needs.get-merge-commit.outputs.mergedSha && !contains(github.event.pull_request.title, '[skip treewide]')" steps: - - name: Get list of changed files from PR - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - gh api \ - repos/${{ github.repository }}/pulls/${{github.event.number}}/files --paginate \ - | jq --raw-output '.[] | select(.status != "removed" and (.filename | endswith(".nix"))) | .filename' \ - > "$HOME/changed_files" - if [[ -s "$HOME/changed_files" ]]; then - echo "CHANGED_FILES=$HOME/changed_files" > "$GITHUB_ENV" - fi - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: ref: ${{ needs.get-merge-commit.outputs.mergedSha }} @@ -37,11 +25,6 @@ jobs: extra_nix_config: sandbox = true nix_path: nixpkgs=channel:nixpkgs-unstable - - name: Parse all changed or added nix files + - name: Parse all nix files run: | - ret=0 - while IFS= read -r file; do - out="$(nix-instantiate --parse "$file")" || { echo "$out" && ret=1; } - done < "$HOME/changed_files" - exit "$ret" - if: ${{ env.CHANGED_FILES && env.CHANGED_FILES != '' }} + nix-build ci -A parse diff --git a/ci/default.nix b/ci/default.nix index 396fb172df23..67b1eddf1000 100644 --- a/ci/default.nix +++ b/ci/default.nix @@ -76,5 +76,8 @@ in manual-nixos = (import ../nixos/release.nix { }).manual.${system} or null; manual-nixpkgs = (import ../pkgs/top-level/release.nix { }).manual; manual-nixpkgs-tests = (import ../pkgs/top-level/release.nix { }).manual.tests; + parse = pkgs.lib.recurseIntoAttrs { + latest = pkgs.callPackage ./parse.nix { nix = pkgs.nixVersions.latest; }; + }; shell = import ../shell.nix { inherit nixpkgs system; }; } diff --git a/ci/parse.nix b/ci/parse.nix new file mode 100644 index 000000000000..26ac0f785fd4 --- /dev/null +++ b/ci/parse.nix @@ -0,0 +1,43 @@ +{ + lib, + nix, + runCommand, +}: +let + nixpkgs = + with lib.fileset; + toSource { + root = ../.; + fileset = (fileFilter (file: file.hasExt "nix") ../.); + }; +in +runCommand "nix-parse-${nix.name}" + { + nativeBuildInputs = [ + nix + ]; + } + '' + export NIX_STORE_DIR=$TMPDIR/store + export NIX_STATE_DIR=$TMPDIR/state + + cd "${nixpkgs}" + + # Passes all files to nix-instantiate at once. + # Much faster, but will only show first error. + parse-all() { + find . -type f -iname '*.nix' | xargs -P $(nproc) nix-instantiate --parse >/dev/null 2>/dev/null + } + + # Passes each file separately to nix-instantiate with -n1. + # Much slower, but will show all errors. + parse-each() { + find . -type f -iname '*.nix' | xargs -n1 -P $(nproc) nix-instantiate --parse >/dev/null + } + + if ! parse-all; then + parse-each + fi + + touch $out + '' From 8980c1f7fc23102fb723a41bc70cc3233ef5f62b Mon Sep 17 00:00:00 2001 From: Wolfgang Walther Date: Sat, 10 May 2025 22:23:24 +0200 Subject: [PATCH 7/8] various: fix parse errors for nix 2.3 Path interpolation syntax is not supported in the minimum nix version. --- nixos/tests/scion/freestanding-deployment/default.nix | 2 +- pkgs/test/make-binary-wrapper/default.nix | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/nixos/tests/scion/freestanding-deployment/default.nix b/nixos/tests/scion/freestanding-deployment/default.nix index ca6c7cffc30e..7dbd10c225a5 100644 --- a/nixos/tests/scion/freestanding-deployment/default.nix +++ b/nixos/tests/scion/freestanding-deployment/default.nix @@ -23,7 +23,7 @@ import ../../make-test-python.nix ( networkConfig.Address = "192.168.1.${toString hostId}/24"; }; environment.etc = { - "scion/topology.json".source = ./topology${toString hostId}.json; + "scion/topology.json".source = ./topology + "${toString hostId}.json"; "scion/crypto/as".source = trust-root-configuration-keys + "/AS${toString hostId}"; "scion/certs/ISD42-B1-S1.trc".source = trust-root-configuration-keys + "/ISD42-B1-S1.trc"; "scion/keys/master0.key".text = "U${toString hostId}v4k23ZXjGDwDofg/Eevw=="; diff --git a/pkgs/test/make-binary-wrapper/default.nix b/pkgs/test/make-binary-wrapper/default.nix index 6f086de299a0..715b28f912e4 100644 --- a/pkgs/test/make-binary-wrapper/default.nix +++ b/pkgs/test/make-binary-wrapper/default.nix @@ -20,7 +20,7 @@ let runCommand "make-binary-wrapper-test-${testname}" env '' mkdir -p tmp/foo # for the chdir test - source=${./${testname}} + source=${./. + "/${testname}"} params=$(<"$source/${testname}.cmdline") eval "makeCWrapper /send/me/flags $params" > wrapper.c From 101a271eed66eb4c2ec5b1e286c92e154c0f51eb Mon Sep 17 00:00:00 2001 From: Wolfgang Walther Date: Sat, 10 May 2025 21:56:40 +0200 Subject: [PATCH 8/8] ci/parse: test for nix 2.3 and lix This adds the minimum nix version and the latest lix version to the matrix of parse checks. Especially the minimum nix version is relevant, because parsing routinely breaks because of introduction of newer syntax. Adding lix just completes the picture. --- .github/workflows/nix-parse-v2.yml | 3 ++- ci/default.nix | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/nix-parse-v2.yml b/.github/workflows/nix-parse-v2.yml index 706cc34619bb..019ad770672b 100644 --- a/.github/workflows/nix-parse-v2.yml +++ b/.github/workflows/nix-parse-v2.yml @@ -27,4 +27,5 @@ jobs: - name: Parse all nix files run: | - nix-build ci -A parse + # Tests multiple versions at once, let's make sure all of them run, so keep-going. + nix-build ci -A parse --keep-going diff --git a/ci/default.nix b/ci/default.nix index 67b1eddf1000..dd21e1858492 100644 --- a/ci/default.nix +++ b/ci/default.nix @@ -78,6 +78,8 @@ in manual-nixpkgs-tests = (import ../pkgs/top-level/release.nix { }).manual.tests; parse = pkgs.lib.recurseIntoAttrs { latest = pkgs.callPackage ./parse.nix { nix = pkgs.nixVersions.latest; }; + lix = pkgs.callPackage ./parse.nix { nix = pkgs.lix; }; + minimum = pkgs.callPackage ./parse.nix { nix = pkgs.nixVersions.minimum; }; }; shell = import ../shell.nix { inherit nixpkgs system; }; }