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