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QOJVLHP5LZ6BXDKGNE7IKUJHB5XKH244ZAC
L5VIEXSC5R72SEDSWF7HWNXMSTAAADBUMCSREU5ITMRXLEJ6KZWQC
IK53RV4VGOHLCZGQCCIKPB45M3C7M7YMNBOJFBGZJ4LWIZNU4QNQC
UHANDRARA2OOOIKBFWPL5ICQH3ECDMWCPVKZXCXXR7E7PJN5SVYQC
2GK5DOU7ODF4WBSN3QTD3WIO52VTL2LOAXKGCDEMMAQPTEO4A4HAC
AFTXA575C6JTVLVXTYJUKQGPLBO3NFORLO5XDSPHNL44HXLRH4TAC
MOCEUXZAS4CNZL2QDKGVTZCRZ6AMOO2WSFHJ4VPZPPPAXHANG4NAC
IWVA2P2Y2RMX3F6AQNJ5JMK6VTAAC2YCQT25GYN5TTEXUWCBDY2QC
BA46C5LNEQ57N52IJTCEXW4J74F33KKNYHYXE6ZJLQ5ARMCJPUHAC
Y35C6GHH45ZUEZHHYZU4BQK3GOPJENOY2DZM3TMVUA6AMSPT2I7AC
NYC3LZKHWRIP2VJDCO3UVPR6TR7JURVX5NBS4H2AOOOG3ZG5G6FAC
package Hydra::Base::Controller::Nix;
use strict;
use warnings;
use parent 'Catalyst::Controller';
use Hydra::Helper::Nix;
use Hydra::Helper::CatalystUtils;
sub closure : Chained('nix') PathPart {
my ($self, $c) = @_;
$c->stash->{current_view} = 'Hydra::View::NixClosure';
# !!! quick hack; this is to make HEAD requests return the right
# MIME type. This is set in the view as well, but the view isn't
# called for HEAD requests. There should be a cleaner solution...
$c->response->content_type('application/x-nix-export');
}
sub manifest : Chained('nix') PathPart Args(0) {
my ($self, $c) = @_;
$c->stash->{current_view} = 'Hydra::View::NixManifest';
}
1;
}
sub nix : Chained('build') PathPart('nix') CaptureArgs(0) {
my ($self, $c) = @_;
my $build = $c->stash->{build};
error($c, "Build cannot be downloaded as a closure or Nix package.")
if !$build->buildproducts->find({type => "nix-build"});
error($c, "Path " . $build->outpath . " is no longer available.")
unless isValidPath($build->outpath);
$c->stash->{name} = $build->nixname;
$c->stash->{storePaths} = [$build->outpath];
eval {
my $releaseSetName = $c->request->params->{name};
$c->model('DB')->schema->txn_do(sub {
# Note: $releaseSetName is validated in updateProject,
# which will abort the transaction if the name isn't
# valid.
my $releaseSet = $project->releasesets->create({name => $releaseSetName});
updateReleaseSet($c, $releaseSet);
return $c->res->redirect($c->uri_for("/releases", $projectName, $releaseSet->name));
});
};
if ($@) {
return error($c, $@);
}
my $releaseSetName = $c->request->params->{name};
$c->model('DB')->schema->txn_do(sub {
# Note: $releaseSetName is validated in updateProject,
# which will abort the transaction if the name isn't
# valid.
my $releaseSet = $project->releasesets->create({name => $releaseSetName});
updateReleaseSet($c, $releaseSet);
return $c->res->redirect($c->uri_for("/releases", $projectName, $releaseSet->name));
});
eval {
my $projectName = trim $c->request->params->{name};
$c->model('DB')->schema->txn_do(sub {
# Note: $projectName is validated in updateProject,
# which will abort the transaction if the name isn't
# valid. Idem for the owner.
my $project = $c->model('DB::Projects')->create(
{name => $projectName, displayname => "", owner => trim $c->request->params->{owner}});
updateProject($c, $project);
});
return $c->res->redirect($c->uri_for("/project", $projectName));
};
if ($@) {
return error($c, $@);
}
my $projectName = trim $c->request->params->{name};
$c->model('DB')->schema->txn_do(sub {
# Note: $projectName is validated in updateProject,
# which will abort the transaction if the name isn't
# valid. Idem for the owner.
my $project = $c->model('DB::Projects')->create(
{name => $projectName, displayname => "", owner => trim $c->request->params->{owner}});
updateProject($c, $project);
});
return $c->res->redirect($c->uri_for("/project", $projectName));
return error($c, "Build $buildId cannot be downloaded as a closure.")
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::NixClosure';
$c->stash->{storePath} = $build->outpath;
$c->stash->{name} = $build->nixname;
# !!! quick hack; this is to make HEAD requests return the right
# MIME type. This is set in the view as well, but the view isn't
# called for HEAD requests. There should be a cleaner solution...
$c->response->content_type('application/x-nix-export');
$c->response->header('Content-Disposition' => 'attachment; filename=' . $c->stash->{name} . '.closure.gz');
}
sub manifest :Local {
my ($self, $c, $buildId) = @_;
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;
}
my @paths = split '\n', `nix-store --query --requisites $storePath`
or die "cannot query dependencies of `$storePath': $?";
my @paths = split '\n', `nix-store --query --requisites @storePaths`
or die "cannot query dependencies of path(s) @storePaths: $?";