@@ -10,13 +10,18 @@ KEYNAME=na
1010export NIX_REMOTE=daemon
1111
1212config="${NIX_BINARY_CACHE_CONFIG:-${HTTP_NIX_BINARY_CACHE_CONFIG:-/etc/nix/nix-binary-cache.cgi.conf}}"
13−config="$(cd "$(@coreutils@/dirname "$config")";
13+config="$(cd "$(@coreutils@/dirname "$config")";
1414 @coreutils@/pwd)/$(@coreutils@/basename "$config")"
1515@coreutils@/test -e "$config" && . "$config"
1616
1717header(){
1818 echo "Content-Type: text/plain; charset=utf-8"
19− echo
19+ echo
20+}
21+
22+header404(){
23+ echo "Status: 404 Not Found"
24+ echo
2025}
2126
2227clean_path() {
@@ -28,12 +33,12 @@ storeq(){
2833}
2934
3035sign(){
31− test -n "$1" &&
32− @coreutils@/sha256sum | @gnused@/sed -e 's/ .*//' |
36+ test -n "$1" &&
37+ @coreutils@/sha256sum | @gnused@/sed -e 's/ .*//' |
3338 @openssl@/openssl rsautl -sign -inkey "$@" | @coreutils@/base64 -w 0
3439}
3540
36−case "$QUERY_STRING" in
41+case "$QUERY_STRING" in
3742 "")
3843 header
3944 echo "Hello, this is a dynamically-generated Nix binary cache"
@@ -61,9 +66,9 @@ case "$QUERY_STRING" in
6166 echo "Compression: $COMPRESSION"
6267 echo "NarHash: $(storeq --hash "$path")"
6368 echo "NarSize: $(storeq --size "$path")"
64− echo "References: $(storeq --references "$path" |
69+ echo "References: $(storeq --references "$path" |
6570 @coreutils@/tac | clean_path )"
66− echo "Deriver: $(storeq --deriver "$path" |
71+ echo "Deriver: $(storeq --deriver "$path" |
6772 clean_path )"
6873 )"
6974 signature="$(echo "$info" | sign "$KEY")"
@@ -72,6 +77,7 @@ case "$QUERY_STRING" in
7277 echo "Signature: 1;$KEYNAME;$signature"
7378
7479 else
80+ header404
7581 exit 1
7682 fi
7783 ;;
@@ -81,6 +87,7 @@ case "$QUERY_STRING" in
8187 header
8288 @nix@/nix-store --dump "$path" | @xz@/xz
8389 else
90+ header404
8491 exit 1
8592 fi
8693 ;;
@@ -91,6 +98,7 @@ case "$QUERY_STRING" in
9198 header
9299 @nix@/nix-store --dump "$path" | @bzip2@/bzip2
93100 else
101+ header404
94102 exit 1
95103 fi
96104 ;;