From 8b991d2076b20761214591e729191bc8aa8ae781 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Fri, 1 Nov 2024 13:24:21 +0100 Subject: [PATCH] try ofborg eval --- .github/workflows/eval.yml | 12 +++++-- ci/eval-nixpkgs.sh | 19 +++++----- ci/outpaths.nix | 72 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 92 insertions(+), 11 deletions(-) create mode 100755 ci/outpaths.nix diff --git a/.github/workflows/eval.yml b/.github/workflows/eval.yml index cca52bcefeb4e..c79bd4627730e 100644 --- a/.github/workflows/eval.yml +++ b/.github/workflows/eval.yml @@ -13,7 +13,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - arch: [x86_64-linux, aarch64-linux, aarch64-darwin, x86_64-darwin] + system: [x86_64-linux, aarch64-linux, aarch64-darwin, x86_64-darwin] steps: - name: Set up Git run: | @@ -73,8 +73,16 @@ jobs: - uses: cachix/install-nix-action@08dcb3a5e62fa31e2da3d490afc4176ef55ecd72 # v30 if: env.is_pr == 'true' + - name: Enable swap + if: env.is_pr == 'true' + run: | + sudo fallocate -l 10G /swapfile + sudo chmod 600 /swapfile + sudo mkswap /swapfile + sudo swapon /swapfile + - name: Check eval if: env.is_pr == 'true' run: | cd nixpkgs - ./ci/eval-nixpkgs.sh --system "$system" + ./ci/eval-nixpkgs.sh --system "{{matrix.system}} diff --git a/ci/eval-nixpkgs.sh b/ci/eval-nixpkgs.sh index 75a3a1b76062c..2c9c85ddde0c6 100755 --- a/ci/eval-nixpkgs.sh +++ b/ci/eval-nixpkgs.sh @@ -3,6 +3,8 @@ set -euxo pipefail system="x86_64-linux" +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" +NIXPKGS_PATH="$(readlink -f $SCRIPT_DIR/..)" parseArgs() { while [[ $# -gt 0 ]]; do @@ -25,14 +27,13 @@ main() { trap 'rm -rf "$tmpdir"' EXIT ( set +e - nix-env -f . \ - -qa \* \ - --meta \ - --xml \ - --drv-path \ - --show-trace \ - --eval-system "$system" \ - > "$tmpdir/store-path" + nix-env \ + --arg "supportedSystems" "[\"$system\"]" \ + -qaP --no-name \ + --out-path \ + --arg checkMeta true \ + --argstr path "$NIXPKGS_PATH" \ + -f "$SCRIPT_DIR/outpaths.nix" > "$tmpdir/paths" echo $? > "$tmpdir/exit-code" ) & pid=$! @@ -43,4 +44,4 @@ main() { exit "$(cat "$tmpdir/exit-code")" } -main +main "$@" diff --git a/ci/outpaths.nix b/ci/outpaths.nix new file mode 100755 index 0000000000000..694003695ac73 --- /dev/null +++ b/ci/outpaths.nix @@ -0,0 +1,72 @@ +#!/usr/bin/env nix-shell +# When using as a callable script, passing `--argstr path some/path` overrides $PWD. +#!nix-shell -p nix -i "nix-env -qaP --no-name --out-path --arg checkMeta true --argstr path $PWD -f" +{ + checkMeta, + path ? ./.., + supportedSystems ? [ + "aarch64-linux" + "aarch64-darwin" + "x86_64-linux" + "x86_64-darwin" + ], +}: +let + lib = import (path + "/lib"); + hydraJobs = + import (path + "/pkgs/top-level/release.nix") + # Compromise: accuracy vs. resources needed for evaluation. + { + inherit supportedSystems; + + nixpkgsArgs = { + config = { + allowAliases = false; + allowBroken = true; + allowUnfree = true; + allowInsecurePredicate = x: true; + checkMeta = checkMeta; + + handleEvalIssue = + reason: errormsg: + let + fatalErrors = [ + "unknown-meta" + "broken-outputs" + ]; + in + if builtins.elem reason fatalErrors then abort errormsg else true; + + inHydra = true; + }; + }; + }; + recurseIntoAttrs = attrs: attrs // { recurseForDerivations = true; }; + + # hydraJobs leaves recurseForDerivations as empty attrmaps; + # that would break nix-env and we also need to recurse everywhere. + tweak = lib.mapAttrs ( + name: val: + if name == "recurseForDerivations" then + true + else if lib.isAttrs val && val.type or null != "derivation" then + recurseIntoAttrs (tweak val) + else + val + ); + + # Some of these contain explicit references to platform(s) we want to avoid; + # some even (transitively) depend on ~/.nixpkgs/config.nix (!) + blacklist = [ + "tarball" + "metrics" + "manual" + "darwin-tested" + "unstable" + "stdenvBootstrapTools" + "moduleSystem" + "lib-tests" # these just confuse the output + ]; + +in +tweak (builtins.removeAttrs hydraJobs blacklist)