49 lines
997 B
Nix
49 lines
997 B
Nix
hm:
|
||
|
||
{ configuration
|
||
, pkgs
|
||
, inputs ? { }
|
||
}:
|
||
|
||
with pkgs.lib;
|
||
let
|
||
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;
|
||
|
||
extendedLib = import "${hm}/modules/lib/stdlib-extended.nix" pkgs.lib;
|
||
|
||
hmModules =
|
||
import "${hm}/modules/modules.nix" {
|
||
inherit pkgs;
|
||
check = true;
|
||
useNixpkgsModule = false;
|
||
lib = extendedLib;
|
||
};
|
||
|
||
rawModule = extendedLib.evalModules {
|
||
modules = [ configuration ] ++ hmModules;
|
||
specialArgs = {
|
||
inherit inputs;
|
||
modulesPath = "${hm}/modules";
|
||
};
|
||
};
|
||
|
||
module = showWarnings (
|
||
let
|
||
failed = collectFailed rawModule.config;
|
||
failedStr = concatStringsSep "\n" (map (x: "- ${x}") failed);
|
||
in
|
||
if failed == [ ]
|
||
then rawModule
|
||
else throw "\nFailed assertions:\n${failedStr}"
|
||
);
|
||
|
||
in
|
||
module.config.home.activationPackage
|