mirror of
https://github.com/nix-community/home-manager
synced 2024-12-04 17:09:47 +01:00
home-manager: present news even if assertion failed
This commit is contained in:
parent
07b4228988
commit
cda222d2ec
2 changed files with 25 additions and 16 deletions
|
@ -73,9 +73,10 @@ function doBuildAttr() {
|
||||||
--argstr confAttr "$HOME_MANAGER_CONFIG_ATTRIBUTE"
|
--argstr confAttr "$HOME_MANAGER_CONFIG_ATTRIBUTE"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Presents news to the user. Takes as argument the path to a "news
|
||||||
|
# info" file as generated by `buildNews`.
|
||||||
function presentNews() {
|
function presentNews() {
|
||||||
local infoFile
|
local infoFile="$1"
|
||||||
infoFile=$(buildNews) || return 1
|
|
||||||
|
|
||||||
# shellcheck source=/dev/null
|
# shellcheck source=/dev/null
|
||||||
. "$infoFile"
|
. "$infoFile"
|
||||||
|
@ -111,11 +112,22 @@ function presentNews() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function doBuild() {
|
function doBuild() {
|
||||||
doBuildAttr -A activationPackage
|
local newsInfo
|
||||||
presentNews
|
newsInfo=$(buildNews)
|
||||||
|
|
||||||
|
local exitCode
|
||||||
|
doBuildAttr -A activationPackage \
|
||||||
|
&& exitCode=0 || exitCode=1
|
||||||
|
|
||||||
|
presentNews "$newsInfo"
|
||||||
|
|
||||||
|
return $exitCode
|
||||||
}
|
}
|
||||||
|
|
||||||
function doSwitch() {
|
function doSwitch() {
|
||||||
|
local newsInfo
|
||||||
|
newsInfo=$(buildNews)
|
||||||
|
|
||||||
local generation
|
local generation
|
||||||
local exitCode=0
|
local exitCode=0
|
||||||
local wrkdir
|
local wrkdir
|
||||||
|
@ -132,9 +144,7 @@ function doSwitch() {
|
||||||
# running and $wrkdir is always removed.
|
# running and $wrkdir is always removed.
|
||||||
rm -r "$wrkdir"
|
rm -r "$wrkdir"
|
||||||
|
|
||||||
if [[ $exitCode -eq 0 ]]; then
|
presentNews "$newsInfo"
|
||||||
presentNews
|
|
||||||
fi
|
|
||||||
|
|
||||||
return $exitCode
|
return $exitCode
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,18 +70,17 @@ let
|
||||||
config._module.check = check;
|
config._module.check = check;
|
||||||
};
|
};
|
||||||
|
|
||||||
module = showWarnings (
|
rawModule = lib.evalModules {
|
||||||
let
|
|
||||||
mod = lib.evalModules {
|
|
||||||
modules = [ configuration ] ++ modules ++ [ pkgsModule ];
|
modules = [ configuration ] ++ modules ++ [ pkgsModule ];
|
||||||
};
|
};
|
||||||
|
|
||||||
failed = collectFailed mod.config;
|
module = showWarnings (
|
||||||
|
let
|
||||||
|
failed = collectFailed rawModule.config;
|
||||||
failedStr = concatStringsSep "\n" (map (x: "- ${x}") failed);
|
failedStr = concatStringsSep "\n" (map (x: "- ${x}") failed);
|
||||||
in
|
in
|
||||||
if failed == []
|
if failed == []
|
||||||
then mod
|
then rawModule
|
||||||
else throw "\nFailed assertions:\n${failedStr}"
|
else throw "\nFailed assertions:\n${failedStr}"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -95,9 +94,9 @@ in
|
||||||
# For backwards compatibility. Please use activationPackage instead.
|
# For backwards compatibility. Please use activationPackage instead.
|
||||||
activation-script = module.config.home.activationPackage;
|
activation-script = module.config.home.activationPackage;
|
||||||
|
|
||||||
newsDisplay = module.config.news.display;
|
newsDisplay = rawModule.config.news.display;
|
||||||
newsEntries =
|
newsEntries =
|
||||||
sort (a: b: a.time > b.time) (
|
sort (a: b: a.time > b.time) (
|
||||||
filter (a: a.condition) module.config.news.entries
|
filter (a: a.condition) rawModule.config.news.entries
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue