diff --git a/nixos/users.nix b/nixos/users.nix index 9cba1a7..eb74ada 100644 --- a/nixos/users.nix +++ b/nixos/users.nix @@ -1,27 +1,58 @@ -{ pkgs, ... }: -{ - users.users = - let - adminGroups = [ - "adm" - "named" - "networkmanager" - "nginx" - "tuxcord" - "wheel" - ]; - in +{ lib, ... }: +let + users = [ { - error = { - isNormalUser = true; - shell = pkgs.fish; - extraGroups = adminGroups; - }; + name = "error"; + options.admin = true; + } + { + name = "javalsai"; + options.admin = true; + } + { + name = "max"; + options.admin = true; + } + { + name = "vectorum"; + } + ]; - javalsai = { - isNormalUser = true; - shell = pkgs.zsh; - extraGroups = adminGroups; - }; + adminGroups = [ + "adm" + "named" + "networkmanager" + "nginx" + "tuxcord" + "wheel" + ]; + + mkUser = name: uid: options: { + users.users.${name} = { + isNormalUser = true; + extraGroups = lib.optionals (options.admin or false) adminGroups; + inherit uid; }; -} + + systemd.slices."user-${builtins.toString uid}".sliceConfig = { + CPUQuota = "50%"; + CPUWeight = "10"; + IOAccounting = true; + IOWeight = "10"; + MemoryMax = "2G"; + MemorySwapMax = "1G"; + TasksMax = "100"; + }; + }; +in +(builtins.foldl' + (attrs: user: { + options = lib.recursiveUpdate attrs.options (mkUser user.name attrs.uid (user.options or { })); + uid = attrs.uid + 1; + }) + { + options = { }; + uid = 1000; + } + users +).options