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