Merge branch 'decl-project-remote-store'

This commit is contained in:
Shea Levy 2017-04-10 11:36:41 -04:00
commit 7e3f12fe10
2 changed files with 23 additions and 3 deletions

View file

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

View file

@ -23,7 +23,7 @@ our @EXPORT = qw(
getEvals getMachines
pathIsInsidePrefix
captureStdoutStderr run grab
getTotalShares
getTotalShares readNixFile
cancelBuilds restartBuilds);
@ -390,7 +390,18 @@ sub run {
my @x = ($args{cmd}, \$stdin, \$res->{stdout});
push @x, \$res->{stderr} if $args{grabStderr} // 1;
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;
};
@ -479,4 +490,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;