Created mkHMUser function in lib

This commit is contained in:
Giulio De Pasquale 2022-10-14 00:41:18 +02:00
parent 45935b999e
commit 334a606f11
2 changed files with 23 additions and 5 deletions

View File

@ -1,5 +1,5 @@
{ pkgs, unstable, nixpkgs, nixos-unstable, home-manager, system, ... }: rec { { pkgs, unstable, nixpkgs, nixos-unstable, home-manager, system, ... }: rec {
user = import ./user.nix { inherit pkgs unstable system; }; user = import ./user.nix { inherit pkgs unstable system home-manager; };
host = import ./host.nix { host = import ./host.nix {
inherit pkgs nixpkgs unstable nixos-unstable home-manager user system; inherit pkgs nixpkgs unstable nixos-unstable home-manager user system;
}; };

View File

@ -1,4 +1,4 @@
{ pkgs, unstable, ... }: { pkgs, unstable, home-manager, ... }:
{ {
mkUser = { name, roles ? [ ] }: mkUser = { name, roles ? [ ] }:
@ -20,7 +20,25 @@
extraGroups = [ "wheel" "plugdev" ]; extraGroups = [ "wheel" "plugdev" ];
}; };
home-manager.users.${name}.imports = [ (mkRole "common") ] home-manager.users.${name}.imports = [ (mkRole "common") ] ++ roles_mod;
++ roles_mod; };
mkHMUser = { name, roles }:
let
mkRole = role: import (../roles/home + "/${role}.nix");
roles_mod = (map (r: mkRole r) roles);
in home-manager.lib.homeManagerConfiguration {
inherit pkgs;
modules = [
{
home = {
username = name;
homeDirectory =
if pkgs.stdenv.isLinux then "/home/${name}" else "/Users/${name}";
stateVersion = "22.05";
};
}
(mkRole "common")
] ++ roles_mod;
}; };
} }