1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-23 19:49:45 +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 setFlakeAttribute
if [[ -v FLAKE_CONFIG_URI ]]; then if [[ -v FLAKE_CONFIG_URI ]]; then
local exitCode=0
nix build \ nix build \
"${PASSTHROUGH_OPTS[@]}" \ "${PASSTHROUGH_OPTS[@]}" \
${DRY_RUN+--dry-run} \ ${DRY_RUN+--dry-run} \
${NO_OUT_LINK+--no-link} \ ${NO_OUT_LINK+--no-link} \
"$FLAKE_CONFIG_URI.activationPackage" \ "$FLAKE_CONFIG_URI.activationPackage" \
|| exitCode=1 || return
return $exitCode
fi fi
setWorkDir setWorkDir
@ -263,26 +261,21 @@ function doBuild() {
local newsInfo local newsInfo
newsInfo=$(buildNews) newsInfo=$(buildNews)
local exitCode
doBuildAttr \ doBuildAttr \
${NO_OUT_LINK+--no-out-link} \ ${NO_OUT_LINK+--no-out-link} \
--attr activationPackage \ --attr activationPackage \
&& exitCode=0 || exitCode=1 || return
presentNews "$newsInfo" presentNews "$newsInfo"
return $exitCode
} }
function doSwitch() { function doSwitch() {
setFlakeAttribute setFlakeAttribute
if [[ -v FLAKE_CONFIG_URI ]]; then if [[ -v FLAKE_CONFIG_URI ]]; then
local exitCode=0
nix run \ nix run \
"${PASSTHROUGH_OPTS[@]}" \ "${PASSTHROUGH_OPTS[@]}" \
"$FLAKE_CONFIG_URI.activationPackage" \ "$FLAKE_CONFIG_URI.activationPackage" \
|| exitCode=1 || return
return $exitCode
fi fi
setWorkDir setWorkDir
@ -291,7 +284,6 @@ function doSwitch() {
newsInfo=$(buildNews) newsInfo=$(buildNews)
local generation local generation
local exitCode=0
# Build the generation and run the activate script. Note, we # Build the generation and run the activate script. Note, we
# specify an output link so that it is treated as a GC root. This # specify an output link so that it is treated as a GC root. This
@ -302,11 +294,9 @@ function doSwitch() {
doBuildAttr \ doBuildAttr \
--out-link "$generation" \ --out-link "$generation" \
--attr activationPackage \ --attr activationPackage \
&& "$generation/activate" || exitCode=1 && "$generation/activate" || return
presentNews "$newsInfo" presentNews "$newsInfo"
return $exitCode
} }
function doListGens() { function doListGens() {