58 lines
1.4 KiB
Nix
58 lines
1.4 KiB
Nix
|
{ lib, config, pkgs, ... }:
|
||
|
|
||
|
let
|
||
|
cfg = config.main_user;
|
||
|
in
|
||
|
{
|
||
|
options.main_user = {
|
||
|
enable = lib.mkEnableOption "enable user module";
|
||
|
|
||
|
isDesktopUser = lib.mkOption {
|
||
|
default = false;
|
||
|
example = true;
|
||
|
description = "Add additional user groups for desktop users";
|
||
|
};
|
||
|
|
||
|
userName = lib.mkOption {
|
||
|
default = "mainuser";
|
||
|
description = "username";
|
||
|
};
|
||
|
};
|
||
|
|
||
|
config = lib.mkIf cfg.enable {
|
||
|
users.users.${cfg.userName} = lib.mkMerge [
|
||
|
{
|
||
|
isNormalUser = true;
|
||
|
initialPassword = "password";
|
||
|
|
||
|
description = "main user";
|
||
|
shell = pkgs.zsh;
|
||
|
}
|
||
|
|
||
|
(lib.mkIf (!cfg.isDesktopUser) {
|
||
|
extraGroups = [
|
||
|
"wheel"
|
||
|
"networkmanager"
|
||
|
cfg.userName
|
||
|
];
|
||
|
})
|
||
|
(lib.mkIf cfg.isDesktopUser {
|
||
|
extraGroups = [
|
||
|
"wheel"
|
||
|
"networkmanager"
|
||
|
"corectrl"
|
||
|
cfg.userName
|
||
|
"video"
|
||
|
"audio"
|
||
|
# For android
|
||
|
"adbusers"
|
||
|
# For serial interfaces
|
||
|
"dialout"
|
||
|
# For docker
|
||
|
"docker"
|
||
|
];
|
||
|
})
|
||
|
];
|
||
|
};
|
||
|
}
|