diff --git a/src/Hydra/lib/Hydra/Controller/Root.pm b/src/Hydra/lib/Hydra/Controller/Root.pm index 72673564..cf54bcae 100644 --- a/src/Hydra/lib/Hydra/Controller/Root.pm +++ b/src/Hydra/lib/Hydra/Controller/Root.pm @@ -710,6 +710,7 @@ sub manifest :Local { my $build = getBuild($c, $buildId); return error($c, "Build with ID $buildId doesn't exist.") if !defined $build; + return error($c, "Path " . $build->outpath . " is no longer available.") unless isValidPath($build->outpath); $c->stash->{current_view} = 'Hydra::View::NixManifest'; @@ -717,6 +718,24 @@ sub manifest :Local { } +sub nixpkg :Local { + my ($self, $c, $buildId) = @_; + + my $build = getBuild($c, $buildId); + return error($c, "Build $buildId doesn't exist.") if !defined $build; + + return error($c, "Build $buildId cannot be downloaded as a Nix package.") + if !$build->buildproducts->find({type => "nix-build"}); + + return error($c, "Path " . $build->outpath . " is no longer available.") unless isValidPath($build->outpath); + + $c->stash->{current_view} = 'Hydra::View::NixPkg'; + $c->stash->{build} = $build; + + $c->response->content_type('application/nix-package'); +} + + sub nar :Local { my ($self, $c, @rest) = @_; diff --git a/src/Hydra/lib/Hydra/View/NixManifest.pm b/src/Hydra/lib/Hydra/View/NixManifest.pm index 6796470f..2d9b555a 100644 --- a/src/Hydra/lib/Hydra/View/NixManifest.pm +++ b/src/Hydra/lib/Hydra/View/NixManifest.pm @@ -38,12 +38,17 @@ sub process { chomp $hash; my $url = $c->uri_for('/nar' . $path); + + my $deriver = `nix-store --query --deriver $path` + or die "cannot query deriver of `$path': $?"; + chomp $deriver; $manifest .= "{\n" . - " StorePath: ${path}y\n" . + " StorePath: $path\n" . + (scalar @refs > 0 ? " References: @refs\n" : "") . + ($deriver ne "unknown-deriver" ? " Deriver: $deriver\n" : "") . " NarURL: $url\n" . - " References: @refs\n" . " NarHash: $hash\n" . "}\n"; } diff --git a/src/Hydra/root/product-list.tt b/src/Hydra/root/product-list.tt index f86ea0fe..780eeb57 100644 --- a/src/Hydra/root/product-list.tt +++ b/src/Hydra/root/product-list.tt @@ -5,21 +5,53 @@