From 3b9a62c964013b100c4787bdae5e20652672923c Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 5 Dec 2011 13:08:43 +0100 Subject: [PATCH] Pass inputs to release expressions using -I This means that you can now write (for instance) with { ... }; in release.nix, rather than { nixpkgs } : with nixpkgs { ... }; --- src/c/hydra-eval-jobs.cc | 7 +++++++ src/lib/Hydra/Helper/AddBuilds.pm | 3 +++ src/script/hydra-evaluator | 2 +- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/c/hydra-eval-jobs.cc b/src/c/hydra-eval-jobs.cc index a13b3eb5..7c10988d 100644 --- a/src/c/hydra-eval-jobs.cc +++ b/src/c/hydra-eval-jobs.cc @@ -9,6 +9,7 @@ #include "util.hh" #include "xml-writer.hh" #include "get-drvs.hh" +#include "common-opts.hh" using namespace nix; @@ -203,6 +204,10 @@ void run(Strings args) EvalState state; Path releaseExpr; AutoArgs autoArgs; + + /* Prevent undeclared dependencies in the evaluation via + $HYDRA_PATH. */ + unsetenv("HYDRA_PATH"); for (Strings::iterator i = args.begin(); i != args.end(); ) { string arg = *i++; @@ -226,6 +231,8 @@ void run(Strings args) if (i == args.end()) throw UsageError("missing argument"); gcRootsDir = *i++; } + else if (parseSearchPathArg(arg, i, args.end(), state)) + ; else if (arg[0] == '-') throw UsageError(format("unknown flag `%1%'") % arg); else diff --git a/src/lib/Hydra/Helper/AddBuilds.pm b/src/lib/Hydra/Helper/AddBuilds.pm index 00588fcc..e1f48bea 100644 --- a/src/lib/Hydra/Helper/AddBuilds.pm +++ b/src/lib/Hydra/Helper/AddBuilds.pm @@ -604,6 +604,9 @@ sub inputsToArgs { my @res = (); foreach my $input (keys %{$inputInfo}) { + push @res, "-I", "$input=$inputInfo->{$input}->[0]->{storePath}" + if scalar @{$inputInfo->{$input}} == 1 + && defined $inputInfo->{$input}->[0]->{storePath}; foreach my $alt (@{$inputInfo->{$input}}) { given ($alt->{type}) { when ("string") { diff --git a/src/script/hydra-evaluator b/src/script/hydra-evaluator index 8c781e30..92632be3 100755 --- a/src/script/hydra-evaluator +++ b/src/script/hydra-evaluator @@ -115,7 +115,7 @@ sub checkJobset { my @args = ($jobset->nixexprinput, $jobset->nixexprpath, inputsToArgs($inputInfo)); my $argsHash = sha256_hex("@args"); - if ($jobset->jobsetevals->find({hash => $argsHash})) { + if (scalar($jobset->jobsetevals->search({hash => $argsHash})) > 0) { print " already evaluated, skipping\n"; txn_do($db, sub { $jobset->update({lastcheckedtime => time});