modules: users: add to groups in single place

This commit is contained in:
Bruno BELANYI 2021-03-07 17:47:33 +00:00
parent 960f65f62c
commit 5b63b70958
2 changed files with 10 additions and 11 deletions

View file

@ -2,11 +2,6 @@
{ config, lib, ... }:
let
my = config.my;
groupIfExists = grp:
lib.lists.optional
(builtins.hasAttr grp config.users.groups)
grp;
groupsIfExist = grps: builtins.concatMap groupIfExists grps;
in
{
users.users.blog = {
@ -17,8 +12,4 @@ in
home = "/var/www/";
openssh.authorizedKeys.keys = [ my.secrets.drone.ssh.publicKey ];
};
users.users.ambroisie.extraGroups = groupsIfExist [
"media"
];
}

View file

@ -1,7 +1,12 @@
# User setup
{ config, pkgs, ... }:
{ config, lib, pkgs, ... }:
let
my = config.my;
groupIfExists = grp:
lib.lists.optional
(builtins.hasAttr grp config.users.groups)
grp;
groupsIfExist = grps: builtins.concatMap groupIfExists grps;
in
{
users.mutableUsers = false; # I want it to be declarative.
@ -13,7 +18,10 @@ in
description = "Bruno BELANYI";
isNormalUser = true;
shell = pkgs.zsh;
extraGroups = [ "wheel" ]; # Enable sudo for the user.
extraGroups = groupsIfExist [
"media" # access to media files
"wheel" # `sudo` for the user.
];
openssh.authorizedKeys.keys = with builtins; let
keyDir = ./ssh;
contents = readDir keyDir;