diff --git a/src/lib/Hydra/Base/Controller/NixChannel.pm b/src/lib/Hydra/Base/Controller/NixChannel.pm index 77d154f0..1d28735a 100644 --- a/src/lib/Hydra/Base/Controller/NixChannel.pm +++ b/src/lib/Hydra/Base/Controller/NixChannel.pm @@ -9,7 +9,7 @@ use Hydra::Helper::CatalystUtils; sub closure : Chained('nix') PathPart { my ($self, $c) = @_; - $c->stash->{current_view} = 'Hydra::View::NixClosure'; + $c->stash->{current_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 @@ -20,25 +20,8 @@ sub closure : Chained('nix') PathPart { sub manifest : Chained('nix') PathPart("MANIFEST") Args(0) { my ($self, $c) = @_; - $c->stash->{current_view} = 'Hydra::View::NixManifest'; - $c->stash->{narBase} = $c->uri_for($self->action_for("nar"), $c->req->captures); -} - - -sub nar : Chained('nix') PathPart { - my ($self, $c, @rest) = @_; - - my $path .= "/" . join("/", @rest); - - if (!isValidPath($path)) { - $c->response->status(410); # "Gone" - error($c, "Path " . $path . " is no longer available."); - } - - # !!! check that $path is in the closure of $c->stash->{storePaths}. - - $c->stash->{current_view} = 'Hydra::View::NixNAR'; - $c->stash->{storePath} = $path; + $c->stash->{current_view} = 'NixManifest'; + $c->stash->{narBase} = $c->uri_for($c->controller('Root')->action_for("nar")); } @@ -54,7 +37,7 @@ sub pkg : Chained('nix') PathPart Args(1) { $c->stash->{manifestUri} = $c->uri_for($self->action_for("manifest"), $c->req->captures); - $c->stash->{current_view} = 'Hydra::View::NixPkg'; + $c->stash->{current_view} = 'NixPkg'; $c->response->content_type('application/nix-package'); } @@ -62,7 +45,7 @@ sub pkg : Chained('nix') PathPart Args(1) { sub nixexprs : Chained('nix') PathPart('nixexprs.tar.bz2') Args(0) { my ($self, $c) = @_; - $c->stash->{current_view} = 'Hydra::View::NixExprs'; + $c->stash->{current_view} = 'NixExprs'; } diff --git a/src/lib/Hydra/Controller/Build.pm b/src/lib/Hydra/Controller/Build.pm index 26310011..a08c7a28 100644 --- a/src/lib/Hydra/Controller/Build.pm +++ b/src/lib/Hydra/Controller/Build.pm @@ -266,7 +266,7 @@ sub runtimedeps : Chained('build') PathPart('runtime-deps') { notFound($c, "Path " . $build->outpath . " is no longer available.") unless isValidPath($build->outpath); - $c->stash->{current_view} = 'Hydra::View::NixDepGraph'; + $c->stash->{current_view} = 'NixDepGraph'; $c->stash->{storePaths} = [$build->outpath]; $c->res->content_type('image/png'); # !!! @@ -281,7 +281,7 @@ sub buildtimedeps : Chained('build') PathPart('buildtime-deps') { notFound($c, "Path " . $build->drvpath . " is no longer available.") unless isValidPath($build->drvpath); - $c->stash->{current_view} = 'Hydra::View::NixDepGraph'; + $c->stash->{current_view} = 'NixDepGraph'; $c->stash->{storePaths} = [$build->drvpath]; $c->res->content_type('image/png'); # !!! diff --git a/src/lib/Hydra/Controller/Root.pm b/src/lib/Hydra/Controller/Root.pm index b031da21..b67b228e 100644 --- a/src/lib/Hydra/Controller/Root.pm +++ b/src/lib/Hydra/Controller/Root.pm @@ -158,4 +158,19 @@ sub end : ActionClass('RenderView') { } +sub nar :Local :Args(1) { + my ($self, $c, $path) = @_; + + $path = "/nix/store/$path"; + + if (!isValidPath($path)) { + $c->response->status(410); # "Gone" + error($c, "Path " . $path . " is no longer available."); + } + + $c->stash->{current_view} = 'NixNAR'; + $c->stash->{storePath} = $path; +} + + 1; diff --git a/src/lib/Hydra/View/NixManifest.pm b/src/lib/Hydra/View/NixManifest.pm index b14ee36f..927cc548 100644 --- a/src/lib/Hydra/View/NixManifest.pm +++ b/src/lib/Hydra/View/NixManifest.pm @@ -26,11 +26,12 @@ sub process { # Escape the characters that are allowed to appear in a Nix # path name but have special meaning in a URI. my $escaped = $path; + $escaped =~ s/^.*\///; # remove /nix/store/ $escaped =~ s/\+/%2b/g; $escaped =~ s/\=/%3d/g; $escaped =~ s/\?/%3f/g; - my $url = $c->stash->{narBase} . $escaped; + my $url = $c->stash->{narBase} . "/" . $escaped; $manifest .= "{\n" .