mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-10 00:08:07 +02:00
982399bb14
Example: $ nix-build ./all-packages.nix -A xlibs.libX11 So finally it's easy to perform a test build of a Nix expression!
78 lines
1.6 KiB
Text
78 lines
1.6 KiB
Text
#! @shell@ -e
|
|
|
|
nixExpr=$1
|
|
|
|
extraArgs=
|
|
extraInstArgs=
|
|
addDrvLink=0
|
|
addOutLink=1
|
|
|
|
|
|
trap 'rm -f ./.nix-build-tmp-*' EXIT
|
|
|
|
|
|
# Process the arguments.
|
|
args=("$@")
|
|
for ((i = 0; i < ${#args[*]}; )); do
|
|
arg=${args[$i]}
|
|
i=$((i + 1))
|
|
case "$arg" in
|
|
|
|
--help)
|
|
echo "syntax: $0 [NIX-EXPR...]" >&2
|
|
exit 0
|
|
;;
|
|
|
|
--add-drv-link)
|
|
addDrvLink=1
|
|
;;
|
|
|
|
--no-link)
|
|
addOutLink=0
|
|
;;
|
|
|
|
--attr|-A)
|
|
arg2=${args[$i]}
|
|
i=$((i + 1))
|
|
extraInstArgs="$extraInstArgs $arg $arg2"
|
|
;;
|
|
|
|
-*)
|
|
extraArgs="$extraArgs $arg"
|
|
;;
|
|
|
|
*)
|
|
exprs="$exprs $arg"
|
|
;;
|
|
esac
|
|
done
|
|
|
|
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 \
|
|
$extraInstArgs "$i")
|
|
|
|
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
|