lol

nixos/desktop-manager/none: add option to run XDG autostart files

`fcitx5` and `service.earlyoom` rely on use XDG autostart files to start.
But for X session with only window manager and no desktop manager
(`none` is used), no one can start them.

This options is added to run these autostart files for sessions without
desktop manager to make other services just work.

oxalica 45ba086e 671960c8

+94 -5
+9
nixos/doc/manual/from_md/release-notes/rl-2205.section.xml
··· 1800 1800 </listitem> 1801 1801 <listitem> 1802 1802 <para> 1803 + The option 1804 + <link linkend="opt-services.xserver.desktopManager.runXdgAutostartIfNone">services.xserver.desktopManager.runXdgAutostartIfNone</link> 1805 + was added in order to automatically run XDG autostart files 1806 + for sessions without a desktop manager. This replaces helpers 1807 + like the <literal>dex</literal> package. 1808 + </para> 1809 + </listitem> 1810 + <listitem> 1811 + <para> 1803 1812 A new module was added for the Envoy reverse proxy, providing 1804 1813 the options <literal>services.envoy.enable</literal> and 1805 1814 <literal>services.envoy.settings</literal>.
+5
nixos/doc/manual/release-notes/rl-2205.section.md
··· 656 656 657 657 - The `services.stubby` module was converted to a [settings-style](https://github.com/NixOS/rfcs/blob/master/rfcs/0042-config-option.md) configuration. 658 658 659 + - The option 660 + [services.xserver.desktopManager.runXdgAutostartIfNone](#opt-services.xserver.desktopManager.runXdgAutostartIfNone) 661 + was added in order to automatically run XDG autostart files for sessions without a desktop manager. 662 + This replaces helpers like the `dex` package. 663 + 659 664 - A new module was added for the Envoy reverse proxy, providing the options `services.envoy.enable` and `services.envoy.settings`. 660 665 661 666 - The option `services.duplicati.dataDir` has been added to allow changing the location of duplicati's files.
+44 -5
nixos/modules/services/x11/desktop-managers/none.nix
··· 1 + { config, lib, pkgs, ... }: 2 + with lib; 3 + let 4 + runXdgAutostart = config.services.xserver.desktopManager.runXdgAutostartIfNone; 5 + in 1 6 { 2 - services.xserver.desktopManager.session = 3 - [ { name = "none"; 4 - start = ""; 5 - } 6 - ]; 7 + options = { 8 + services.xserver.desktopManager.runXdgAutostartIfNone = mkOption { 9 + type = types.bool; 10 + default = false; 11 + description = '' 12 + Whether to run XDG autostart files for sessions without a desktop manager 13 + (with only a window manager), these sessions usually don't handle XDG 14 + autostart files by default. 15 + 16 + Some services like <option>i18n.inputMethod</option> and 17 + <option>service.earlyoom</option> use XDG autostart files to start. 18 + If this option is not set to <literal>true</literal> and you are using 19 + a window manager without a desktop manager, you need to manually start 20 + them or running <package>dex</package> somewhere. 21 + ''; 22 + }; 23 + }; 24 + 25 + config = mkMerge [ 26 + { 27 + services.xserver.desktopManager.session = [ 28 + { 29 + name = "none"; 30 + start = optionalString runXdgAutostart '' 31 + /run/current-system/systemd/bin/systemctl --user start xdg-autostart-if-no-desktop-manager.target 32 + ''; 33 + } 34 + ]; 35 + } 36 + (mkIf runXdgAutostart { 37 + systemd.user.targets.xdg-autostart-if-no-desktop-manager = { 38 + description = "Run XDG autostart files"; 39 + # From `plasma-workspace`, `share/systemd/user/plasma-workspace@.target`. 40 + requires = [ "xdg-desktop-autostart.target" "graphical-session.target" ]; 41 + before = [ "xdg-desktop-autostart.target" "graphical-session.target" ]; 42 + bindsTo = [ "graphical-session.target" ]; 43 + }; 44 + }) 45 + ]; 7 46 }
+1
nixos/tests/all-tests.nix
··· 591 591 xautolock = handleTest ./xautolock.nix {}; 592 592 xfce = handleTest ./xfce.nix {}; 593 593 xmonad = handleTest ./xmonad.nix {}; 594 + xmonad-xdg-autostart = handleTest ./xmonad-xdg-autostart.nix {}; 594 595 xrdp = handleTest ./xrdp.nix {}; 595 596 xss-lock = handleTest ./xss-lock.nix {}; 596 597 xterm = handleTest ./xterm.nix {};
+35
nixos/tests/xmonad-xdg-autostart.nix
··· 1 + import ./make-test-python.nix ({ lib, ... }: { 2 + name = "xmonad-xdg-autostart"; 3 + meta.maintainers = with lib.maintainers; [ oxalica ]; 4 + 5 + nodes.machine = { pkgs, config, ... }: { 6 + imports = [ ./common/x11.nix ./common/user-account.nix ]; 7 + test-support.displayManager.auto.user = "alice"; 8 + services.xserver.displayManager.defaultSession = "none+xmonad"; 9 + services.xserver.windowManager.xmonad.enable = true; 10 + services.xserver.desktopManager.runXdgAutostartIfNone = true; 11 + 12 + environment.systemPackages = [ 13 + (pkgs.writeTextFile { 14 + name = "test-xdg-autostart"; 15 + destination = "/etc/xdg/autostart/test-xdg-autostart.desktop"; 16 + text = '' 17 + [Desktop Entry] 18 + Name=test-xdg-autoatart 19 + Type=Application 20 + Terminal=false 21 + Exec=${pkgs.coreutils}/bin/touch ${config.users.users.alice.home}/xdg-autostart-executed 22 + ''; 23 + }) 24 + ]; 25 + }; 26 + 27 + testScript = { nodes, ... }: 28 + let 29 + user = nodes.machine.config.users.users.alice; 30 + in 31 + '' 32 + machine.wait_for_x() 33 + machine.wait_for_file("${user.home}/xdg-autostart-executed") 34 + ''; 35 + })