home-manager: add news sub-command

This command allows the user to examine the news items generated by
the news module. See #52.

Many thanks to @nonsequitur and @uvNikita for suggestions and
improvements.
This commit is contained in:
Robert Helgesson
2017-08-26 22:24:40 +02:00
parent ab0338f6ae
commit 9c1b3735b4
4 changed files with 195 additions and 13 deletions

View File

@@ -1,6 +1,9 @@
{ configuration
, pkgs
, lib ? pkgs.stdenv.lib
# Whether to check that each option has a matching declaration.
, check ? true
}:
with lib;
@@ -64,6 +67,7 @@ let
pkgsModule = {
config._module.args.pkgs = lib.mkForce pkgs;
config._module.args.baseModules = modules;
config._module.check = check;
};
module = showWarnings (
@@ -90,4 +94,10 @@ in
# For backwards compatibility. Please use activationPackage instead.
activation-script = module.config.home.activationPackage;
newsDisplay = module.config.news.display;
newsEntries =
sort (a: b: a.time > b.time) (
filter (a: a.condition) module.config.news.entries
);
}