···
752
+
systemd.tmpfiles.packages = mkOption {
753
+
type = types.listOf types.package;
755
+
example = literalExample "[ pkgs.lvm2 ]";
756
+
apply = map getLib;
758
+
List of packages containing <command>systemd-tmpfiles</command> rules.
760
+
All files ending in .conf found in
761
+
<filename><replaceable>pkg</replaceable>/lib/tmpfiles.d</filename>
763
+
If this folder does not exist or does not contain any files an error will be returned instead.
765
+
If a <filename>lib</filename> output is available, rules are searched there and only there.
766
+
If there is no <filename>lib</filename> output it will fall back to <filename>out</filename>
767
+
and if that does not exist either, the default output will be used.
systemd.user.units = mkOption {
description = "Definition of systemd per-user units.";
···
"sysctl.d/50-coredump.conf".source = "${systemd}/example/sysctl.d/50-coredump.conf";
"sysctl.d/50-default.conf".source = "${systemd}/example/sysctl.d/50-default.conf";
995
-
"tmpfiles.d/00-nixos.conf".text = ''
996
-
# This file is created automatically and should not be modified.
997
-
# Please change the option ‘systemd.tmpfiles.rules’ instead.
999
-
${concatStringsSep "\n" cfg.tmpfiles.rules}
1002
-
"tmpfiles.d/home.conf".source = "${systemd}/example/tmpfiles.d/home.conf";
1003
-
"tmpfiles.d/journal-nocow.conf".source = "${systemd}/example/tmpfiles.d/journal-nocow.conf";
1004
-
"tmpfiles.d/portables.conf".source = "${systemd}/example/tmpfiles.d/portables.conf";
1005
-
"tmpfiles.d/static-nodes-permissions.conf".source = "${systemd}/example/tmpfiles.d/static-nodes-permissions.conf";
1006
-
"tmpfiles.d/systemd.conf".source = "${systemd}/example/tmpfiles.d/systemd.conf";
1007
-
"tmpfiles.d/systemd-nologin.conf".source = "${systemd}/example/tmpfiles.d/systemd-nologin.conf";
1008
-
"tmpfiles.d/systemd-nspawn.conf".source = "${systemd}/example/tmpfiles.d/systemd-nspawn.conf";
1009
-
"tmpfiles.d/systemd-tmp.conf".source = "${systemd}/example/tmpfiles.d/systemd-tmp.conf";
1010
-
"tmpfiles.d/tmp.conf".source = "${systemd}/example/tmpfiles.d/tmp.conf";
1011
-
"tmpfiles.d/var.conf".source = "${systemd}/example/tmpfiles.d/var.conf";
1012
-
"tmpfiles.d/x11.conf".source = "${systemd}/example/tmpfiles.d/x11.conf";
1014
+
"tmpfiles.d".source = (pkgs.symlinkJoin {
1015
+
name = "tmpfiles.d";
1016
+
paths = cfg.tmpfiles.packages;
1018
+
for i in $(cat $pathsPath); do
1019
+
(test -d $i/lib/tmpfiles.d && test $(ls $i/lib/tmpfiles.d/*.conf | wc -l) -ge 1) || (
1020
+
echo "ERROR: The path $i was passed to systemd.tmpfiles.packages but either does not contain the folder lib/tmpfiles.d or if it contains that folder, there are no files ending in .conf in it."
1025
+
}) + "/lib/tmpfiles.d";
"systemd/system-generators" = { source = hooks "generators" cfg.generators; };
"systemd/system-shutdown" = { source = hooks "shutdown" cfg.shutdown; };
···
{ description = "Security Keys";
unitConfig.X-StopOnReconfiguration = true;
1046
+
systemd.tmpfiles.packages = [
1047
+
# Default tmpfiles rules provided by systemd
1048
+
(pkgs.runCommand "systemd-default-tmpfiles" {} ''
1049
+
mkdir -p $out/lib/tmpfiles.d
1050
+
cd $out/lib/tmpfiles.d
1052
+
ln -s "${systemd}/example/tmpfiles.d/home.conf"
1053
+
ln -s "${systemd}/example/tmpfiles.d/journal-nocow.conf"
1054
+
ln -s "${systemd}/example/tmpfiles.d/static-nodes-permissions.conf"
1055
+
ln -s "${systemd}/example/tmpfiles.d/systemd.conf"
1056
+
ln -s "${systemd}/example/tmpfiles.d/systemd-nologin.conf"
1057
+
ln -s "${systemd}/example/tmpfiles.d/systemd-nspawn.conf"
1058
+
ln -s "${systemd}/example/tmpfiles.d/systemd-tmp.conf"
1059
+
ln -s "${systemd}/example/tmpfiles.d/tmp.conf"
1060
+
ln -s "${systemd}/example/tmpfiles.d/var.conf"
1061
+
ln -s "${systemd}/example/tmpfiles.d/x11.conf"
1063
+
# User-specified tmpfiles rules
1064
+
(pkgs.writeTextFile {
1065
+
name = "nixos-tmpfiles.d";
1066
+
destination = "/lib/tmpfiles.d/00-nixos.conf";
1068
+
# This file is created automatically and should not be modified.
1069
+
# Please change the option ‘systemd.tmpfiles.rules’ instead.
1071
+
${concatStringsSep "\n" cfg.tmpfiles.rules}
mapAttrs' (n: v: nameValuePair "${n}.path" (pathToUnit n v)) cfg.paths