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