declarative projects: Pull jobset spec build from the remote store

Fixes #443
This commit is contained in:
Shea Levy 2017-04-01 10:38:39 -04:00
parent 3e0ee24b87
commit a738f826e8
2 changed files with 23 additions and 3 deletions

View file

@ -68,7 +68,7 @@ sub handleDeclarativeJobsetBuild {
my $id = $build->id; my $id = $build->id;
die "Declarative jobset build $id failed" unless $build->buildstatus == 0; die "Declarative jobset build $id failed" unless $build->buildstatus == 0;
my $declPath = ($build->buildoutputs)[0]->path; my $declPath = ($build->buildoutputs)[0]->path;
my $declText = read_file($declPath) my $declText = readNixFile($declPath)
or die "Couldn't read declarative specification file $declPath: $!"; or die "Couldn't read declarative specification file $declPath: $!";
my $declSpec = decode_json($declText); my $declSpec = decode_json($declText);
txn_do($db, sub { txn_do($db, sub {

View file

@ -23,7 +23,7 @@ our @EXPORT = qw(
getEvals getMachines getEvals getMachines
pathIsInsidePrefix pathIsInsidePrefix
captureStdoutStderr run grab captureStdoutStderr run grab
getTotalShares getTotalShares readNixFile
cancelBuilds restartBuilds); cancelBuilds restartBuilds);
@ -412,7 +412,18 @@ sub run {
my @x = ($args{cmd}, \$stdin, \$res->{stdout}); my @x = ($args{cmd}, \$stdin, \$res->{stdout});
push @x, \$res->{stderr} if $args{grabStderr} // 1; push @x, \$res->{stderr} if $args{grabStderr} // 1;
IPC::Run::run(@x, IPC::Run::run(@x,
init => sub { chdir $args{dir} or die "changing to $args{dir}" if defined $args{dir}; }); init => sub {
chdir $args{dir} or die "changing to $args{dir}" if defined $args{dir};
if (defined $args{env}) {
foreach my $key (keys %{$args{env}}) {
if (defined $args{env}->{$key}) {
$ENV{$key} = $args{env}->{$key};
} else {
delete $ENV{$key};
}
}
}
});
alarm 0; alarm 0;
}; };
@ -501,4 +512,13 @@ sub restartBuilds($$) {
} }
# Read a file from the (possibly remote) nix store
sub readNixFile {
my ($path) = @_;
my $config = getHydraConfig();
my $storeUri = $config->{'store_uri'} // "";
return grab(cmd => ["nix", "cat-store", "$path"], env => { NIX_REMOTE => "$storeUri" });
}
1; 1;