2004-06-22 15:12:34 +00:00
|
|
|
#! @shell@ -e
|
|
|
|
|
|
|
|
nixExpr=$1
|
|
|
|
|
|
|
|
if test -z "$nixExpr"; then
|
|
|
|
echo "syntax: $0 NIX-EXPR..." >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
extraArgs=
|
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.
|
2004-06-22 15:12:34 +00:00
|
|
|
for i in "$@"; do
|
|
|
|
case "$i" in
|
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
|
|
|
;;
|
2005-02-01 13:48:46 +00:00
|
|
|
|
2004-06-22 15:12:34 +00:00
|
|
|
-*)
|
|
|
|
extraArgs="$extraArgs $i"
|
|
|
|
;;
|
2005-02-01 13:48:46 +00:00
|
|
|
|
2004-06-22 15:12:34 +00:00
|
|
|
*)
|
2005-02-01 13:48:46 +00:00
|
|
|
# Instantiate the Nix expression.
|
|
|
|
prefix=
|
|
|
|
if test "$addDrvLink" = 0; then prefix=.nix-build-tmp-; fi
|
2005-02-01 12:36:25 +00:00
|
|
|
storeExprs=$(@bindir@/nix-instantiate \
|
2005-02-01 13:48:46 +00:00
|
|
|
--add-root ./${prefix}derivation --indirect \
|
2005-02-01 12:36:25 +00:00
|
|
|
"$i")
|
2005-02-01 13:48:46 +00:00
|
|
|
|
2004-08-18 12:11:31 +00:00
|
|
|
for j in $storeExprs; do
|
2005-02-01 17:52:11 +00:00
|
|
|
echo "store expression is $(readlink "$j")" >&2
|
2004-06-22 15:17:04 +00:00
|
|
|
done
|
2005-02-01 13:48:46 +00:00
|
|
|
|
|
|
|
# Build the resulting store derivation.
|
|
|
|
prefix=
|
|
|
|
if test "$addOutLink" = 0; then prefix=.nix-build-tmp-; fi
|
2005-02-01 12:36:25 +00:00
|
|
|
outPaths=$(@bindir@/nix-store \
|
2005-02-01 13:48:46 +00:00
|
|
|
--add-root ./${prefix}result --indirect \
|
2005-02-01 12:36:25 +00:00
|
|
|
-rv $extraArgs $storeExprs)
|
2005-02-01 13:48:46 +00:00
|
|
|
|
2004-08-18 12:11:31 +00:00
|
|
|
for j in $outPaths; do
|
2005-02-01 17:52:11 +00:00
|
|
|
echo "$(readlink "$j")"
|
2004-08-18 12:11:31 +00:00
|
|
|
done
|
2005-02-01 13:48:46 +00:00
|
|
|
|
2004-06-22 15:12:34 +00:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|