2017-01-07 18:16:26 +00:00
|
|
|
|
{ configuration
|
|
|
|
|
, pkgs
|
|
|
|
|
, lib ? pkgs.stdenv.lib
|
2017-08-26 20:24:40 +00:00
|
|
|
|
|
|
|
|
|
# Whether to check that each option has a matching declaration.
|
|
|
|
|
, check ? true
|
2021-01-06 02:31:01 +00:00
|
|
|
|
# Extra arguments passed to specialArgs.
|
|
|
|
|
, extraSpecialArgs ? { }
|
2017-01-07 18:16:26 +00:00
|
|
|
|
}:
|
|
|
|
|
|
2017-02-21 20:39:53 +00:00
|
|
|
|
with lib;
|
|
|
|
|
|
2017-01-07 18:16:26 +00:00
|
|
|
|
let
|
|
|
|
|
|
2017-02-21 20:39:53 +00:00
|
|
|
|
collectFailed = cfg:
|
|
|
|
|
map (x: x.message) (filter (x: !x.assertion) cfg.assertions);
|
|
|
|
|
|
|
|
|
|
showWarnings = res:
|
|
|
|
|
let
|
|
|
|
|
f = w: x: builtins.trace "[1;31mwarning: ${w}[0m" x;
|
|
|
|
|
in
|
|
|
|
|
fold f res res.config.warnings;
|
|
|
|
|
|
2020-01-16 22:41:14 +00:00
|
|
|
|
extendedLib = import ./lib/stdlib-extended.nix pkgs.lib;
|
|
|
|
|
|
|
|
|
|
hmModules =
|
|
|
|
|
import ./modules.nix {
|
|
|
|
|
inherit check pkgs;
|
|
|
|
|
lib = extendedLib;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
rawModule = extendedLib.evalModules {
|
|
|
|
|
modules = [ configuration ] ++ hmModules;
|
2019-04-07 11:14:15 +00:00
|
|
|
|
specialArgs = {
|
|
|
|
|
modulesPath = builtins.toString ./.;
|
2021-01-06 02:31:01 +00:00
|
|
|
|
} // extraSpecialArgs;
|
2017-09-09 15:14:07 +00:00
|
|
|
|
};
|
|
|
|
|
|
2017-02-21 20:39:53 +00:00
|
|
|
|
module = showWarnings (
|
|
|
|
|
let
|
2017-09-09 15:14:07 +00:00
|
|
|
|
failed = collectFailed rawModule.config;
|
2017-02-21 20:39:53 +00:00
|
|
|
|
failedStr = concatStringsSep "\n" (map (x: "- ${x}") failed);
|
|
|
|
|
in
|
|
|
|
|
if failed == []
|
2017-09-09 15:14:07 +00:00
|
|
|
|
then rawModule
|
2017-02-21 20:39:53 +00:00
|
|
|
|
else throw "\nFailed assertions:\n${failedStr}"
|
|
|
|
|
);
|
2017-01-07 18:16:26 +00:00
|
|
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
inherit (module) options config;
|
|
|
|
|
|
2017-08-27 11:04:39 +00:00
|
|
|
|
activationPackage = module.config.home.activationPackage;
|
2017-08-27 15:44:00 +00:00
|
|
|
|
|
|
|
|
|
# For backwards compatibility. Please use activationPackage instead.
|
2017-08-27 15:13:06 +00:00
|
|
|
|
activation-script = module.config.home.activationPackage;
|
2017-08-26 20:24:40 +00:00
|
|
|
|
|
2017-09-09 15:14:07 +00:00
|
|
|
|
newsDisplay = rawModule.config.news.display;
|
2017-08-26 20:24:40 +00:00
|
|
|
|
newsEntries =
|
|
|
|
|
sort (a: b: a.time > b.time) (
|
2017-09-09 15:14:07 +00:00
|
|
|
|
filter (a: a.condition) rawModule.config.news.entries
|
2017-08-26 20:24:40 +00:00
|
|
|
|
);
|
2017-01-07 18:16:26 +00:00
|
|
|
|
}
|