hydra/src/lib/Hydra/View/NixClosure.pm
Eelco Dolstra 8b752627a2 * Use IO::Handles instead of old school filehandles. This ensures
that the pipe gets closed, and the child process dies, if the HTTP
  connection is prematurely interrupted.
2009-03-11 14:44:34 +00:00

24 lines
407 B
Perl

package Hydra::View::NixClosure;
use strict;
use base qw/Catalyst::View/;
use IO::Pipe;
sub process {
my ($self, $c) = @_;
$c->response->content_type('application/x-nix-export');
my @storePaths = @{$c->stash->{storePaths}};
my $fh = new IO::Handle;
open $fh, "nix-store --export `nix-store -qR @storePaths` | gzip |";
$c->response->body($fh);
return 1;
}
1;