From 113a312f6717ae81327b4d5bb91a16ae06e0933e Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Tue, 3 Mar 2020 22:32:13 -0500 Subject: [PATCH 1/3] handleDeclarativeJobsetBuild: handle errors from readNixFile --- src/lib/Hydra/Helper/AddBuilds.pm | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/lib/Hydra/Helper/AddBuilds.pm b/src/lib/Hydra/Helper/AddBuilds.pm index 40375c6b..296afbc5 100644 --- a/src/lib/Hydra/Helper/AddBuilds.pm +++ b/src/lib/Hydra/Helper/AddBuilds.pm @@ -68,8 +68,14 @@ sub handleDeclarativeJobsetBuild { my $id = $build->id; die "Declarative jobset build $id failed" unless $build->buildstatus == 0; my $declPath = ($build->buildoutputs)[0]->path; - my $declText = readNixFile($declPath) - or die "Couldn't read declarative specification file $declPath: $!"; + my $declText = eval { + readNixFile($declPath) + }; + if ($@) { + print STDERR "ERROR: failed to readNixFile $declPath: ", $@, "\n"; + die; + } + my $declSpec = decode_json($declText); txn_do($db, sub { my @kept = keys %$declSpec; From 117b9ecef18e4bf63b84a9cce0b0d3ae7d8910e9 Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Tue, 3 Mar 2020 22:36:21 -0500 Subject: [PATCH 2/3] =?UTF-8?q?Nix.pm:=20readNixFile:=20pass=20=C2=AB--exp?= =?UTF-8?q?erimental-features=20nix-command=C2=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Declarative jobsets were broken by the Nix update, causing nix cat-file to break silently. This commit restores declarative jobsets, based on top of a commit making it easier to see what broke. --- src/lib/Hydra/Helper/Nix.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lib/Hydra/Helper/Nix.pm b/src/lib/Hydra/Helper/Nix.pm index 8ce284ad..5034c81b 100644 --- a/src/lib/Hydra/Helper/Nix.pm +++ b/src/lib/Hydra/Helper/Nix.pm @@ -509,7 +509,8 @@ sub getStoreUri { # Read a file from the (possibly remote) nix store sub readNixFile { my ($path) = @_; - return grab(cmd => ["nix", "cat-store", "--store", getStoreUri(), "$path"]); + return grab(cmd => ["nix", "--experimental-features", "nix-command", + "cat-store", "--store", getStoreUri(), "$path"]); } From 994430b94bb3d237ee8380a0942c58a44dc94c06 Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Tue, 3 Mar 2020 22:46:32 -0500 Subject: [PATCH 3/3] treewide: allow `nix` command --- src/lib/Hydra/Controller/Build.pm | 6 ++++-- src/script/hydra-eval-jobset | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/lib/Hydra/Controller/Build.pm b/src/lib/Hydra/Controller/Build.pm index 22bfd98e..52cb71dd 100644 --- a/src/lib/Hydra/Controller/Build.pm +++ b/src/lib/Hydra/Controller/Build.pm @@ -193,7 +193,8 @@ sub checkPath { sub serveFile { my ($c, $path) = @_; - my $res = run(cmd => ["nix", "ls-store", "--store", getStoreUri(), "--json", "$path"]); + my $res = run(cmd => ["nix", "--experimental-features", "nix-command", + "ls-store", "--store", getStoreUri(), "--json", "$path"]); if ($res->{status}) { notFound($c, "File '$path' does not exist.") if $res->{stderr} =~ /does not exist/; @@ -217,7 +218,8 @@ sub serveFile { elsif ($ls->{type} eq "regular") { - $c->stash->{'plain'} = { data => grab(cmd => ["nix", "cat-store", "--store", getStoreUri(), "$path"]) }; + $c->stash->{'plain'} = { data => grab(cmd => ["nix", "--experimental-features", "nix-command", + "cat-store", "--store", getStoreUri(), "$path"]) }; # Detect MIME type. Borrowed from Catalyst::Plugin::Static::Simple. my $type = "text/plain"; diff --git a/src/script/hydra-eval-jobset b/src/script/hydra-eval-jobset index cdb09b74..53a16f38 100755 --- a/src/script/hydra-eval-jobset +++ b/src/script/hydra-eval-jobset @@ -82,7 +82,7 @@ sub getPath { my $substituter = $config->{eval_substituter}; - system("nix", "copy", "--from", $substituter, "--", $path) + system("nix", "--experimental-features", "nix-command", "copy", "--from", $substituter, "--", $path) if defined $substituter; return isValidPath($path);