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