2019-10-24 02:20:38 +02:00
|
|
|
{ config, pkgs, lib, ... }:
|
|
|
|
with lib;
|
2023-06-01 14:02:57 +02:00
|
|
|
with types;
|
2019-10-24 02:20:38 +02:00
|
|
|
let
|
|
|
|
|
2023-06-01 14:02:57 +02:00
|
|
|
cfg = config.components.mainUser;
|
2019-10-24 02:20:38 +02:00
|
|
|
|
|
|
|
dockerGroup =
|
2019-12-20 05:54:26 +01:00
|
|
|
if (config.virtualisation.docker.enable) then [ "docker" ] else [ ];
|
2019-10-24 02:20:38 +02:00
|
|
|
|
2021-11-01 09:20:42 +01:00
|
|
|
vboxGroup =
|
|
|
|
if (config.virtualisation.virtualbox.host.enable) then
|
|
|
|
[ "vboxusers" ]
|
|
|
|
else
|
|
|
|
[ ];
|
|
|
|
|
|
|
|
in
|
|
|
|
{
|
2019-10-24 02:20:38 +02:00
|
|
|
|
2023-06-01 14:02:57 +02:00
|
|
|
options.components.mainUser = {
|
2019-10-24 02:20:38 +02:00
|
|
|
|
2023-06-01 14:02:57 +02:00
|
|
|
enable = mkEnableOption "enable mainUser for a system";
|
2019-10-24 02:20:38 +02:00
|
|
|
|
|
|
|
userName = mkOption {
|
2023-06-01 14:02:57 +02:00
|
|
|
type = str;
|
|
|
|
default = "palo";
|
2019-10-24 02:20:38 +02:00
|
|
|
description = ''
|
|
|
|
name of the main user
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
uid = mkOption {
|
2023-06-01 14:02:57 +02:00
|
|
|
type = int;
|
2019-10-24 02:20:38 +02:00
|
|
|
default = 1337;
|
|
|
|
description = ''
|
|
|
|
uid of main user
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
extraGroups = mkOption {
|
2019-12-20 05:54:26 +01:00
|
|
|
default = [ ];
|
2023-06-01 14:02:57 +02:00
|
|
|
type = listOf str;
|
2019-10-24 02:20:38 +02:00
|
|
|
description = ''
|
|
|
|
list of groups the main user should also be in
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
authorizedKeyFiles = mkOption {
|
2019-12-20 05:54:26 +01:00
|
|
|
default = [ ];
|
2023-06-01 14:02:57 +02:00
|
|
|
type = listOf str;
|
2019-10-24 02:20:38 +02:00
|
|
|
description = ''
|
|
|
|
list of keys allowed to login as this user
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
|
|
|
|
users = {
|
|
|
|
|
2024-02-16 22:21:05 +01:00
|
|
|
mutableUsers = lib.mkDefault true;
|
2023-06-01 12:08:59 +02:00
|
|
|
|
2019-10-24 02:20:38 +02:00
|
|
|
defaultUserShell = pkgs.zsh;
|
|
|
|
|
2023-06-01 12:08:59 +02:00
|
|
|
groups.mainUser.name = cfg.userName;
|
|
|
|
|
2019-10-24 02:20:38 +02:00
|
|
|
users.mainUser = {
|
2019-12-20 05:54:26 +01:00
|
|
|
isNormalUser = true;
|
|
|
|
name = cfg.userName;
|
|
|
|
uid = cfg.uid;
|
|
|
|
home = "/home/${cfg.userName}";
|
2019-10-24 02:20:38 +02:00
|
|
|
initialPassword = cfg.userName;
|
2024-06-10 16:21:52 +02:00
|
|
|
extraGroups = [ "wheel" "networkmanager" "transmission" "wireshark" "audio" "pipewire" "input" ]
|
2019-12-20 05:54:26 +01:00
|
|
|
++ dockerGroup ++ vboxGroup ++ cfg.extraGroups;
|
|
|
|
openssh.authorizedKeys.keyFiles = cfg.authorizedKeyFiles;
|
2023-01-07 21:11:25 +01:00
|
|
|
group = config.users.groups.mainUser.name;
|
|
|
|
};
|
|
|
|
|
2019-10-24 02:20:38 +02:00
|
|
|
};
|
2023-07-02 20:56:42 +02:00
|
|
|
|
2019-10-24 02:20:38 +02:00
|
|
|
};
|
|
|
|
}
|