dotfiles/modules/os/core/user.nix
eriedaberrie eaa14b0412 Initial commit
Note: not the actual initial commit.

I swear I will stop repeatedly force pushing to this single commit eventually
ok.
2024-09-15 00:19:38 -07:00

58 lines
1.3 KiB
Nix

{ config, lib, self, inputs, ... }:
let
cfg = config.my.user;
in {
imports = [ inputs.home-manager.nixosModules.home-manager ];
options.my.user = {
username = lib.mkOption {
type = with lib.types; nullOr str;
default = null;
};
extraGroups = lib.mkOption {
type = with lib.types; listOf str;
default = [ ];
};
useDefaultGroups = lib.mkEnableOption null // {
default = true;
};
homeModule = lib.mkOption {
type = with lib.types; nullOr pathInStore;
default = null;
};
};
config = lib.mkIf (cfg.username != null) {
users.users.${cfg.username} = {
isNormalUser = true;
extraGroups = cfg.extraGroups ++ lib.optionals cfg.useDefaultGroups [
"wheel"
"video"
"disk"
"input"
];
};
home-manager = lib.mkIf (cfg.homeModule != null) {
backupFileExtension = "hm-bak";
useUserPackages = true;
useGlobalPkgs = true;
extraSpecialArgs = {inherit self inputs;};
users.${cfg.username} = _: {
imports = [
self.homeManagerModules.default
cfg.homeModule
];
home = {
inherit (cfg) username;
homeDirectory = "/home/${cfg.username}";
};
};
};
};
}