git.iko.soy/typeable/nixpkgs
on master help sign in
nixos-option: Support -I option.
82a5f54Nicolas B. Pierron
nixos/modules/installer/tools/nixos-option.sh+10−2
@@ -13,6 +13,7 @@ usage () {
13
13
14xml=false
14xml=false
15verbose=false
15verbose=false
16+nixPath=""
16
17
17option=""
18option=""
18
19
@@ -26,6 +27,7 @@ for arg; do
26 while test "$sarg" != "-"; do
27 while test "$sarg" != "-"; do
27 case $sarg in
28 case $sarg in
28 --*) longarg=$arg; sarg="--";;
29 --*) longarg=$arg; sarg="--";;
30+ -I) argfun="include_nixpath";;
29 -*) usage;;
31 -*) usage;;
30 esac
32 esac
31 # remove the first letter option
33 # remove the first letter option
@@ -53,6 +55,9 @@ for arg; do
53 var=$(echo $argfun | sed 's,^set_,,')
55 var=$(echo $argfun | sed 's,^set_,,')
54 eval $var=$arg
56 eval $var=$arg
55 ;;
57 ;;
58+ include_nixpath)
59+ nixPath="-I $arg $nixPath"
60+ ;;
56 esac
61 esac
57 argfun=""
62 argfun=""
58 fi
63 fi
@@ -69,14 +74,17 @@ fi
69#############################
74#############################
70
75
71evalNix(){
76evalNix(){
72− result=$(nix-instantiate - --eval-only "$@" 2>&1)
77+ result=$(nix-instantiate ${nixPath:+$nixPath} - --eval-only "$@" 2>&1)
73 if test $? -eq 0; then
78 if test $? -eq 0; then
74 cat <<EOF
79 cat <<EOF
75$result
80$result
76EOF
81EOF
77 return 0;
82 return 0;
78 else
83 else
84+ sed -n '
79− sed -n '/error/ { s/, at (string):[0-9]*:[0-9]*//; p; }' <<EOF
85+ /^error/ { s/, at (string):[0-9]*:[0-9]*//; p; };
86+ /^warning: Nix search path/ { p; };
87+' <<EOF
80$result
88$result
81EOF
89EOF
82 return 1;
90 return 1;