2004-06-22 15:12:34 +00:00
|
|
|
#! @shell@ -e
|
|
|
|
|
|
|
|
nixExpr=$1
|
|
|
|
|
|
|
|
extraArgs=
|
2006-02-10 17:37:35 +00:00
|
|
|
extraInstArgs=
|
2005-02-01 13:48:46 +00:00
|
|
|
addDrvLink=0
|
|
|
|
addOutLink=1
|
2004-06-22 15:12:34 +00:00
|
|
|
|
2005-02-01 12:36:25 +00:00
|
|
|
|
2005-02-01 13:48:46 +00:00
|
|
|
trap 'rm -f ./.nix-build-tmp-*' EXIT
|
|
|
|
|
|
|
|
|
|
|
|
# Process the arguments.
|
2006-02-10 17:37:35 +00:00
|
|
|
args=("$@")
|
|
|
|
for ((i = 0; i < ${#args[*]}; )); do
|
|
|
|
arg=${args[$i]}
|
|
|
|
i=$((i + 1))
|
|
|
|
case "$arg" in
|
2005-07-13 17:39:10 +00:00
|
|
|
|
|
|
|
--help)
|
|
|
|
echo "syntax: $0 [NIX-EXPR...]" >&2
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
|
2005-02-01 13:48:46 +00:00
|
|
|
--add-drv-link)
|
|
|
|
addDrvLink=1
|
|
|
|
;;
|
|
|
|
|
2004-08-18 12:11:31 +00:00
|
|
|
--no-link)
|
2005-02-01 13:48:46 +00:00
|
|
|
addOutLink=0
|
2004-08-18 12:11:31 +00:00
|
|
|
;;
|
2006-02-10 17:37:35 +00:00
|
|
|
|
|
|
|
--attr|-A)
|
|
|
|
arg2=${args[$i]}
|
|
|
|
i=$((i + 1))
|
|
|
|
extraInstArgs="$extraInstArgs $arg $arg2"
|
|
|
|
;;
|
2005-02-01 13:48:46 +00:00
|
|
|
|
2004-06-22 15:12:34 +00:00
|
|
|
-*)
|
2006-02-10 17:37:35 +00:00
|
|
|
extraArgs="$extraArgs $arg"
|
2004-06-22 15:12:34 +00:00
|
|
|
;;
|
2005-02-01 13:48:46 +00:00
|
|
|
|
2004-06-22 15:12:34 +00:00
|
|
|
*)
|
2006-02-10 17:37:35 +00:00
|
|
|
exprs="$exprs $arg"
|
2004-06-22 15:12:34 +00:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
2005-07-13 17:39:10 +00:00
|
|
|
|
|
|
|
if test -z "$exprs"; then
|
|
|
|
exprs="./default.nix"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Process the specified Nix expressions.
|
|
|
|
for i in $exprs; do
|
|
|
|
|
|
|
|
# Instantiate the Nix expression.
|
|
|
|
prefix=
|
|
|
|
if test "$addDrvLink" = 0; then prefix=.nix-build-tmp-; fi
|
|
|
|
storeExprs=$(@bindir@/nix-instantiate \
|
|
|
|
--add-root ./${prefix}derivation --indirect \
|
2006-02-10 17:37:35 +00:00
|
|
|
$extraInstArgs "$i")
|
2005-07-13 17:39:10 +00:00
|
|
|
|
|
|
|
for j in $storeExprs; do
|
|
|
|
echo "store expression is $(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 "$(readlink "$j")"
|
|
|
|
done
|
|
|
|
done
|