From 65116f97fcc597187930ee04acc296a747f632d3 Mon Sep 17 00:00:00 2001 From: Atemu Date: Wed, 10 Jun 2026 15:05:12 +0200 Subject: [PATCH] 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.) --- nixos/modules/config/xdg/autostart.nix | 36 +++++++++++++++++--------- 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/nixos/modules/config/xdg/autostart.nix b/nixos/modules/config/xdg/autostart.nix index 8310c377d43b..46c90ae1793a 100644 --- a/nixos/modules/config/xdg/autostart.nix +++ b/nixos/modules/config/xdg/autostart.nix @@ -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" + ); + }; }