diff --git a/src/Hydra/lib/Hydra/Base/Controller/Nix.pm b/src/Hydra/lib/Hydra/Base/Controller/Nix.pm index 4e7fd35f..d930b361 100644 --- a/src/Hydra/lib/Hydra/Base/Controller/Nix.pm +++ b/src/Hydra/lib/Hydra/Base/Controller/Nix.pm @@ -39,4 +39,20 @@ sub nar : Chained('nix') PathPart { } +sub pkg : Chained('nix') PathPart Args(1) { + my ($self, $c, $pkgName) = @_; + + my $pkg = $c->stash->{nixPkgs}->{$pkgName}; + + notFound($c, "Unknown Nix package `$pkgName'.") + unless defined $pkg; + + $c->stash->{build} = $pkg; + + $c->stash->{current_view} = 'Hydra::View::NixPkg'; + + $c->response->content_type('application/nix-package'); +} + + 1; diff --git a/src/Hydra/lib/Hydra/Controller/Build.pm b/src/Hydra/lib/Hydra/Controller/Build.pm index a5d21b3f..2cdb9773 100644 --- a/src/Hydra/lib/Hydra/Controller/Build.pm +++ b/src/Hydra/lib/Hydra/Controller/Build.pm @@ -124,6 +124,8 @@ sub nix : Chained('build') PathPart('nix') CaptureArgs(0) { $c->stash->{name} = $build->nixname; $c->stash->{storePaths} = [$build->outpath]; + my $pkgName = $build->nixname . "-" . $build->system . ".nixpkg"; + $c->stash->{nixPkgs} = {$pkgName => $build}; } diff --git a/src/Hydra/lib/Hydra/Controller/Root.pm b/src/Hydra/lib/Hydra/Controller/Root.pm index f8fea216..5f6c46ac 100644 --- a/src/Hydra/lib/Hydra/Controller/Root.pm +++ b/src/Hydra/lib/Hydra/Controller/Root.pm @@ -544,24 +544,6 @@ sub default :Path { } -sub nixpkg :Local { - my ($self, $c, $buildId) = @_; - - my $build = getBuild($c, $buildId); - notFound($c, "Build $buildId doesn't exist.") if !defined $build; - - error($c, "Build $buildId cannot be downloaded as a Nix package.") - if !$build->buildproducts->find({type => "nix-build"}); - - error($c, "Path " . $build->outpath . " is no longer available.") unless isValidPath($build->outpath); - - $c->stash->{current_view} = 'Hydra::View::NixPkg'; - $c->stash->{build} = $build; - - $c->response->content_type('application/nix-package'); -} - - sub end : ActionClass('RenderView') { my ($self, $c) = @_; diff --git a/src/Hydra/root/product-list.tt b/src/Hydra/root/product-list.tt index eda24140..e8962bf8 100644 --- a/src/Hydra/root/product-list.tt +++ b/src/Hydra/root/product-list.tt @@ -13,7 +13,7 @@ [% CASE "nix-build" %]