Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 21 additions & 9 deletions src/script/hydra-eval-jobset
Original file line number Diff line number Diff line change
Expand Up @@ -358,13 +358,24 @@ 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\")";
my $nix_expr;
my ($ref, $attr) = split '#', $flakeRef, 2;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be great to switch this over to --select: nix-community/nix-eval-jobs@5738c86

otherwise it's impure eval.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

of course we already had this issue before hand.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, for now I can cherry pick this and I can look at --select after this repo is updated to 2.31.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll try to get the ci fixed for 2.31 asap.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't mind carrying the patch for a while so don't rush the work on 2.31 unless you've got other reasons.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have the new nix-eval-jobs now.

if (defined $attr) {
$nix_expr =
"let " .
"flake = builtins.getFlake (toString \"$ref\"); " .
"in " .
"flake.${attr} " .
"or (throw \"flake '$ref' does not provide attribute '$attr'\")";
} else {
$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.
Expand Down Expand Up @@ -713,12 +724,13 @@ sub checkJobsetWrapped {

my $flakeRef = $jobset->flake;
if (defined $flakeRef) {
my ($ref, $attr) = split '#', $flakeRef, 2;
(my $res, my $json, my $stderr) = captureStdoutStderr(
600, "nix", "flake", "metadata", "--refresh", "--json", "--", $flakeRef);
600, "nix", "flake", "metadata", "--refresh", "--json", "--", $ref);
die "'nix flake metadata' returned " . ($res & 127 ? "signal $res" : "exit code " . ($res >> 8))
. ":\n" . ($stderr ? decode("utf-8", $stderr) : "(no output)\n")
if $res;
$flakeRef = decode_json($json)->{'url'};
$ref = decode_json($json)->{'url'};
Copy link

@mipmip mipmip Sep 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this PR the evaluator stops picking up new changes.

After testing I found out that this line should stay $flakeRef = decode_json($json)->{'url'};.

}

Net::Statsd::increment("hydra.evaluator.checkouts");
Expand Down
13 changes: 11 additions & 2 deletions t/evaluator/evaluate-flake.t
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ my $ctx = test_context(
);

sub checkFlake {
my ($flake) = @_;
my ($input) = @_;
my ($flake, $attr) = split '#', $input, 2;

cp($ctx->jobsdir . "/basic.nix", $ctx->jobsdir . "/" . $flake);
cp($ctx->jobsdir . "/config.nix", $ctx->jobsdir . "/" . $flake);
Expand All @@ -30,7 +31,7 @@ sub checkFlake {
chmod 0755, $ctx->jobsdir . "/" . $flake . "/succeed-with-failed.sh";

my $builds = $ctx->makeAndEvaluateJobset(
flake => 'path:' . $ctx->jobsdir . "/" . $flake,
flake => 'path:' . $ctx->jobsdir . "/" . $input,
build => 1
);

Expand Down Expand Up @@ -64,4 +65,12 @@ subtest "Flake using `hydraJobs`" => sub {
checkFlake 'flake-hydraJobs'
};

subtest "Flake using explict `hydraJobs`" => sub {
checkFlake 'flake-hydraJobs#hydraJobs'
};

subtest "Flake using explict `attr`" => sub {
checkFlake 'flake-attr#attr'
};

done_testing;
6 changes: 6 additions & 0 deletions t/jobs/flake-attr/flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
outputs = { ... }: {
attr =
import ./basic.nix;
};
}