From 281b49208c40556c6cdc9d69d817e73440831bd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Tue, 11 Nov 2025 15:12:42 +0100 Subject: [PATCH 1/2] hydra-eval-jobs: use nix-eval-jobs's --select rather --expr the current use of builtins.getFlake, mean we don't have pure evaluation --- src/script/hydra-eval-jobset | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/script/hydra-eval-jobset b/src/script/hydra-eval-jobset index eeea742f5..7eb134123 100755 --- a/src/script/hydra-eval-jobset +++ b/src/script/hydra-eval-jobset @@ -358,21 +358,14 @@ sub evalJobs { my @cmd; if (defined $flakeRef) { - my $nix_expr = - "let " . - "flake = builtins.getFlake (toString \"$flakeRef\"); " . - "in " . - "flake.hydraJobs " . - "or flake.checks " . - "or (throw \"flake '$flakeRef' does not provide any Hydra jobs or checks\")"; - @cmd = ("nix-eval-jobs", # Disable the eval cache to prevent SQLite database contention. # Since Hydra typically evaluates each revision only once, # parallel workers would compete for database locks without # providing any benefit from caching. "--option", "eval-cache", "false", - "--expr", $nix_expr); + "--flake", $flakeRef, + "--select", "flake: flake.outputs.hydraJobs or flake.outputs.checks or (throw \"flake '$flakeRef' does not provide any Hydra jobs or checks\")"); } else { my $nixExprInput = $inputInfo->{$nixExprInputName}->[0] or die "cannot find the input containing the job expression\n"; From b254962aa84512e7d91960e7e7736d21926bd0fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Tue, 11 Nov 2025 15:39:23 +0100 Subject: [PATCH 2/2] make flake.nix test pure --- t/jobs/basic.nix | 4 +++- t/jobs/config.nix.in | 4 +++- t/jobs/flake-checks/flake.nix | 13 +++++++++---- t/jobs/flake-hydraJobs/flake.nix | 13 +++++++++---- 4 files changed, 24 insertions(+), 10 deletions(-) diff --git a/t/jobs/basic.nix b/t/jobs/basic.nix index 9e207f80a..31b613f59 100644 --- a/t/jobs/basic.nix +++ b/t/jobs/basic.nix @@ -1,4 +1,6 @@ -with import ./config.nix; +{ system ? builtins.currentSystem }: + +with import ./config.nix { inherit system; }; { empty_dir = mkDerivation { diff --git a/t/jobs/config.nix.in b/t/jobs/config.nix.in index 41776341c..9f9ecbf00 100644 --- a/t/jobs/config.nix.in +++ b/t/jobs/config.nix.in @@ -1,9 +1,11 @@ +{ system ? builtins.currentSystem }: + rec { path = "@testPath@"; mkDerivation = args: derivation ({ - system = builtins.currentSystem; + inherit system; PATH = path; } // args); mkContentAddressedDerivation = args: mkDerivation ({ diff --git a/t/jobs/flake-checks/flake.nix b/t/jobs/flake-checks/flake.nix index 489fa9ecc..f5609a9dd 100644 --- a/t/jobs/flake-checks/flake.nix +++ b/t/jobs/flake-checks/flake.nix @@ -1,6 +1,11 @@ { - outputs = { ... }: { - checks = - import ./basic.nix; - }; + outputs = { self, ... }: + let + systems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ]; + forAllSystems = f: builtins.listToAttrs (map (system: { name = system; value = f system; }) systems); + in { + checks = forAllSystems (system: + import ./basic.nix { inherit system; } + ); + }; } diff --git a/t/jobs/flake-hydraJobs/flake.nix b/t/jobs/flake-hydraJobs/flake.nix index c02ccddd8..5e9b41c66 100644 --- a/t/jobs/flake-hydraJobs/flake.nix +++ b/t/jobs/flake-hydraJobs/flake.nix @@ -1,6 +1,11 @@ { - outputs = { ... }: { - hydraJobs = - import ./basic.nix; - }; + outputs = { self, ... }: + let + systems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ]; + forAllSystems = f: builtins.listToAttrs (map (system: { name = system; value = f system; }) systems); + in { + hydraJobs = forAllSystems (system: + import ./basic.nix { inherit system; } + ); + }; }