about summary refs log blame commit diff
path: root/scripts/nix-build.in
blob: e11a88dcd0df19563f9cd01e9c7a5a33300b0351 (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=
addDrvLink=0
addOutLink=1


trap 'rm -f ./.nix-build-tmp-*' EXIT


# Process the arguments.
for i in "$@"; do
    case "$i" in
    
        --add-drv-link)
            addDrvLink=1
            ;;
            
        --no-link)
            addOutLink=0
            ;;
            
        -*)
            extraArgs="$extraArgs $i"
            ;;
            
        *)
            # Instantiate the Nix expression.
            prefix=
            if test "$addDrvLink" = 0; then prefix=.nix-build-tmp-; fi
            storeExprs=$(@bindir@/nix-instantiate \
                --add-root ./${prefix}derivation --indirect \
                "$i")
                
            for j in $storeExprs; do
                echo "store expression is $j $(readlink "$j")" >&2
            done

            # Build the resulting store derivation.
            prefix=
            if test "$addOutLink" = 0; then prefix=.nix-build-tmp-; fi
            outPaths=$(@bindir@/nix-store \
                --add-root ./${prefix}result --indirect \
                -rv $extraArgs $storeExprs)
                
            for j in $outPaths; do
                echo "$j $(readlink "$j")"
            done
            
            ;;
    esac
done