nixos-option: Support -I option.
This commit is contained in:
parent
c9682a22ff
commit
82a5f54c0d
@ -13,6 +13,7 @@ usage () {
|
|||||||
|
|
||||||
xml=false
|
xml=false
|
||||||
verbose=false
|
verbose=false
|
||||||
|
nixPath=""
|
||||||
|
|
||||||
option=""
|
option=""
|
||||||
|
|
||||||
@ -26,6 +27,7 @@ for arg; do
|
|||||||
while test "$sarg" != "-"; do
|
while test "$sarg" != "-"; do
|
||||||
case $sarg in
|
case $sarg in
|
||||||
--*) longarg=$arg; sarg="--";;
|
--*) longarg=$arg; sarg="--";;
|
||||||
|
-I) argfun="include_nixpath";;
|
||||||
-*) usage;;
|
-*) usage;;
|
||||||
esac
|
esac
|
||||||
# remove the first letter option
|
# remove the first letter option
|
||||||
@ -53,6 +55,9 @@ for arg; do
|
|||||||
var=$(echo $argfun | sed 's,^set_,,')
|
var=$(echo $argfun | sed 's,^set_,,')
|
||||||
eval $var=$arg
|
eval $var=$arg
|
||||||
;;
|
;;
|
||||||
|
include_nixpath)
|
||||||
|
nixPath="-I $arg $nixPath"
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
argfun=""
|
argfun=""
|
||||||
fi
|
fi
|
||||||
@ -69,14 +74,17 @@ fi
|
|||||||
#############################
|
#############################
|
||||||
|
|
||||||
evalNix(){
|
evalNix(){
|
||||||
result=$(nix-instantiate - --eval-only "$@" 2>&1)
|
result=$(nix-instantiate ${nixPath:+$nixPath} - --eval-only "$@" 2>&1)
|
||||||
if test $? -eq 0; then
|
if test $? -eq 0; then
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
$result
|
$result
|
||||||
EOF
|
EOF
|
||||||
return 0;
|
return 0;
|
||||||
else
|
else
|
||||||
sed -n '/error/ { s/, at (string):[0-9]*:[0-9]*//; p; }' <<EOF
|
sed -n '
|
||||||
|
/^error/ { s/, at (string):[0-9]*:[0-9]*//; p; };
|
||||||
|
/^warning: Nix search path/ { p; };
|
||||||
|
' <<EOF
|
||||||
$result
|
$result
|
||||||
EOF
|
EOF
|
||||||
return 1;
|
return 1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user