Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)
Paste
Pasted as Plain Text by Michael ( 12 years ago )
#! /bin/sh
STORE_DIR=/nix/store
PRIORITY=75
COMPRESSI
KEY=/nix/var/nix/keys/id_nix_remote
hostname=/run/current-system/sw/bin/
KEYNAME=$($hostname/hostname)
nix=/run/current-system/sw/bin/
xz=/run/current-system/sw/bin/
bzip2=/run/current-system/sw/bin/
sed=/run/current-system/sw/bin/
openssl=/run/current-system/sw/bin/
export NIX_REMOTE=daemon
header(){
echo "Content-Type: text/plain; charset=utf-8"
echo
}
clean_path() {
$sed/sed -re "s@^$STORE_DIR/?@@" | xargs
}
storeq(){
$nix/nix-store -q "$@"
}
sign(){
sha256sum | sed -e 's/ .*//' | $openssl/openssl rsautl -sign -inkey "$@" | base64 -w 0
}
case "$QUERY_STRING" in
"")
header
echo "Hello, this is a dynamically-generated Nix binary cache"
;;
/nix-cache-info)
header
echo "StoreDir: $STORE_DIR"
echo "WantMassQuery: 0"
echo "Priority: $PRIORITY"
;;
*.narinfo)
hash=${QUERY_STRING%.narinfo}
hash=${hash#/}
path="$(echo "$STORE_DIR/$hash-"* )"
if [ -n "$path" ] && [ -e "$path" ]; then
header
info="$(
echo "StorePath: $path"
echo "URL: $(basename "$path").nar.$COMPRESSION"
echo "Compression: $COMPRESSION"
echo "NarHash: $(storeq --hash "$path")"
echo "NarSize: $(storeq --size "$path")"
echo "References: $(storeq --references "$path" | tac | clean_path )"
echo "Deriver: $(storeq --deriver "$path" | clean_path )"
echo "System: x86_64-linux"
)"
signature="$(echo "$info" | sign "$KEY")"
echo "$info"
echo "Signature: 1;$KEYNAME;$signature"
else
exit 1
fi
;;
*.nar.xz)
path="$STORE_DIR${QUERY_STRING%.nar.xz}"
if [ -n "$path" ] && [ -e "$path" ]; then
header
$nix/nix-store --dump "$path" | $xz/xz | cat
else
exit 1
fi
;;
*.nar.bzip2)
path="$STORE_DIR${QUERY_STRING%.nar.bzip2}"
echo "$path" >&2;
if [ -n "$path" ] && [ -e "$path" ]; then
header
$nix/nix-store --dump "$path" | $bzip2/bzip2 | cat
else
exit 1
fi
;;
esac
Revise this Paste
Parent: 73368