3 STORE_DIR="${NIX_STORE_DIR:-/nix/store}"
10 export NIX_REMOTE=daemon
12 config="${NIX_BINARY_CACHE_CONFIG:-${HTTP_NIX_BINARY_CACHE_CONFIG:-/etc/nix/nix-binary-cache.cgi.conf}}"
13 config="$(cd "$(@coreutils@/dirname "$config")";
14 @coreutils@/pwd)/$(@coreutils@/basename "$config")"
15 @coreutils@/test -e "$config" && . "$config"
18 echo "Content-Type: text/plain; charset=utf-8"
23 echo "Status: 404 Not Found"
28 @gnused@/sed -re "s@^$STORE_DIR/?@@" | @findutils@/xargs
32 @nix@/nix-store -q "$@"
37 @coreutils@/sha256sum | @gnused@/sed -e 's/ .*//' |
38 @openssl@/openssl rsautl -sign -inkey "$@" | @coreutils@/base64 -w 0
41 case "$QUERY_STRING" in
44 echo "Hello, this is a dynamically-generated Nix binary cache"
52 echo "StoreDir: $STORE_DIR"
53 echo "WantMassQuery: $MASS_QUERY"
54 echo "Priority: $PRIORITY"
57 hash=${QUERY_STRING%.narinfo}
59 path="$(echo "$STORE_DIR/$hash-"* | @coreutils@/sort | @coreutils@/head -n 1)"
60 if [ -n "$path" ] && [ -e "$path" ]; then
63 echo "StorePath: $path"
64 echo "URL: $(@coreutils@/basename "$path"
66 echo "Compression: $COMPRESSION"
67 echo "NarHash: $(storeq --hash "$path")"
68 echo "NarSize: $(storeq --size "$path")"
69 echo "References: $(storeq --references "$path" |
70 @coreutils@/tac | clean_path )"
71 echo "Deriver: $(storeq --deriver "$path" |
74 signature="$(echo "$info" | sign "$KEY")"
77 echo "Signature: 1;$KEYNAME;$signature"
85 path="$STORE_DIR${QUERY_STRING%.nar.xz}"
86 if [ -n "$path" ] && [ -e "$path" ]; then
88 @nix@/nix-store --dump "$path" | @xz@/xz
95 path="$STORE_DIR${QUERY_STRING%.nar.bzip2}"
97 if [ -n "$path" ] && [ -e "$path" ]; then
99 @nix@/nix-store --dump "$path" | @bzip2@/bzip2