about summary refs log blame commit diff
path: root/scripts/nix-build.in
blob: a5d747686a7dcda237cd60e1d2d7a80f0d624811 (plain) (tree)
1
2
3
4
5
6
7
8
9
10









                                     
       


                 


                    



                                     
                                                       
                                    

                                                 
                                                                       


                                          
                                           
                                 


                                                                      

                                     
                  
                


              
#! @shell@ -e

nixExpr=$1

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

extraArgs=
noLink=

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