* One-click installs.

This commit is contained in:
Eelco Dolstra 2009-02-23 13:23:55 +00:00
parent 5f8dcab854
commit 5fcd2e26c9
3 changed files with 81 additions and 11 deletions

View file

@ -710,6 +710,7 @@ sub manifest :Local {
my $build = getBuild($c, $buildId); my $build = getBuild($c, $buildId);
return error($c, "Build with ID $buildId doesn't exist.") if !defined $build; 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); return error($c, "Path " . $build->outpath . " is no longer available.") unless isValidPath($build->outpath);
$c->stash->{current_view} = 'Hydra::View::NixManifest'; $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 { sub nar :Local {
my ($self, $c, @rest) = @_; my ($self, $c, @rest) = @_;

View file

@ -38,12 +38,17 @@ sub process {
chomp $hash; chomp $hash;
my $url = $c->uri_for('/nar' . $path); my $url = $c->uri_for('/nar' . $path);
my $deriver = `nix-store --query --deriver $path`
or die "cannot query deriver of `$path': $?";
chomp $deriver;
$manifest .= $manifest .=
"{\n" . "{\n" .
" StorePath: ${path}y\n" . " StorePath: $path\n" .
(scalar @refs > 0 ? " References: @refs\n" : "") .
($deriver ne "unknown-deriver" ? " Deriver: $deriver\n" : "") .
" NarURL: $url\n" . " NarURL: $url\n" .
" References: @refs\n" .
" NarHash: $hash\n" . " NarHash: $hash\n" .
"}\n"; "}\n";
} }

View file

@ -5,21 +5,53 @@
<ul class="productList"> <ul class="productList">
[% FOREACH product IN build.buildproducts -%] [% FOREACH product IN build.buildproducts -%]
<li class="product">
[% SWITCH product.type %] [% SWITCH product.type %]
[% CASE "nix-build" %] [% CASE "nix-build" %]
<a href="[% c.uri_for('/closure' build.id) %]">
<li class="product">
<a href="[% c.uri_for('/nixpkg' build.id) %]">
<img src="/static/images/nix-build.png" alt="Source" /> <img src="/static/images/nix-build.png" alt="Source" />
Nix build of path <tt>[% product.path %]</tt> One-click install of Nix package <tt>[% build.nixname %]</tt>
</a> </a>
[<a class="productDetailsToggle" href="javascript:">help</a>] [<a class="productDetailsToggle" href="javascript:">help</a>]
<div class="help productDetails"> <div class="help productDetails">
<p>If you have Nix installed on your machine, this build and all <p>If you have Nix installed on your machine, you can
its dependencies can be unpacked into your local Nix store by install this package and all its dependencies automatically
doing:</p> by clicking on the link above. This requires that you have
the <tt>application/nix-package</tt> MIME type associated
with the <tt>nix-install-package</tt> program in your web
browser. Alternatively, you can install it from the
command-line:
<pre>$ nix-install-package --non-interactive --url [% c.uri_for('/nixpkg' build.id) %]</pre>
</p>
<pre>$ gunzip < [% HTML.escape(build.nixname) %].closure.gz | nix-store --import</pre> <p>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 <tt>root</tt>.
</p>
</div>
</li>
<li class="product">
<a href="[% c.uri_for('/closure' build.id) %]">
<img src="/static/images/nix-build.png" alt="Source" />
Nix closure of path <tt>[% product.path %]</tt>
</a>
[<a class="productDetailsToggle" href="javascript:">help</a>]
<div class="help productDetails">
<p>If you have Nix installed on your machine, this build and
all its dependencies can be unpacked into your local Nix
store by doing:</p>
<pre>$ gunzip &lt; [% HTML.escape(build.nixname) %].closure.gz | nix-store --import</pre>
or to download and unpack in one command: or to download and unpack in one command:
@ -36,9 +68,15 @@
archive lacks a signature”, you should make sure that you have archive lacks a signature”, you should make sure that you have
sufficient access rights to the Nix store, e.g., run the sufficient access rights to the Nix store, e.g., run the
command as <tt>root</tt>.</p> command as <tt>root</tt>.</p>
-->
</div> </div>
</li>
[% CASE "file" %] [% CASE "file" %]
<li class="product">
<a href="[% c.uri_for('/download' build.id product.productnr product.name) %]"> <a href="[% c.uri_for('/download' build.id product.productnr product.name) %]">
[% SWITCH product.subtype %] [% SWITCH product.subtype %]
[% CASE "source-dist" %] [% CASE "source-dist" %]
@ -70,9 +108,11 @@
<tr><th>Full path:</th><td><tt>[% product.path %]</tt></td></tr> <tr><th>Full path:</th><td><tt>[% product.path %]</tt></td></tr>
</table> </table>
</div> </div>
</li>
[% CASE "report" %] [% CASE "report" %]
<li class="product">
<a href="[% c.uri_for('/download' build.id product.productnr product.name) %]"> <a href="[% c.uri_for('/download' build.id product.productnr product.name) %]">
<img src="/static/images/report.png" alt="Report" /> <img src="/static/images/report.png" alt="Report" />
[% SWITCH product.subtype %] [% SWITCH product.subtype %]
@ -82,9 +122,11 @@
Report of type <tt>[% product.subtype %]</tt> Report of type <tt>[% product.subtype %]</tt>
[% END %] [% END %]
</a> </a>
</li>
[% CASE "doc" %] [% CASE "doc" %]
<li class="product">
<a href="[% c.uri_for('/download' build.id product.productnr product.name) %]"> <a href="[% c.uri_for('/download' build.id product.productnr product.name) %]">
<img src="/static/images/document.png" alt="Document" /> <img src="/static/images/document.png" alt="Document" />
[% SWITCH product.subtype %] [% SWITCH product.subtype %]
@ -98,12 +140,16 @@
Documentation of type <tt>[% product.subtype %]</tt> Documentation of type <tt>[% product.subtype %]</tt>
[% END %] [% END %]
</a> </a>
</li>
[% CASE DEFAULT %] [% CASE DEFAULT %]
<li class="product">
Something of type <tt>[% product.type %]</tt> Something of type <tt>[% product.type %]</tt>
</li>
[% END %] [% END %]
</li>
[% END -%] [% END -%]
</ul> </ul>