forked from lix-project/lix
* Enable the --attr in nix-build as well (and add -A as an alias).
Example: $ nix-build ./all-packages.nix -A xlibs.libX11 So finally it's easy to perform a test build of a Nix expression!
This commit is contained in:
parent
c6120352b3
commit
982399bb14
|
@ -3,6 +3,7 @@
|
||||||
nixExpr=$1
|
nixExpr=$1
|
||||||
|
|
||||||
extraArgs=
|
extraArgs=
|
||||||
|
extraInstArgs=
|
||||||
addDrvLink=0
|
addDrvLink=0
|
||||||
addOutLink=1
|
addOutLink=1
|
||||||
|
|
||||||
|
@ -11,9 +12,11 @@ trap 'rm -f ./.nix-build-tmp-*' EXIT
|
||||||
|
|
||||||
|
|
||||||
# Process the arguments.
|
# Process the arguments.
|
||||||
exprs=
|
args=("$@")
|
||||||
for i in "$@"; do
|
for ((i = 0; i < ${#args[*]}; )); do
|
||||||
case "$i" in
|
arg=${args[$i]}
|
||||||
|
i=$((i + 1))
|
||||||
|
case "$arg" in
|
||||||
|
|
||||||
--help)
|
--help)
|
||||||
echo "syntax: $0 [NIX-EXPR...]" >&2
|
echo "syntax: $0 [NIX-EXPR...]" >&2
|
||||||
|
@ -28,12 +31,18 @@ for i in "$@"; do
|
||||||
addOutLink=0
|
addOutLink=0
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
--attr|-A)
|
||||||
|
arg2=${args[$i]}
|
||||||
|
i=$((i + 1))
|
||||||
|
extraInstArgs="$extraInstArgs $arg $arg2"
|
||||||
|
;;
|
||||||
|
|
||||||
-*)
|
-*)
|
||||||
extraArgs="$extraArgs $i"
|
extraArgs="$extraArgs $arg"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
*)
|
*)
|
||||||
exprs="$exprs $i"
|
exprs="$exprs $arg"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
@ -50,7 +59,7 @@ for i in $exprs; do
|
||||||
if test "$addDrvLink" = 0; then prefix=.nix-build-tmp-; fi
|
if test "$addDrvLink" = 0; then prefix=.nix-build-tmp-; fi
|
||||||
storeExprs=$(@bindir@/nix-instantiate \
|
storeExprs=$(@bindir@/nix-instantiate \
|
||||||
--add-root ./${prefix}derivation --indirect \
|
--add-root ./${prefix}derivation --indirect \
|
||||||
"$i")
|
$extraInstArgs "$i")
|
||||||
|
|
||||||
for j in $storeExprs; do
|
for j in $storeExprs; do
|
||||||
echo "store expression is $(readlink "$j")" >&2
|
echo "store expression is $(readlink "$j")" >&2
|
||||||
|
|
|
@ -84,7 +84,7 @@ void run(Strings args)
|
||||||
throw UsageError("`--add-root requires an argument");
|
throw UsageError("`--add-root requires an argument");
|
||||||
gcRoot = absPath(*i++);
|
gcRoot = absPath(*i++);
|
||||||
}
|
}
|
||||||
else if (arg == "--attr") {
|
else if (arg == "--attr" || arg == "-A") {
|
||||||
if (i == args.end())
|
if (i == args.end())
|
||||||
throw UsageError("`--attr requires an argument");
|
throw UsageError("`--attr requires an argument");
|
||||||
attrPath = *i++;
|
attrPath = *i++;
|
||||||
|
|
Loading…
Reference in a new issue