4 while @coreutils@/test -n "$1" && @coreutils@/test "x$1" != x-- ; do
18 echo "COMPRESSION=$1";
24 echo "KEYNAME=${1%%:*}"
44 echo "USE_IPV6=enable"
48 "$0": start the Nix binary cache serving the Nix store dynamically.
53 --store-dir served Nix store
55 --priority binary cache priority
56 --mass-query 0 or 1 - whether binary cache expects queries for nix-env -qas
58 --compression compression to use: bzip2 or xz
59 --key name:/path/to/key - key to use for narinfo signing
61 --nix-remote 'daemon' or empty string '' - whether to use daemon for store
66 --help show help and exit
75 workingdir="$(@coreutils@/mktemp -d)"
79 (echo "STORE_DIR=${NIX_STORE_DIR:-/nix/store}"; parse_opts "$@"
80 ) > nix-binary-cache.conf || exit
81 . "$workingdir/nix-binary-cache.conf"
85 server.modules = ( \"mod_cgi\", \"mod_setenv\", )
86 server.document-root = \"$workingdir\"
87 cgi.assign = ( \".cgi\" => \"@shell@\" )
88 setenv.add-request-header = ( \"NIX_BINARY_CACHE_CONFIG\" => \"$workingdir/nix-binary-cache.conf\" )
91 test -n "$USE_IPV6" && echo "
92 \$SERVER[\"socket\"] == \"[::]:$PORT\" {
93 server.use-ipv6 = \"enable\"
97 cp @out@/nix-binary-cache.cgi .
98 cp @out@/nix-binary-cache.cgi ./nix-bc.cgi
100 ip="$(@iproute@/ip a | @gnugrep@/grep 'inet .* scope global' | @coreutils@/head -n 1)"
104 url="http://$ip:$PORT/nix-bc.cgi?"
106 echo "Working directory: $workingdir"
108 echo "Address of the binary cache: $url"
110 echo "Usage example: NIX_REMOTE= nix-store --option binary-caches '$url'"
114 @lighttpd@/lighttpd -D -f "$workingdir/lighttpd.conf"
117 @coreutils@/rm -rf "$workingdir"