1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-12-03 16:39:46 +01:00

home-manager: present news even if assertion failed

This commit is contained in:
Robert Helgesson 2017-09-09 17:14:07 +02:00
parent 07b4228988
commit cda222d2ec
No known key found for this signature in database
GPG key ID: C3DB11069E65DC86
2 changed files with 25 additions and 16 deletions

View file

@ -73,9 +73,10 @@ function doBuildAttr() {
--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() {
local infoFile
infoFile=$(buildNews) || return 1
local infoFile="$1"
# shellcheck source=/dev/null
. "$infoFile"
@ -111,11 +112,22 @@ function presentNews() {
}
function doBuild() {
doBuildAttr -A activationPackage
presentNews
local newsInfo
newsInfo=$(buildNews)
local exitCode
doBuildAttr -A activationPackage \
&& exitCode=0 || exitCode=1
presentNews "$newsInfo"
return $exitCode
}
function doSwitch() {
local newsInfo
newsInfo=$(buildNews)
local generation
local exitCode=0
local wrkdir
@ -132,9 +144,7 @@ function doSwitch() {
# running and $wrkdir is always removed.
rm -r "$wrkdir"
if [[ $exitCode -eq 0 ]]; then
presentNews
fi
presentNews "$newsInfo"
return $exitCode
}

View file

@ -70,18 +70,17 @@ let
config._module.check = check;
};
rawModule = lib.evalModules {
modules = [ configuration ] ++ modules ++ [ pkgsModule ];
};
module = showWarnings (
let
mod = lib.evalModules {
modules = [ configuration ] ++ modules ++ [ pkgsModule ];
};
failed = collectFailed mod.config;
failed = collectFailed rawModule.config;
failedStr = concatStringsSep "\n" (map (x: "- ${x}") failed);
in
if failed == []
then mod
then rawModule
else throw "\nFailed assertions:\n${failedStr}"
);
@ -95,9 +94,9 @@ in
# For backwards compatibility. Please use activationPackage instead.
activation-script = module.config.home.activationPackage;
newsDisplay = module.config.news.display;
newsDisplay = rawModule.config.news.display;
newsEntries =
sort (a: b: a.time > b.time) (
filter (a: a.condition) module.config.news.entries
filter (a: a.condition) rawModule.config.news.entries
);
}