1
0
mirror of https://github.com/nix-community/home-manager synced 2024-06-19 21:18:30 +02:00

home-manager: exit with an error on build failure

Because 'set -e' has no effect on commands that run in an if condition,
the script was always exiting with no error when 'doBuild' failed.

As a bonus, $wrkdir is now always removed after building.
This commit is contained in:
Cornelius Mika 2017-08-17 10:16:25 +02:00 committed by Robert Helgesson
parent ffbc7e723d
commit a9d9fb5d75
No known key found for this signature in database
GPG Key ID: C3DB11069E65DC86

View File

@ -91,11 +91,13 @@ function doSwitch() {
local wrkdir
wrkdir="$(mktemp -d)"
if doBuild "$wrkdir/generation" ; then
"$wrkdir/generation/activate"
fi
local exitCode=0
doBuild "$wrkdir/generation" && "$wrkdir/generation/activate" || exitCode=1
# Because the previous command never fails, the script keeps running and
# $wrkdir is always removed.
rm -r "$wrkdir"
return $exitCode
}
function doListGens() {