···
23
+
systemd.tmpfiles.settings = mkOption {
24
+
description = lib.mdDoc ''
25
+
Declare systemd-tmpfiles rules to create, delete, and clean up volatile
26
+
and temporary files and directories.
28
+
Even though the service is called `*tmp*files` you can also create
33
+
"/var/lib/my-service/statefolder".d = {
41
+
type = types.attrsOf (types.attrsOf (types.attrsOf (types.submodule ({ name, config, ... }: {
42
+
options.type = mkOption {
46
+
description = lib.mdDoc ''
47
+
The type of operation to perform on the file.
49
+
The type consists of a single letter and optionally one or more
50
+
modifier characters.
52
+
Please see the upstream documentation for the available types and
54
+
<https://www.freedesktop.org/software/systemd/man/tmpfiles.d>
57
+
options.mode = mkOption {
61
+
description = lib.mdDoc ''
62
+
The file access mode to use when creating this file or directory.
65
+
options.user = mkOption {
69
+
description = lib.mdDoc ''
70
+
The user of the file.
72
+
This may either be a numeric ID or a user/group name.
74
+
If omitted or when set to `"-"`, the user and group of the user who
75
+
invokes systemd-tmpfiles is used.
78
+
options.group = mkOption {
82
+
description = lib.mdDoc ''
83
+
The group of the file.
85
+
This may either be a numeric ID or a user/group name.
87
+
If omitted or when set to `"-"`, the user and group of the user who
88
+
invokes systemd-tmpfiles is used.
91
+
options.age = mkOption {
95
+
description = lib.mdDoc ''
96
+
Delete a file when it reaches a certain age.
98
+
If a file or directory is older than the current time minus the age
99
+
field, it is deleted.
101
+
If set to `"-"` no automatic clean-up is done.
104
+
options.argument = mkOption {
108
+
description = lib.mdDoc ''
109
+
An argument whose meaning depends on the type of operation.
111
+
Please see the upstream documentation for the meaning of this
112
+
parameter in different situations:
113
+
<https://www.freedesktop.org/software/systemd/man/tmpfiles.d>
systemd.tmpfiles.packages = mkOption {
type = types.listOf types.package;
···
${concatStringsSep "\n" cfg.rules}
199
+
] ++ (mapAttrsToList (name: paths:
200
+
pkgs.writeTextDir "lib/tmpfiles.d/${name}.conf" (concatStrings (mapAttrsToList (path: types:
201
+
concatStrings (mapAttrsToList (_type: entry: ''
202
+
'${entry.type}' '${path}' '${entry.mode}' '${entry.user}' '${entry.group}' '${entry.age}' ${entry.argument}
systemd.tmpfiles.rules = [
"d /nix/var 0755 root root - -"