refactor!(tmpfiles): expand power upon tmpfiles by deabstracting

This returns tmpfiles to its original form. Turns out that
making something too simple gives it less power.
This commit is contained in:
Artur Manuel 2025-03-06 01:07:54 +00:00
commit 035fb24038
Signed by: amadaluzia
SSH key fingerprint: SHA256:Zwg7gBuZyaG48ucAZneJwltiXu0+tJb7c3lYt9AYlLg
20 changed files with 74 additions and 72 deletions

View file

@ -3,34 +3,34 @@
lib,
...
}: let
inherit (lib) types mkOption;
createTmpfilesEntries = entries: builtins.attrValues (builtins.mapAttrs (dest: path: "L+ %h/${dest} - - - - ${path}") entries);
inherit (lib.options) mkEnableOption mkOption;
inherit (lib.types) attrsOf listOf submodule str package;
users = config.alqueva.users;
in {
options.alqueva.users = mkOption {
type = types.attrsOf (types.submodule {
type = attrsOf (submodule {
options = {
tmpfiles = mkOption {
description = "tmpfiles";
type = types.attrsOf types.path;
default = {};
type = listOf str;
default = [];
};
packages = mkOption {
type = types.listOf types.package;
type = listOf package;
default = [];
description = "Packages installed to the the defined user.";
};
groups = mkOption {
type = types.listOf types.str;
type = listOf str;
default = [];
description = "Groups to add the defined user to.";
};
shell = mkOption {
type = types.package;
type = package;
default = config.programs.bash.package;
description = "Shell the user wants to use.";
};
enable = (lib.mkEnableOption "this user.") // {default = true;};
enable = (mkEnableOption "this user.") // {default = true;};
};
});
description = "Users to have on the system.";
@ -52,7 +52,7 @@ in {
systemd.user.tmpfiles.users =
builtins.mapAttrs (_: uc: {
rules = createTmpfilesEntries uc.tmpfiles;
rules = uc.tmpfiles;
})
enabledUsers;
};