* Generate NAR archives on the fly. Necessary for producing channels

/ one-click installs on demand.
This commit is contained in:
Eelco Dolstra 2009-02-19 23:43:08 +00:00
parent 5a49cc5916
commit 9013e97534
4 changed files with 42 additions and 5 deletions

View file

@ -712,12 +712,25 @@ 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';
$c->stash->{storePath} = $build->outpath;
}
sub nar :Local {
my ($self, $c, @rest) = @_;
my $path .= "/" . join("/", @rest);
return error($c, "Path " . $path . " is no longer available.") unless isValidPath($path);
$c->stash->{current_view} = 'Hydra::View::NixNAR';
$c->stash->{storePath} = $path;
}
sub end : ActionClass('RenderView') {}

View file

@ -3,7 +3,6 @@ package Hydra::View::NixClosure;
use strict;
use base qw/Catalyst::View/;
use IO::Pipe;
use POSIX qw(dup2);
sub process {
my ( $self, $c ) = @_;

View file

@ -41,10 +41,10 @@ sub process {
$manifest .=
"{\n" .
" StorePath: $path\n" .
" StorePath: ${path}y\n" .
" NarURL: $url\n" .
" References: @refs\n" .
" Hash: $hash\n" .
" NarHash: $hash\n" .
"}\n";
}

View file

@ -0,0 +1,25 @@
package Hydra::View::NixNAR;
use strict;
use base qw/Catalyst::View/;
sub process {
my ($self, $c) = @_;
my $storePath = $c->stash->{storePath};
$c->response->content_type('application/x-nix-archive'); # !!! check MIME type
open(OUTPUT, "nix-store --dump '$storePath' | bzip2 |");
my $fh = new IO::Handle;
$fh->fdopen(fileno(OUTPUT), "r") or die;
$c->response->body($fh);
undef $fh;
return 1;
}
1;