1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-12-24 02:39:48 +01:00

home-manager: properly forward exit codes

This commit is contained in:
Sandro Jäckel 2021-11-14 13:53:14 +01:00 committed by Robert Helgesson
parent 2452979efe
commit 398c0b36a3
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89

View file

@ -248,14 +248,12 @@ function doBuild() {
setFlakeAttribute
if [[ -v FLAKE_CONFIG_URI ]]; then
local exitCode=0
nix build \
"${PASSTHROUGH_OPTS[@]}" \
${DRY_RUN+--dry-run} \
${NO_OUT_LINK+--no-link} \
"$FLAKE_CONFIG_URI.activationPackage" \
|| exitCode=1
return $exitCode
|| return
fi
setWorkDir
@ -263,26 +261,21 @@ function doBuild() {
local newsInfo
newsInfo=$(buildNews)
local exitCode
doBuildAttr \
${NO_OUT_LINK+--no-out-link} \
--attr activationPackage \
&& exitCode=0 || exitCode=1
|| return
presentNews "$newsInfo"
return $exitCode
}
function doSwitch() {
setFlakeAttribute
if [[ -v FLAKE_CONFIG_URI ]]; then
local exitCode=0
nix run \
"${PASSTHROUGH_OPTS[@]}" \
"$FLAKE_CONFIG_URI.activationPackage" \
|| exitCode=1
return $exitCode
|| return
fi
setWorkDir
@ -291,7 +284,6 @@ function doSwitch() {
newsInfo=$(buildNews)
local generation
local exitCode=0
# Build the generation and run the activate script. Note, we
# specify an output link so that it is treated as a GC root. This
@ -302,11 +294,9 @@ function doSwitch() {
doBuildAttr \
--out-link "$generation" \
--attr activationPackage \
&& "$generation/activate" || exitCode=1
&& "$generation/activate" || return
presentNews "$newsInfo"
return $exitCode
}
function doListGens() {