hydra/src/lib/Hydra/View/NixNAR.pm

28 lines
592 B
Perl
Raw Normal View History

package Hydra::View::NixNAR;
use strict;
use base qw/Catalyst::View/;
use Hydra::Helper::CatalystUtils;
sub process {
my ($self, $c) = @_;
my $storePath = $c->stash->{storePath};
my $numThreads = $c->config->{'compress_num_threads'};
my $pParam = ($numThreads > 0) ? "-p$numThreads" : "";
2013-01-22 14:41:02 +01:00
$c->response->content_type('application/x-nix-archive'); # !!! check MIME type
my $fh = new IO::Handle;
2013-01-22 14:41:02 +01:00
open $fh, "nix-store --dump '$storePath' | pixz -0 $pParam |";
setCacheHeaders($c, 365 * 24 * 60 * 60);
$c->response->body($fh);
return 1;
}
1;