40 lines
979 B
Nix
40 lines
979 B
Nix
{ config, lib, pkgs, ... }: with lib; let
|
|
|
|
userOpts = { name, config, ... }: {
|
|
options = {
|
|
homeSize = mkOption {
|
|
type = types.nullOr types.str;
|
|
description = "Size of user's home directory";
|
|
default = null;
|
|
};
|
|
homeProjectId = mkOption {
|
|
type = types.nullOr types.int;
|
|
description = "What project does this user's home directory belong to";
|
|
default = null;
|
|
};
|
|
};
|
|
config = {
|
|
};
|
|
};
|
|
|
|
in {
|
|
options = {
|
|
users.users = mkOption {
|
|
type = with types; attrsOf (submodule userOpts);
|
|
};
|
|
};
|
|
|
|
config = let
|
|
users' = lib.attrsets.filterAttrs (userName: user: user.homeSize != null) config.users.users;
|
|
in mkIf (users' != {}) {
|
|
programs.xfs_quota.projects = mapAttrs (userName: user: let
|
|
in {
|
|
id = user.homeProjectId;
|
|
fileSystem = "/";
|
|
path = user.home;
|
|
sizeSoftLimit = user.homeSize;
|
|
sizeHardLimit = user.homeSize;
|
|
}) users';
|
|
};
|
|
}
|