fork/home-manager

git clone https://git.julia.blue/fork/home-manager

nicootmpfiles: use only `xdg.configFile`7ac2cd01

master
1.6 KiB49 linesraw
1{ config, lib, pkgs, ... }:
2
3with lib;
4
5let
6
7  cfg = config.systemd.user.tmpfiles;
8
9in {
10  meta.maintainers = [ maintainers.dawidsowa ];
11
12  options.systemd.user.tmpfiles.rules = mkOption {
13    type = types.listOf types.str;
14    default = [ ];
15    example = [ "L /home/user/Documents - - - - /mnt/data/Documents" ];
16    description = ''
17      Rules for creating and cleaning up temporary files
18      automatically. See
19      {manpage}`tmpfiles.d(5)`
20      for the exact format.
21    '';
22  };
23
24  config = mkIf (cfg.rules != [ ]) {
25    assertions = [
26      (hm.assertions.assertPlatform "systemd.user.tmpfiles" pkgs
27        platforms.linux)
28    ];
29
30    xdg.configFile = {
31      "user-tmpfiles.d/home-manager.conf" = {
32        text = ''
33          # This file is created automatically and should not be modified.
34          # Please change the option ‘systemd.user.tmpfiles.rules’ instead.
35          ${concatStringsSep "\n" cfg.rules}
36        '';
37        onChange = "${pkgs.systemd}/bin/systemd-tmpfiles --user --create";
38      };
39      "systemd/user/basic.target.wants/systemd-tmpfiles-setup.service".source =
40        "${pkgs.systemd}/example/systemd/user/systemd-tmpfiles-setup.service";
41      "systemd/user/systemd-tmpfiles-setup.service".source =
42        "${pkgs.systemd}/example/systemd/user/systemd-tmpfiles-setup.service";
43      "systemd/user/timers.target.wants/systemd-tmpfiles-clean.timer".source =
44        "${pkgs.systemd}/example/systemd/user/systemd-tmpfiles-clean.timer";
45      "systemd/user/systemd-tmpfiles-clean.service".source =
46        "${pkgs.systemd}/example/systemd/user/systemd-tmpfiles-clean.service";
47    };
48  };
49}