nixos-config/lib/utils/nixos.nix

52 lines
1.4 KiB
Nix
Raw Normal View History

{ lib }:
{
# This is only used for home-manager users without a NixOS user counterpart.
mapHomeManagerUser = user: settings:
2025-01-12 09:57:14 +00:00
let homeDirectory = "/home/${user}";
in ({ lib, ... }: {
home-manager.users."${user}" = { ... }: {
imports = [
{
home.username = user;
home.homeDirectory = homeDirectory;
}
../../configs/home-manager/${user}
];
};
users.users."${user}" = lib.mkMerge [
2024-07-27 12:20:10 +00:00
{
extraGroups = lib.mkDefault [ "wheel" ];
createHome = lib.mkDefault true;
home = lib.mkDefault homeDirectory;
isNormalUser = lib.mkForce true;
}
settings
];
});
/* Returns the file path of the given config of the given environment.
Type: getConfig :: String -> String -> Path
Example:
getConfig "home-manager" "foo-dogsquared"
=> ../configs/home-manager/foo-dogsquared
*/
getConfig = type: config: ../../configs/${type}/${config};
/* Returns the file path of the given user subpart of the given
environment. Only certain environments such as NixOS have this type of
setup.
Type: getConfig :: String -> String -> Path
Example:
getUser "nixos" "foo-dogsquared"
=> ../configs/nixos/_users/foo-dogsquared
*/
getUser = type: user: ../../configs/${type}/_users/${user};
}