Merge pull request #43147 from Ma27/fix-nixos-option-evaluation

nixos/nixos-option: don't abort in case of evaluation errors
This commit is contained in:
Franz Pletz 2018-07-16 03:57:37 +00:00 committed by GitHub
commit 1cfc4963a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -16,6 +16,7 @@ verbose=false
nixPath="" nixPath=""
option="" option=""
exit_code=0
argfun="" argfun=""
for arg; do for arg; do
@ -74,8 +75,13 @@ fi
############################# #############################
evalNix(){ evalNix(){
# disable `-e` flag, it's possible that the evaluation of `nix-instantiate` fails (e.g. due to broken pkgs)
set +e
result=$(nix-instantiate ${nixPath:+$nixPath} - --eval-only "$@" 2>&1) result=$(nix-instantiate ${nixPath:+$nixPath} - --eval-only "$@" 2>&1)
if test $? -eq 0; then exit_code=$?
set -e
if test $exit_code -eq 0; then
cat <<EOF cat <<EOF
$result $result
EOF EOF
@ -87,7 +93,7 @@ EOF
' <<EOF ' <<EOF
$result $result
EOF EOF
return 1; exit_code=1
fi fi
} }
@ -317,3 +323,5 @@ else
echo $result echo $result
fi fi
fi fi
exit $exit_code