* 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);
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) = @_;

View file

@ -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";
}

View file

@ -5,21 +5,53 @@
<ul class="productList">
[% FOREACH product IN build.buildproducts -%]
<li class="product">
[% SWITCH product.type %]
[% 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" />
Nix build of path <tt>[% product.path %]</tt>
One-click install of Nix package <tt>[% build.nixname %]</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>
<p>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 <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:
@ -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 <tt>root</tt>.</p>
-->
</div>
</li>
[% CASE "file" %]
<li class="product">
<a href="[% c.uri_for('/download' build.id product.productnr product.name) %]">
[% SWITCH product.subtype %]
[% CASE "source-dist" %]
@ -70,9 +108,11 @@
<tr><th>Full path:</th><td><tt>[% product.path %]</tt></td></tr>
</table>
</div>
</li>
[% CASE "report" %]
<li class="product">
<a href="[% c.uri_for('/download' build.id product.productnr product.name) %]">
<img src="/static/images/report.png" alt="Report" />
[% SWITCH product.subtype %]
@ -82,9 +122,11 @@
Report of type <tt>[% product.subtype %]</tt>
[% END %]
</a>
</li>
[% CASE "doc" %]
<li class="product">
<a href="[% c.uri_for('/download' build.id product.productnr product.name) %]">
<img src="/static/images/document.png" alt="Document" />
[% SWITCH product.subtype %]
@ -98,12 +140,16 @@
Documentation of type <tt>[% product.subtype %]</tt>
[% END %]
</a>
</li>
[% CASE DEFAULT %]
<li class="product">
Something of type <tt>[% product.type %]</tt>
</li>
[% END %]
</li>
[% END -%]
</ul>