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 @@
If you have Nix installed on your machine, this build and all - its dependencies can be unpacked into your local Nix store by - doing:
+If you have Nix installed on your machine, you can + install this package and all its dependencies automatically + by clicking on the link above. This requires that you have + the application/nix-package MIME type associated + with the nix-install-package program in your web + browser. Alternatively, you can install it from the + command-line: + +
$ nix-install-package --non-interactive --url [% c.uri_for('/nixpkg' build.id) %]+ + -
$ gunzip < [% HTML.escape(build.nixname) %].closure.gz | nix-store --import+
If you get an error message “Permission denied”, you + should make sure that you have sufficient access rights to + the Nix store, e.g., run the command as root. + +
+If you have Nix installed on your machine, this build and + all its dependencies can be unpacked into your local Nix + store by doing:
+ +$ gunzip < [% HTML.escape(build.nixname) %].closure.gz | nix-store --importor to download and unpack in one command: @@ -36,9 +68,15 @@ archive lacks a signature”, you should make sure that you have sufficient access rights to the Nix store, e.g., run the command as root. + -->