* Generate NAR archives on the fly. Necessary for producing channels
/ one-click installs on demand.
This commit is contained in:
parent
5a49cc5916
commit
9013e97534
|
@ -712,12 +712,25 @@ 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);
|
||||||
|
|
||||||
$c->stash->{current_view} = 'Hydra::View::NixManifest';
|
$c->stash->{current_view} = 'Hydra::View::NixManifest';
|
||||||
$c->stash->{storePath} = $build->outpath;
|
$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') {}
|
sub end : ActionClass('RenderView') {}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@ package Hydra::View::NixClosure;
|
||||||
use strict;
|
use strict;
|
||||||
use base qw/Catalyst::View/;
|
use base qw/Catalyst::View/;
|
||||||
use IO::Pipe;
|
use IO::Pipe;
|
||||||
use POSIX qw(dup2);
|
|
||||||
|
|
||||||
sub process {
|
sub process {
|
||||||
my ( $self, $c ) = @_;
|
my ( $self, $c ) = @_;
|
||||||
|
|
|
@ -12,7 +12,7 @@ sub captureStdoutStderr {
|
||||||
return ($res, $stdout, $stderr);
|
return ($res, $stdout, $stderr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
sub process {
|
sub process {
|
||||||
my ($self, $c) = @_;
|
my ($self, $c) = @_;
|
||||||
|
|
||||||
|
@ -41,10 +41,10 @@ sub process {
|
||||||
|
|
||||||
$manifest .=
|
$manifest .=
|
||||||
"{\n" .
|
"{\n" .
|
||||||
" StorePath: $path\n" .
|
" StorePath: ${path}y\n" .
|
||||||
" NarURL: $url\n" .
|
" NarURL: $url\n" .
|
||||||
" References: @refs\n" .
|
" References: @refs\n" .
|
||||||
" Hash: $hash\n" .
|
" NarHash: $hash\n" .
|
||||||
"}\n";
|
"}\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
25
src/Hydra/lib/Hydra/View/NixNAR.pm
Normal file
25
src/Hydra/lib/Hydra/View/NixNAR.pm
Normal 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;
|
Loading…
Reference in a new issue