nixos: define user limits
This commit is contained in:
+43
-14
@@ -1,7 +1,5 @@
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
users.users =
|
||||
let
|
||||
{ lib, ... }:
|
||||
let
|
||||
adminGroups = [
|
||||
"adm"
|
||||
"named"
|
||||
@@ -10,18 +8,49 @@
|
||||
"tuxcord"
|
||||
"wheel"
|
||||
];
|
||||
in
|
||||
{
|
||||
error = {
|
||||
|
||||
mkUser = name: uid: options: {
|
||||
users.users.${name} = {
|
||||
isNormalUser = true;
|
||||
shell = pkgs.fish;
|
||||
extraGroups = adminGroups;
|
||||
extraGroups = lib.optionals (options.admin or false) adminGroups;
|
||||
inherit uid;
|
||||
};
|
||||
|
||||
javalsai = {
|
||||
isNormalUser = true;
|
||||
shell = pkgs.zsh;
|
||||
extraGroups = adminGroups;
|
||||
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;
|
||||
}
|
||||
[
|
||||
{
|
||||
name = "error";
|
||||
options.admin = true;
|
||||
}
|
||||
{
|
||||
name = "javalsai";
|
||||
options.admin = true;
|
||||
}
|
||||
{
|
||||
name = "max";
|
||||
options.admin = true;
|
||||
}
|
||||
{
|
||||
name = "vectorum";
|
||||
}
|
||||
]
|
||||
).options
|
||||
|
||||
Reference in New Issue
Block a user