about summary refs log tree commit diff
path: root/corepkgs/nix-pull/builder.sh.in
blob: cc1a125d8f8ff1dbde9ac74a44971a7f279ba8ee (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#! @shell@ -e

export PATH=/bin:/usr/bin

mkdir $out

cat > $out/fetch <<EOF
#! @shell@ -e

export PATH=/bin:/usr/bin

echo "downloading \$2..."

export PRINT_PATH=1
result=(\$(@bindir@/nix-prefetch-url \$2))

hash=\${result[0]}
path=\${result[1]}

if test "\$hash" != "\$3"; then
    echo "hash is \$hash, expected \$3"
    exit 1
fi

echo "unpacking into \$1..."

if ! @bunzip2@ < "\$path" | @bindir@/nix-store --restore "\$1"; then
    exit 1
fi

exit 0
EOF

chmod +x $out/fetch