This makes downloading/viewing build results work with binary cache stores. For good performance, this should be used in conjunction with https://github.com/NixOS/nix/commit/ca580bec35ea4d1984e36864158d7be99cfcb34b, i.e. you should set store_uri to something like
s3://my-cache?local-nar-cache=/tmp/nar-cache
to cache NARs between requests.
2V4M2M2RZ5R6I55UIFKRMONPEGBA5FQ7ZB6HM6LHF255AX4JCXXAC
V2YFPM72UMEDEZVWBQT42KSVDALD5PPJXTBZALKH26SR5PKGC42AC
MAOFG2TDQZUK62BT7W3JYAIOSEAKDZJOYAMLGXBJAUHABJHQQMHQC
LBNVQXUBEZ45SOTGVXK5UEZXIAIZTJLWZNUYFI4JZ6J65N3KPDVQC
3TZGWQHOP4PQ5YSHETBXAHVQP5QNSPG7QREZCGQ4GF55DZSSHKZAC
5NO7NCKTMM5ZW7JYOETUFOSWK2ACTXWDZGJAFXZN6L3OF6BFTNOQC
7UHHF564BOGHA2CP4OZA3BEPUUTY5S3SS53A32F7RHEVSIDEVWRAC
6ZB4CIW66KZMCEBTUWTRRNKQAV5WVPYX4QLFAJT5TTJ3CMS4JMXQC
GJFYEU3SVP7TDSYXVZEYGKN4NVWSZX4754PPPTOYPRHUO5RMDWPQC
D3DIBMOKXK2E65267BEEWQL4S4NSHGZBCY7YTU34JSEPZ7AKNBRQC
R6B5CAFF3BWJPW6I5YGKXOKKCW6S7D7AHO2HLZVFUW3NL77ZW44QC
XJFHFZCA2VXGYSRDJDLAZZX3MLRH2KDT242DHWRU5XQRJ6XIHZUQC
# If this is a directory but no "/" is attached, then redirect.
if (-d $path && substr($c->request->uri, -1) ne "/") {
return $c->res->redirect($c->request->uri . "/");
}
notFound($c, "File " . $product->path . " does not exist.") unless -e $product->path;
notFound($c, "Path $path is a directory.") if -d $path;
$path = "$path/index.html" if -d $path && -e "$path/index.html";
notFound($c, "File $path does not exist.") if !-e $path;
notFound($c, "Path $path is a directory.") if -d $path;
$c->serve_static_file($path);
$c->response->headers->last_modified($c->stash->{build}->stoptime);
$c->serve_static_file($path);
$c->response->headers->last_modified($c->stash->{build}->stoptime);
} else {
$c->stash->{'plain'} = { data => readNixFile($path) };
$c->response->content_type('application/octet-stream');
$c->forward('Hydra::View::Plain');
}