2021-02-06 15:35:38 +01:00
|
|
|
# User setup
|
2021-03-07 18:47:33 +01:00
|
|
|
{ config, lib, pkgs, ... }:
|
2021-02-06 15:35:38 +01:00
|
|
|
let
|
2021-09-25 12:46:58 +02:00
|
|
|
secrets = config.age.secrets;
|
2021-05-29 21:14:28 +02:00
|
|
|
cfg = config.my.system.users;
|
2021-05-09 12:14:50 +02:00
|
|
|
groupExists = grp: builtins.hasAttr grp config.users.groups;
|
|
|
|
groupsIfExist = builtins.filter groupExists;
|
2021-02-06 15:35:38 +01:00
|
|
|
in
|
|
|
|
{
|
2021-05-29 21:14:28 +02:00
|
|
|
options.my.system.users = with lib; {
|
|
|
|
enable = my.mkDisableOption "user configuration";
|
|
|
|
};
|
|
|
|
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
|
|
users = {
|
|
|
|
mutableUsers = false; # I want it to be declarative.
|
|
|
|
|
|
|
|
users = {
|
|
|
|
root = {
|
2021-09-25 12:46:58 +02:00
|
|
|
passwordFile = secrets."users/root/hashed-password".path;
|
2021-05-29 21:14:28 +02:00
|
|
|
};
|
2021-02-06 15:35:38 +01:00
|
|
|
|
2021-06-25 20:40:34 +02:00
|
|
|
${config.my.user.name} = {
|
2021-09-25 12:46:58 +02:00
|
|
|
passwordFile = secrets."users/ambroisie/hashed-password".path;
|
2021-05-29 21:14:28 +02:00
|
|
|
description = "Bruno BELANYI";
|
|
|
|
isNormalUser = true;
|
|
|
|
shell = pkgs.zsh;
|
|
|
|
extraGroups = groupsIfExist [
|
|
|
|
"audio" # sound control
|
2023-06-08 13:53:17 +02:00
|
|
|
"docker" # usage of `docker` socket
|
2021-05-29 21:14:28 +02:00
|
|
|
"media" # access to media files
|
|
|
|
"networkmanager" # wireless configuration
|
|
|
|
"plugdev" # usage of ZSA keyboard tools
|
2022-01-12 18:22:43 +01:00
|
|
|
"podman" # usage of `podman` socket
|
2021-05-29 21:14:28 +02:00
|
|
|
"video" # screen control
|
|
|
|
"wheel" # `sudo` for the user.
|
|
|
|
];
|
|
|
|
openssh.authorizedKeys.keys = with builtins;
|
|
|
|
let
|
|
|
|
keyDir = ./ssh;
|
|
|
|
contents = readDir keyDir;
|
|
|
|
names = attrNames contents;
|
|
|
|
files = filter (name: contents.${name} == "regular") names;
|
|
|
|
keys = map (basename: readFile (keyDir + "/${basename}")) files;
|
|
|
|
in
|
|
|
|
keys;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2021-02-06 15:35:38 +01:00
|
|
|
};
|
|
|
|
}
|