60 lines
1.4 KiB
Nix
Executable file
60 lines
1.4 KiB
Nix
Executable file
{
|
|
pkgs,
|
|
lib,
|
|
config,
|
|
...
|
|
}: {
|
|
options = {
|
|
main-user = {
|
|
enable = lib.mkEnableOption "Enable main user";
|
|
name = lib.mkOption {
|
|
type = lib.types.str;
|
|
default = "default-user";
|
|
description = "Name of the user";
|
|
};
|
|
|
|
groups = lib.mkOption {
|
|
type = lib.types.listOf lib.types.str;
|
|
default = [];
|
|
description = "List of groups to add the user to";
|
|
};
|
|
|
|
sudo = lib.mkEnableOption "Should the user be in the sudoers group or not";
|
|
|
|
shell = lib.mkOption {
|
|
default = pkgs.zsh;
|
|
description = "The shell of the user";
|
|
};
|
|
|
|
home-manager = {
|
|
enable = lib.mkEnableOption "Enable home-manager for the user";
|
|
import =
|
|
lib.mkOption
|
|
{
|
|
description = "Import path. MUST BE SET IN CONFIGURATION.NIX";
|
|
};
|
|
};
|
|
};
|
|
};
|
|
|
|
config = lib.mkIf config.main-user.enable {
|
|
users.users.${config.main-user.name} = {
|
|
isNormalUser = true;
|
|
initialPassword = "1234";
|
|
description = "Main system user";
|
|
extraGroups =
|
|
[
|
|
"networkmanager"
|
|
"audio"
|
|
]
|
|
++ config.main-user.groups
|
|
++ (lib.lists.optional config.main-user.sudo "wheel");
|
|
|
|
shell = config.main-user.shell;
|
|
};
|
|
|
|
home-manager.users.${config.main-user.name} =
|
|
lib.mkIf config.main-user.home-manager.enable config.main-user.home-manager.import;
|
|
};
|
|
}
|