From 45ba086ea53102019f54fc18583f9b11d8224972 Mon Sep 17 00:00:00 2001 From: oxalica Date: Fri, 18 Jun 2021 21:10:26 +0800 Subject: [PATCH 1/3] 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. --- .../from_md/release-notes/rl-2205.section.xml | 9 ++++ .../manual/release-notes/rl-2205.section.md | 5 ++ .../services/x11/desktop-managers/none.nix | 49 +++++++++++++++++-- nixos/tests/all-tests.nix | 1 + nixos/tests/xmonad-xdg-autostart.nix | 35 +++++++++++++ 5 files changed, 94 insertions(+), 5 deletions(-) create mode 100644 nixos/tests/xmonad-xdg-autostart.nix diff --git a/nixos/doc/manual/from_md/release-notes/rl-2205.section.xml b/nixos/doc/manual/from_md/release-notes/rl-2205.section.xml index 1a6b09df2633..8c5db066ac44 100644 --- a/nixos/doc/manual/from_md/release-notes/rl-2205.section.xml +++ b/nixos/doc/manual/from_md/release-notes/rl-2205.section.xml @@ -1798,6 +1798,15 @@ configuration. + + + The option + services.xserver.desktopManager.runXdgAutostartIfNone + was added in order to automatically run XDG autostart files + for sessions without a desktop manager. This replaces helpers + like the dex package. + + A new module was added for the Envoy reverse proxy, providing diff --git a/nixos/doc/manual/release-notes/rl-2205.section.md b/nixos/doc/manual/release-notes/rl-2205.section.md index de1251104188..d29b7f70fffd 100644 --- a/nixos/doc/manual/release-notes/rl-2205.section.md +++ b/nixos/doc/manual/release-notes/rl-2205.section.md @@ -656,6 +656,11 @@ In addition to numerous new and upgraded packages, this release has the followin - The `services.stubby` module was converted to a [settings-style](https://github.com/NixOS/rfcs/blob/master/rfcs/0042-config-option.md) configuration. +- The option + [services.xserver.desktopManager.runXdgAutostartIfNone](#opt-services.xserver.desktopManager.runXdgAutostartIfNone) + was added in order to automatically run XDG autostart files for sessions without a desktop manager. + This replaces helpers like the `dex` package. + - A new module was added for the Envoy reverse proxy, providing the options `services.envoy.enable` and `services.envoy.settings`. - The option `services.duplicati.dataDir` has been added to allow changing the location of duplicati's files. diff --git a/nixos/modules/services/x11/desktop-managers/none.nix b/nixos/modules/services/x11/desktop-managers/none.nix index af7a376ae029..b5e498b67a01 100644 --- a/nixos/modules/services/x11/desktop-managers/none.nix +++ b/nixos/modules/services/x11/desktop-managers/none.nix @@ -1,7 +1,46 @@ +{ config, lib, pkgs, ... }: +with lib; +let + runXdgAutostart = config.services.xserver.desktopManager.runXdgAutostartIfNone; +in { - services.xserver.desktopManager.session = - [ { name = "none"; - start = ""; - } - ]; + options = { + services.xserver.desktopManager.runXdgAutostartIfNone = mkOption { + type = types.bool; + default = false; + description = '' + Whether to run XDG autostart files for sessions without a desktop manager + (with only a window manager), these sessions usually don't handle XDG + autostart files by default. + + Some services like and + use XDG autostart files to start. + If this option is not set to true and you are using + a window manager without a desktop manager, you need to manually start + them or running dex somewhere. + ''; + }; + }; + + config = mkMerge [ + { + services.xserver.desktopManager.session = [ + { + name = "none"; + start = optionalString runXdgAutostart '' + /run/current-system/systemd/bin/systemctl --user start xdg-autostart-if-no-desktop-manager.target + ''; + } + ]; + } + (mkIf runXdgAutostart { + systemd.user.targets.xdg-autostart-if-no-desktop-manager = { + description = "Run XDG autostart files"; + # From `plasma-workspace`, `share/systemd/user/plasma-workspace@.target`. + requires = [ "xdg-desktop-autostart.target" "graphical-session.target" ]; + before = [ "xdg-desktop-autostart.target" "graphical-session.target" ]; + bindsTo = [ "graphical-session.target" ]; + }; + }) + ]; } diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index cb68ef685300..477091b94e44 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -591,6 +591,7 @@ in xautolock = handleTest ./xautolock.nix {}; xfce = handleTest ./xfce.nix {}; xmonad = handleTest ./xmonad.nix {}; + xmonad-xdg-autostart = handleTest ./xmonad-xdg-autostart.nix {}; xrdp = handleTest ./xrdp.nix {}; xss-lock = handleTest ./xss-lock.nix {}; xterm = handleTest ./xterm.nix {}; diff --git a/nixos/tests/xmonad-xdg-autostart.nix b/nixos/tests/xmonad-xdg-autostart.nix new file mode 100644 index 000000000000..2577a9ce2ea1 --- /dev/null +++ b/nixos/tests/xmonad-xdg-autostart.nix @@ -0,0 +1,35 @@ +import ./make-test-python.nix ({ lib, ... }: { + name = "xmonad-xdg-autostart"; + meta.maintainers = with lib.maintainers; [ oxalica ]; + + nodes.machine = { pkgs, config, ... }: { + imports = [ ./common/x11.nix ./common/user-account.nix ]; + test-support.displayManager.auto.user = "alice"; + services.xserver.displayManager.defaultSession = "none+xmonad"; + services.xserver.windowManager.xmonad.enable = true; + services.xserver.desktopManager.runXdgAutostartIfNone = true; + + environment.systemPackages = [ + (pkgs.writeTextFile { + name = "test-xdg-autostart"; + destination = "/etc/xdg/autostart/test-xdg-autostart.desktop"; + text = '' + [Desktop Entry] + Name=test-xdg-autoatart + Type=Application + Terminal=false + Exec=${pkgs.coreutils}/bin/touch ${config.users.users.alice.home}/xdg-autostart-executed + ''; + }) + ]; + }; + + testScript = { nodes, ... }: + let + user = nodes.machine.config.users.users.alice; + in + '' + machine.wait_for_x() + machine.wait_for_file("${user.home}/xdg-autostart-executed") + ''; +}) From 3855e83c49fa2be185c88e56d6c56b40c165b103 Mon Sep 17 00:00:00 2001 From: oxalica Date: Fri, 18 Jun 2021 21:15:47 +0800 Subject: [PATCH 2/3] nixos/fcitx5: remove systemd service via XDG autostart files --- .../from_md/release-notes/rl-2205.section.xml | 14 ++++++++++++++ nixos/doc/manual/release-notes/rl-2205.section.md | 6 ++++++ nixos/modules/i18n/input-method/fcitx5.nix | 6 ------ 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/nixos/doc/manual/from_md/release-notes/rl-2205.section.xml b/nixos/doc/manual/from_md/release-notes/rl-2205.section.xml index 8c5db066ac44..e798996f4f4a 100644 --- a/nixos/doc/manual/from_md/release-notes/rl-2205.section.xml +++ b/nixos/doc/manual/from_md/release-notes/rl-2205.section.xml @@ -1807,6 +1807,20 @@ like the dex package. + + + When setting + i18n.inputMethod.enabled + to fcitx5, it no longer creates + coresponding systemd user services. It now relies on XDG + autostart files to start and work properly in your desktop + seesions. If your are using only a window manager without a + desktop manager, you need to enable + services.xserver.desktopManager.runXdgAutostartIfNone + or using the dex package to make + fcitx5 work. + + A new module was added for the Envoy reverse proxy, providing diff --git a/nixos/doc/manual/release-notes/rl-2205.section.md b/nixos/doc/manual/release-notes/rl-2205.section.md index d29b7f70fffd..fa0c3867e97d 100644 --- a/nixos/doc/manual/release-notes/rl-2205.section.md +++ b/nixos/doc/manual/release-notes/rl-2205.section.md @@ -661,6 +661,12 @@ In addition to numerous new and upgraded packages, this release has the followin was added in order to automatically run XDG autostart files for sessions without a desktop manager. This replaces helpers like the `dex` package. +- When setting [i18n.inputMethod.enabled](#opt-i18n.inputMethod.enabled) to `fcitx5`, + it no longer creates coresponding systemd user services. + It now relies on XDG autostart files to start and work properly in your desktop seesions. + If your are using only a window manager without a desktop manager, you need to enable + `services.xserver.desktopManager.runXdgAutostartIfNone` or using the `dex` package to make `fcitx5` work. + - A new module was added for the Envoy reverse proxy, providing the options `services.envoy.enable` and `services.envoy.settings`. - The option `services.duplicati.dataDir` has been added to allow changing the location of duplicati's files. diff --git a/nixos/modules/i18n/input-method/fcitx5.nix b/nixos/modules/i18n/input-method/fcitx5.nix index 414aabbbaa73..6fea28e22345 100644 --- a/nixos/modules/i18n/input-method/fcitx5.nix +++ b/nixos/modules/i18n/input-method/fcitx5.nix @@ -28,11 +28,5 @@ in { QT_IM_MODULE = "fcitx"; XMODIFIERS = "@im=fcitx"; }; - - systemd.user.services.fcitx5-daemon = { - enable = true; - script = "${fcitx5Package}/bin/fcitx5"; - wantedBy = [ "graphical-session.target" ]; - }; }; } From d67d4ee6a197dee4cb2306bdcd25b4a2b9d336c7 Mon Sep 17 00:00:00 2001 From: Thiago Kenji Okada Date: Sun, 17 Apr 2022 23:18:54 +0100 Subject: [PATCH 3/3] nixos/doc: fix typos --- nixos/doc/manual/from_md/release-notes/rl-2205.section.xml | 4 ++-- nixos/doc/manual/release-notes/rl-2205.section.md | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/nixos/doc/manual/from_md/release-notes/rl-2205.section.xml b/nixos/doc/manual/from_md/release-notes/rl-2205.section.xml index e798996f4f4a..29a63a454aba 100644 --- a/nixos/doc/manual/from_md/release-notes/rl-2205.section.xml +++ b/nixos/doc/manual/from_md/release-notes/rl-2205.section.xml @@ -1812,9 +1812,9 @@ When setting i18n.inputMethod.enabled to fcitx5, it no longer creates - coresponding systemd user services. It now relies on XDG + corresponding systemd user services. It now relies on XDG autostart files to start and work properly in your desktop - seesions. If your are using only a window manager without a + sessions. If you are using only a window manager without a desktop manager, you need to enable services.xserver.desktopManager.runXdgAutostartIfNone or using the dex package to make diff --git a/nixos/doc/manual/release-notes/rl-2205.section.md b/nixos/doc/manual/release-notes/rl-2205.section.md index fa0c3867e97d..c4fff8627d0c 100644 --- a/nixos/doc/manual/release-notes/rl-2205.section.md +++ b/nixos/doc/manual/release-notes/rl-2205.section.md @@ -662,9 +662,9 @@ In addition to numerous new and upgraded packages, this release has the followin This replaces helpers like the `dex` package. - When setting [i18n.inputMethod.enabled](#opt-i18n.inputMethod.enabled) to `fcitx5`, - it no longer creates coresponding systemd user services. - It now relies on XDG autostart files to start and work properly in your desktop seesions. - If your are using only a window manager without a desktop manager, you need to enable + it no longer creates corresponding systemd user services. + It now relies on XDG autostart files to start and work properly in your desktop sessions. + If you are using only a window manager without a desktop manager, you need to enable `services.xserver.desktopManager.runXdgAutostartIfNone` or using the `dex` package to make `fcitx5` work. - A new module was added for the Envoy reverse proxy, providing the options `services.envoy.enable` and `services.envoy.settings`.