git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #43147 from Ma27/fix-nixos-option-evaluation

nixos/nixos-option: don't abort in case of evaluation errors

commit1cfc4963a90f6b12148cddc9f7527641534415bd authorFranz Pletz <fpletz@fnordicwalking.de> dateMon 16 Jul 2018, 03:57 (8 years ago) parent7307c356f72b63
1 file changed+10−2
nixos/modules/installer/tools/nixos-option.sh+10−2
nixos/modules/installer/tools/nixos-option.sh+10−2
@@ -16,6 +16,7 @@ verbose=false
1616nixPath=""
1717
1818option=""
19+exit_code=0
1920
2021argfun=""
2122for arg; do
@@ -74,8 +75,13 @@ fi
7475#############################
7576
7677evalNix(){
78+ # disable `-e` flag, it's possible that the evaluation of `nix-instantiate` fails (e.g. due to broken pkgs)
79+ set +e
7780 result=$(nix-instantiate ${nixPath:+$nixPath} - --eval-only "$@" 2>&1)
78− if test $? -eq 0; then
81+ exit_code=$?
82+ set -e
83+
84+ if test $exit_code -eq 0; then
7985 cat <<EOF
8086$result
8187EOF
@@ -87,7 +93,7 @@ EOF
8793' <<EOF
8894$result
8995EOF
90− return 1;
96+ exit_code=1
9197 fi
9298}
9399
@@ -317,3 +323,5 @@ else
317323 echo $result
318324 fi
319325fi
326+
327+exit $exit_code