Remove remaining references to store_mode etc.
This commit is contained in:
parent
cc64e51f75
commit
bc60fccf78
|
@ -53,6 +53,9 @@ sub getChannelData {
|
|||
|
||||
sub closure : Chained('nix') PathPart {
|
||||
my ($self, $c) = @_;
|
||||
|
||||
requireLocalStore($c);
|
||||
|
||||
$c->stash->{current_view} = 'NixClosure';
|
||||
|
||||
getChannelData($c, 1);
|
||||
|
@ -68,6 +71,7 @@ sub closure : Chained('nix') PathPart {
|
|||
|
||||
sub manifest : Chained('nix') PathPart("MANIFEST") Args(0) {
|
||||
my ($self, $c) = @_;
|
||||
requireLocalStore($c);
|
||||
$c->stash->{current_view} = 'NixManifest';
|
||||
$c->stash->{narBase} = $c->uri_for($c->controller('Root')->action_for("nar"));
|
||||
getChannelData($c, 1);
|
||||
|
@ -86,6 +90,8 @@ sub pkg : Chained('nix') PathPart Args(1) {
|
|||
|| notFound($c, "No such package in this channel.");
|
||||
}
|
||||
|
||||
requireLocalStore($c);
|
||||
|
||||
gone($c, "Build " . $c->stash->{build}->id . " is no longer available.")
|
||||
unless all { isValidPath($_->path) } $c->stash->{build}->buildoutputs->all;
|
||||
|
||||
|
@ -97,6 +103,7 @@ sub pkg : Chained('nix') PathPart Args(1) {
|
|||
|
||||
sub nixexprs : Chained('nix') PathPart('nixexprs.tar.bz2') Args(0) {
|
||||
my ($self, $c) = @_;
|
||||
requireLocalStore($c);
|
||||
$c->stash->{current_view} = 'NixExprs';
|
||||
getChannelData($c, 1);
|
||||
}
|
||||
|
@ -126,6 +133,7 @@ sub sortPkgs {
|
|||
|
||||
sub channel_contents : Chained('nix') PathPart('') Args(0) {
|
||||
my ($self, $c) = @_;
|
||||
requireLocalStore($c);
|
||||
# Optimistically assume that none of the packages have been
|
||||
# garbage-collected. That should be true for the "latest"
|
||||
# channel.
|
||||
|
|
|
@ -65,9 +65,9 @@ sub build_GET {
|
|||
|
||||
$c->stash->{template} = 'build.tt';
|
||||
$c->stash->{available} =
|
||||
($c->config->{store_mode} // "direct") eq "direct"
|
||||
isLocalStore
|
||||
? all { isValidPath($_->path) } $build->buildoutputs->all
|
||||
: 1; # FIXME
|
||||
: 1;
|
||||
$c->stash->{drvAvailable} = isValidPath $build->drvpath;
|
||||
|
||||
if ($build->finished && $build->iscachedbuild) {
|
||||
|
@ -204,27 +204,6 @@ sub download : Chained('buildChain') PathPart {
|
|||
}
|
||||
my $storePath = $1;
|
||||
|
||||
# Hack to get downloads to work on binary cache stores: if the
|
||||
# store path is not available locally, then import it into the
|
||||
# local store. FIXME: find a better way; this can require an
|
||||
# unbounded amount of space.
|
||||
if (!isValidPath($storePath)) {
|
||||
my $storeMode = $c->config->{store_mode} // "direct";
|
||||
notFound($c, "File " . $product->path . " has disappeared.")
|
||||
if $storeMode eq "direct";
|
||||
my $url =
|
||||
$storeMode eq "local-binary-cache" ? "file://" . $c->config->{binary_cache_dir} :
|
||||
$storeMode eq "s3-binary-cache" ? "https://" . $c->config->{binary_cache_s3_bucket} . ".s3.amazonaws.com/" :
|
||||
die;
|
||||
my $args = "";
|
||||
if (defined $c->config->{binary_cache_public_key_file}
|
||||
&& -r $c->config->{binary_cache_public_key_file})
|
||||
{
|
||||
$args = "--option binary-cache-public-keys " . read_file($c->config->{binary_cache_public_key_file});
|
||||
}
|
||||
system("nix-store --realise '$storePath' --option extra-binary-caches '$url' $args>/dev/null");
|
||||
}
|
||||
|
||||
notFound($c, "File " . $product->path . " does not exist.") unless -e $product->path;
|
||||
|
||||
return $c->res->redirect(defaultUriForProduct($self, $c, $product, @path))
|
||||
|
|
|
@ -258,17 +258,10 @@ sub nar :Local :Args(1) {
|
|||
|
||||
die if $path =~ /\//;
|
||||
|
||||
my $storeMode = $c->config->{store_mode} // "direct";
|
||||
|
||||
if ($storeMode eq "s3-binary-cache") {
|
||||
if (!isLocalStore) {
|
||||
notFound($c, "There is no binary cache here.");
|
||||
}
|
||||
|
||||
elsif ($storeMode eq "local-binary-cache") {
|
||||
my $dir = $c->config->{binary_cache_dir};
|
||||
$c->serve_static_file($dir . "/nar/" . $path);
|
||||
}
|
||||
|
||||
else {
|
||||
$path = $Nix::Config::storeDir . "/$path";
|
||||
|
||||
|
@ -283,17 +276,10 @@ sub nar :Local :Args(1) {
|
|||
sub nix_cache_info :Path('nix-cache-info') :Args(0) {
|
||||
my ($self, $c) = @_;
|
||||
|
||||
my $storeMode = $c->config->{store_mode} // "direct";
|
||||
|
||||
if ($storeMode eq "s3-binary-cache") {
|
||||
if (!isLocalStore) {
|
||||
notFound($c, "There is no binary cache here.");
|
||||
}
|
||||
|
||||
elsif ($storeMode eq "local-binary-cache") {
|
||||
my $dir = $c->config->{binary_cache_dir};
|
||||
$c->serve_static_file($dir . "/nix-cache-info");
|
||||
}
|
||||
|
||||
else {
|
||||
$c->response->content_type('text/plain');
|
||||
$c->stash->{plain}->{data} =
|
||||
|
@ -311,17 +297,10 @@ sub nix_cache_info :Path('nix-cache-info') :Args(0) {
|
|||
sub narinfo :LocalRegex('^([a-z0-9]+).narinfo$') :Args(0) {
|
||||
my ($self, $c) = @_;
|
||||
|
||||
my $storeMode = $c->config->{store_mode} // "direct";
|
||||
|
||||
if ($storeMode eq "s3-binary-cache") {
|
||||
if (!isLocalStore) {
|
||||
notFound($c, "There is no binary cache here.");
|
||||
}
|
||||
|
||||
elsif ($storeMode eq "local-binary-cache") {
|
||||
my $dir = $c->config->{binary_cache_dir};
|
||||
$c->serve_static_file($dir . "/" . $c->req->captures->[0] . ".narinfo");
|
||||
}
|
||||
|
||||
else {
|
||||
my $hash = $c->req->captures->[0];
|
||||
|
||||
|
|
|
@ -347,8 +347,7 @@ sub approxTableSize {
|
|||
|
||||
sub requireLocalStore {
|
||||
my ($c) = @_;
|
||||
notFound($c, "Nix channels are not supported by this Hydra server.")
|
||||
if ($c->config->{store_mode} // "direct") ne "direct";
|
||||
notFound($c, "Nix channels are not supported by this Hydra server.") if !Hydra::Helper::Nix::isLocalStore();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -23,7 +23,10 @@ our @EXPORT = qw(
|
|||
getEvals getMachines
|
||||
pathIsInsidePrefix
|
||||
captureStdoutStderr run grab
|
||||
getTotalShares readNixFile
|
||||
getTotalShares
|
||||
getStoreUri
|
||||
readNixFile
|
||||
isLocalStore
|
||||
cancelBuilds restartBuilds);
|
||||
|
||||
|
||||
|
@ -491,12 +494,22 @@ sub restartBuilds($$) {
|
|||
}
|
||||
|
||||
|
||||
sub getStoreUri {
|
||||
my $config = getHydraConfig();
|
||||
return $config->{'store_uri'} // "auto";
|
||||
}
|
||||
|
||||
|
||||
# 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" });
|
||||
return grab(cmd => ["nix", "cat-store", "--store", getStoreUri(), "$path"]);
|
||||
}
|
||||
|
||||
|
||||
sub isLocalStore {
|
||||
my $uri = getStoreUri();
|
||||
return $uri =~ "^(local|daemon|auto)";
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ package Hydra::View::NixPkg;
|
|||
|
||||
use strict;
|
||||
use base qw/Catalyst::View/;
|
||||
use Hydra::Helper::CatalystUtils;
|
||||
|
||||
sub process {
|
||||
my ($self, $c) = @_;
|
||||
|
@ -10,12 +11,9 @@ sub process {
|
|||
|
||||
my $build = $c->stash->{build};
|
||||
|
||||
my $storeMode = $c->config->{store_mode} // "direct";
|
||||
my $channelUri =
|
||||
$storeMode eq "direct" ? $c->uri_for('/')
|
||||
: $storeMode eq "s3-binary-cache" ?
|
||||
($c->config->{binary_cache_public_uri} // ("https://" . $c->config->{binary_cache_s3_bucket} . ".s3.amazonaws.com/"))
|
||||
: die "Not supported.\n";
|
||||
requireLocalStore($c);
|
||||
|
||||
my $channelUri = $c->uri_for('/');
|
||||
|
||||
# FIXME: add multiple output support
|
||||
my $s = "NIXPKG1 http://invalid.org/"
|
||||
|
|
|
@ -38,7 +38,7 @@ sub keepBuild {
|
|||
$build->get_column('project'), ":", $build->get_column('jobset'), ":", $build->get_column('job'), "; ",
|
||||
$build->system, "; ",
|
||||
strftime("%Y-%m-%d %H:%M:%S", localtime($build->timestamp)), ")\n";
|
||||
if (($config->{store_mode} // "direct") eq "direct" &&
|
||||
if (isLocalStore &&
|
||||
$build->finished && ($build->buildstatus == 0 || $build->buildstatus == 6))
|
||||
{
|
||||
foreach my $path (split / /, $build->get_column('outpaths')) {
|
||||
|
|
Loading…
Reference in a new issue