Fix nixos-option without argument.
svn path=/nixos/trunk/; revision=31139
This commit is contained in:
parent
eb755d4692
commit
338bc7b9f8
@ -166,6 +166,29 @@ findSources(){
|
|||||||
evalNix --strict
|
evalNix --strict
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Given a result from nix-instantiate, recover the list of attributes it
|
||||||
|
# contains.
|
||||||
|
attrNames() {
|
||||||
|
local attributeset=$1
|
||||||
|
# sed is used to replace un-printable subset by 0s, and to remove most of
|
||||||
|
# the inner-attribute set, which reduce the likelyhood to encounter badly
|
||||||
|
# pre-processed input.
|
||||||
|
echo "builtins.attrNames $attributeset" | \
|
||||||
|
sed 's,<[A-Z]*>,0,g; :inner; s/{[^\{\}]*};/0;/g; t inner;' | \
|
||||||
|
evalNix --strict
|
||||||
|
}
|
||||||
|
|
||||||
|
# map a simple list which contains strings or paths.
|
||||||
|
nixMap() {
|
||||||
|
local fun="$1"
|
||||||
|
local list="$2"
|
||||||
|
local elem
|
||||||
|
for elem in $list; do
|
||||||
|
test $elem = '[' -o $elem = ']' && continue;
|
||||||
|
$fun $elem
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
if $install; then
|
if $install; then
|
||||||
if test -e "$mountPoint$NIXOS"; then
|
if test -e "$mountPoint$NIXOS"; then
|
||||||
export NIXOS="$mountPoint$NIXOS"
|
export NIXOS="$mountPoint$NIXOS"
|
||||||
@ -362,17 +385,13 @@ if test "$(evalOpt "_type" 2> /dev/null)" = '"option"'; then
|
|||||||
if $defs; then
|
if $defs; then
|
||||||
$desc || $value && echo;
|
$desc || $value && echo;
|
||||||
|
|
||||||
|
printPath () { echo " $1"; }
|
||||||
|
|
||||||
echo "Declared by:"
|
echo "Declared by:"
|
||||||
for f in $(findSources "declarations"); do
|
nixMap printPath "$(findSources "declarations")"
|
||||||
test $f = '[' -o $f = ']' && continue;
|
|
||||||
echo " $f"
|
|
||||||
done
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "Defined by:"
|
echo "Defined by:"
|
||||||
for f in $(findSources "definitions"); do
|
nixMap printPath "$(findSources "definitions")"
|
||||||
test $f = '[' -o $f = ']' && continue;
|
|
||||||
echo " $f"
|
|
||||||
done
|
|
||||||
echo ""
|
echo ""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -380,13 +399,12 @@ else
|
|||||||
# echo 1>&2 "Warning: This value is not an option."
|
# echo 1>&2 "Warning: This value is not an option."
|
||||||
|
|
||||||
result=$(evalCfg)
|
result=$(evalCfg)
|
||||||
if names=$(echo "builtins.attrNames $result" | sed 's,<[A-Z]*>,0,g' | nix-instantiate - --eval-only --strict 2> /dev/null); then
|
if names=$(attrNames "$result" 2> /dev/null); then
|
||||||
echo 1>&2 "This attribute set contains:"
|
echo 1>&2 "This attribute set contains:"
|
||||||
for attr in $names; do
|
escapeQuotes () { eval echo "$1"; }
|
||||||
test $attr = '[' -o $attr = ']' && continue;
|
nixMap escapeQuotes "$names"
|
||||||
eval echo $attr # escape extra double-quotes in the attribute name.
|
|
||||||
done
|
|
||||||
else
|
else
|
||||||
|
echo 1>&2 "An error occured while looking for attribute names."
|
||||||
echo $result
|
echo $result
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
Loading…
x
Reference in New Issue
Block a user