tmpfiles: add module

PR #1144
This commit is contained in:
dawidsowa 2020-04-30 15:54:54 +02:00 committed by Robert Helgesson
parent 69f8e47e9e
commit 0fe984d575
No known key found for this signature in database
GPG Key ID: 36BDAA14C2797E89
3 changed files with 52 additions and 0 deletions

2
.github/CODEOWNERS vendored
View File

@ -18,6 +18,8 @@
/modules/misc/submodule-support.nix @rycee
/modules/misc/tmpfiles.nix @dawidsowa
/modules/misc/xdg-mime-apps.nix @pacien
/modules/misc/xdg-user-dirs.nix @pacien

49
modules/misc/tmpfiles.nix Normal file
View File

@ -0,0 +1,49 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.systemd.user.tmpfiles;
in {
meta.maintainers = [ maintainers.dawidsowa ];
options.systemd.user.tmpfiles.rules = mkOption {
type = types.listOf types.str;
default = [ ];
example = [ "L /home/user/Documents - - - - /mnt/data/Documents" ];
description = ''
Rules for creating and cleaning up temporary files
automatically. See
<citerefentry>
<refentrytitle>tmpfiles.d</refentrytitle>
<manvolnum>5</manvolnum>
</citerefentry>
for the exact format.
'';
};
config = mkIf (cfg.rules != [ ]) {
xdg = {
dataFile."user-tmpfiles.d/home-manager.conf" = {
text = ''
# This file is created automatically and should not be modified.
# Please change the option systemd.user.tmpfiles.rules instead.
${concatStringsSep "\n" cfg.rules}
'';
onChange = "${pkgs.systemd}/bin/systemd-tmpfiles --user --create";
};
configFile = {
"systemd/user/basic.target.wants/systemd-tmpfiles-setup.service".source =
"${pkgs.systemd}/example/systemd/user/systemd-tmpfiles-setup.service";
"systemd/user/systemd-tmpfiles-setup.service".source =
"${pkgs.systemd}/example/systemd/user/systemd-tmpfiles-setup.service";
"systemd/user/timers.target.wants/systemd-tmpfiles-clean.timer".source =
"${pkgs.systemd}/example/systemd/user/systemd-tmpfiles-clean.timer";
"systemd/user/systemd-tmpfiles-clean.service".source =
"${pkgs.systemd}/example/systemd/user/systemd-tmpfiles-clean.service";
};
};
};
}

View File

@ -36,6 +36,7 @@ let
(loadModule ./misc/pam.nix { })
(loadModule ./misc/qt.nix { })
(loadModule ./misc/submodule-support.nix { })
(loadModule ./misc/tmpfiles.nix { condition = hostPlatform.isLinux; })
(loadModule ./misc/version.nix { })
(loadModule ./misc/xdg-mime.nix { condition = hostPlatform.isLinux; })
(loadModule ./misc/xdg-mime-apps.nix { condition = hostPlatform.isLinux; })