nixfiles/goodhm.nix
2021-03-29 15:22:47 -07:00

49 lines
997 B
Nix
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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 "warning: ${w}" 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