home-manager kat user refactor

This commit is contained in:
kat witch 2021-08-05 21:47:54 +01:00
parent b1f27aa74d
commit 1230ff387b
No known key found for this signature in database
GPG key ID: 1B477797DCA5EC72
13 changed files with 34 additions and 82 deletions

View file

@ -8,9 +8,9 @@
}@args: let
colorHelpers = import ./color-helpers.nix { inherit lib; };
lib = before // katlib // self;
katlib = with before; with katlib; with self;
katlib = with before; with katlib; with self;
{
inherit (colorHelpers) hextorgba;
hostImport = import ./host-import.nix { inherit lib; };
modList = import ./module-list.nix;
modList = import ./module-list.nix { inherit lib; };
}; in katlib

View file

@ -1,6 +1,15 @@
{ lib }: hostName: lib.filter builtins.pathExists [
{ lib }: hostName: with lib; filter builtins.pathExists [
(../../config/hosts + "/${hostName}/nixos.nix")
(../../config/trusted/hosts + "/${hostName}/nixos.nix")
../../config/trusted/profile
../../config/profiles/base
]
] ++ singleton {
options.home-manager.users = mkOption {
type = types.attrsOf (types.submoduleWith {
modules = filter builtins.pathExists [
(../../config/hosts + "/${hostName}/home.nix")
(../../config/trusted/hosts + "/${hostName}/home.nix")
];
});
};
}

View file

@ -1,8 +1,9 @@
{ modulesDir, defaultFile ? "default.nix", importAll ? false }:
{ lib }: { modulesDir, defaultFile ? "default.nix", importAll ? false }:
with builtins;
let
isModule = m: lib.isFunction m && (m.isModule or true);
filterAttrNamesToList = filter: set:
foldl' (a: b: a ++ b) [ ]
(map (e: if (filter e set.${e}) then [ e ] else [ ]) (attrNames set));
@ -20,7 +21,7 @@ let
in
{
inherit name;
value = if (isFunction m) && !importAll then value else m;
value = if lib.isFunction m && ! isModule m then m { inherit lib; } else if isModule m && !importAll then value else m;
})
files;
in