Pass inputs to release expressions using -I

This means that you can now write (for instance)

  with <nixpkgs> { ... };

in release.nix, rather than

  { nixpkgs } :

  with nixpkgs { ... };
This commit is contained in:
Eelco Dolstra 2011-12-05 13:08:43 +01:00
parent 9d4b2253ea
commit 3b9a62c964
3 changed files with 11 additions and 1 deletions

View file

@ -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

View file

@ -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") {

View file

@ -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});