Make one-click installs work for binary cache stores

This requires setting binary_cache_public_uri in hydra.conf.
This commit is contained in:
Eelco Dolstra 2017-10-18 14:09:28 +02:00
parent 44ef743d84
commit 62c6cca937
No known key found for this signature in database
GPG key ID: 8170B4726D7198DE
3 changed files with 8 additions and 10 deletions

View file

@ -3,7 +3,7 @@ package Hydra::Base::Controller::NixChannel;
use strict;
use warnings;
use base 'Hydra::Base::Controller::REST';
use List::MoreUtils qw(all);
use List::MoreUtils qw(any);
use Nix::Store;
use Hydra::Helper::Nix;
use Hydra::Helper::CatalystUtils;
@ -90,10 +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;
if isLocalStore() && any { !isValidPath($_->path) } $c->stash->{build}->buildoutputs->all;
$c->stash->{current_view} = 'NixPkg';

View file

@ -432,9 +432,11 @@ sub nix : Chained('buildChain') PathPart('nix') CaptureArgs(0) {
notFound($c, "Build cannot be downloaded as a closure or Nix package.")
if $build->buildproducts->search({type => "nix-build"})->count == 0;
foreach my $out ($build->buildoutputs) {
notFound($c, "Path " . $out->path . " is no longer available.")
unless isValidPath($out->path);
if (isLocalStore) {
foreach my $out ($build->buildoutputs) {
notFound($c, "Path " . $out->path . " is no longer available.")
unless isValidPath($out->path);
}
}
$c->stash->{channelBuilds} = $c->model('DB::Builds')->search(

View file

@ -11,9 +11,7 @@ sub process {
my $build = $c->stash->{build};
requireLocalStore($c);
my $channelUri = $c->uri_for('/');
my $channelUri = $c->config->{binary_cache_public_uri} // $c->uri_for('/');
# FIXME: add multiple output support
my $s = "NIXPKG1 http://invalid.org/"