nixos/config/users.nix

47 lines
1.2 KiB
Nix
Raw Permalink Normal View History

2019-04-13 00:05:39 +02:00
{ config, lib, pkgs, ... }:
2019-02-26 13:44:40 +01:00
with lib;
2019-04-13 00:05:39 +02:00
let
administrators = user: {
name = user.name;
value = let
cfg = config.services;
passPath = "${config.machine.secretPath}/${user.name}";
in {
2019-02-26 13:44:40 +01:00
isNormalUser = true;
2019-04-13 00:05:39 +02:00
name = user.name;
uid = user.id;
home = builtins.toPath "/home/${user.name}";
2019-02-26 13:44:40 +01:00
createHome = true;
2019-04-13 00:05:39 +02:00
description = "Administrative user ${user.name}.";
group = user.name;
extraGroups = [ "audio" "wheel" "network" ]
++ (optionals cfg.xserver.enable ["input" "video"])
++ (optionals cfg.printing.enable [ "cups" "lp" ])
2019-09-06 11:38:02 +02:00
++ (optional config.virtualisation.docker.enable "docker");
2019-04-13 00:05:39 +02:00
shell = "${pkgs.zsh}/bin/zsh";
passwordFile = passPath;
openssh.authorizedKeys.keyFiles = optional
(cfg.openssh.enable && (builtins.pathExists "${passPath}.pub"))
"${passPath}.pub";
2019-02-26 13:44:40 +01:00
};
2019-04-13 00:05:39 +02:00
};
2019-04-13 00:05:39 +02:00
mkusergroup = user: {
name = user.name;
value = {
name = user.name;
gid = user.id;
members = [ user.name ];
};
};
in {
users = {
mutableUsers = false;
users = listToAttrs (map administrators config.machine.administrators);
groups = listToAttrs (map mkusergroup config.machine.administrators);
2019-02-26 13:44:40 +01:00
};
}