diff --git a/home-manager/home-manager b/home-manager/home-manager index 329dd8d5c..97166d6f9 100644 --- a/home-manager/home-manager +++ b/home-manager/home-manager @@ -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 } diff --git a/modules/default.nix b/modules/default.nix index 9137fa384..c5fc9bcbc 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -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 ); }