about summary refs log tree commit diff
path: root/scripts/nix-build.in
blob: 321add884f24377f343cf83d337db9be4af5368e (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

nixExpr=$1

if test -z "$nixExpr"; then
    echo "syntax: $0 NIX-EXPR..." >&2
    exit 1
fi

extraArgs=

for i in "$@"; do
    case "$i" in
        -*)
            extraArgs="$extraArgs $i"
            ;;
        *)
            storeExpr=$(nix-instantiate "$i")
            for j in $storeExpr; do
                echo "store expression is $j" >&2
            done
            outPath=$(nix-store -qnfv $extraArgs $storeExpr)
            echo $outPath
            if test -e result; then
                if ! test -L result; then
                    echo "cannot remove \`result\' (not a symlink)"
                    exit 1
                fi
                rm result
            fi
            ln -s $outPath result
            ;;
    esac
done