2019-10-24 02:20:38 +02:00
|
|
|
{ config, pkgs, lib, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.system.custom.mainUser;
|
|
|
|
|
|
|
|
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
|
|
|
|
2019-12-20 05:54:26 +01:00
|
|
|
vboxGroup = if (config.virtualisation.virtualbox.host.enable) then
|
|
|
|
[ "vboxusers" ]
|
|
|
|
else
|
|
|
|
[ ];
|
2019-10-24 02:20:38 +02:00
|
|
|
|
|
|
|
in {
|
|
|
|
|
|
|
|
options.system.custom.mainUser = {
|
|
|
|
|
|
|
|
enable = mkEnableOption "enable mainUser for a desktop system";
|
|
|
|
|
|
|
|
userName = mkOption {
|
2019-12-20 05:54:26 +01:00
|
|
|
type = with types; str;
|
2019-10-24 02:20:38 +02:00
|
|
|
description = ''
|
|
|
|
name of the main user
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
uid = mkOption {
|
2019-12-20 05:54:26 +01:00
|
|
|
type = with types; 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 = [ ];
|
2019-10-24 02:20:38 +02:00
|
|
|
type = with types; listOf str;
|
|
|
|
description = ''
|
|
|
|
list of groups the main user should also be in
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
authorizedKeyFiles = mkOption {
|
2019-12-20 05:54:26 +01:00
|
|
|
default = [ ];
|
2019-10-24 02:20:38 +02:00
|
|
|
type = with types; listOf str;
|
|
|
|
description = ''
|
|
|
|
list of keys allowed to login as this user
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
|
|
|
|
users = {
|
|
|
|
|
2019-12-20 05:54:26 +01:00
|
|
|
mutableUsers = true;
|
2019-10-24 02:20:38 +02:00
|
|
|
defaultUserShell = pkgs.zsh;
|
|
|
|
|
|
|
|
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;
|
2019-12-20 05:54:26 +01:00
|
|
|
extraGroups = [ "wheel" "networkmanager" "transmission" "wireshark" ]
|
|
|
|
++ dockerGroup ++ vboxGroup ++ cfg.extraGroups;
|
|
|
|
openssh.authorizedKeys.keyFiles = cfg.authorizedKeyFiles;
|
2019-10-24 02:20:38 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|