summaryrefslogtreecommitdiffstats
path: root/nixos/modules/config/xdg/autostart.nix
blob: 46c90ae1793a928feb9ac3e0d0f2ae9f57bb63b0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
{ config, lib, ... }:
{
  meta = {
    teams = [ lib.teams.freedesktop ];
  };

  options.xdg.autostart = {
    enable =
      lib.mkEnableOption "auto-starting of desktop applications according to the [XDG Autostart specification](https://specifications.freedesktop.org/autostart-spec/latest)."
      // lib.mkOption {
        default = true;
      };
    install =
      lib.mkEnableOption ''
        install desktop files following the [XDG Autostart specification](https://specifications.freedesktop.org/autostart-spec/latest) into `/etc/xdg/autostart/`.

        These are handled by your desktop environment or [`systemd-xdg-autostart-generator`](https://www.freedesktop.org/software/systemd/man/latest/systemd-xdg-autostart-generator.html).
      ''
      // lib.mkOption {
        default = true;
      };
  };

  config = {
    # FIXME this does not actually work because "/etc/xdg" is linked
    # unconditionally in `nixos/modules/config/system-path.nix`
    environment.pathsToLink = lib.mkIf config.xdg.autostart.install [
      "/etc/xdg/autostart"
    ];

    # On by default
    systemd.user.generators.systemd-xdg-autostart-generator = lib.mkIf (!config.xdg.autostart.enable) (
      lib.mkDefault "/dev/null"
    );
  };
}