nixos/xdg/autostart: actually disable generation of autostart units

This did not actually do anything when set to false.

Fixes https://github.com/NixOS/nixpkgs/issues/380166

I split this into two options that are independent of each other:

1. Whether to link the `systemPackages`' autostarts
2. Whether to enable their interpretation

(You can have interpretation of user-provided autostarts and the user could
interpret the system-provided autostarts.)
This commit is contained in:
Atemu
2026-06-10 16:11:36 +02:00
parent a799d3e388
commit 65116f97fc
+24 -12
View File
@@ -4,21 +4,33 @@
teams = [ lib.teams.freedesktop ];
};
options = {
xdg.autostart.enable = lib.mkOption {
type = lib.types.bool;
default = true;
description = ''
Whether to install files to support the
[XDG Autostart specification](https://specifications.freedesktop.org/autostart-spec/latest).
'';
};
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 = lib.mkIf config.xdg.autostart.enable {
environment.pathsToLink = [
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"
);
};
}