about summary refs log tree commit diff
path: root/nixos/modules
diff options
context:
space:
mode:
authorLuna Nova <git@lunnova.dev>2023-07-16 10:31:18 -0700
committergithub-actions[bot] <github-actions[bot]@users.noreply.github.com>2023-11-30 19:42:44 +0000
commitfc92afc3f0cef9138fe25008e6a04bc838292432 (patch)
treeba9e7f55e21345a60b91c07bd080d0a4e2de1c6f /nixos/modules
parent1d450276166762338e6da4a865356bd05c526d97 (diff)
nixos/i3: add updateSessionEnvironment option
Runs dbus-update-activation-environment and systemctl import-environment on session start
to ensure xdg portals work, and user services have correct PATH / XDG env vars.
Matches behavior of Plasma/Gnome sessions.

(cherry picked from commit d47bb3261f54f5285b0f0714cd4f3f7452f89017)
Diffstat (limited to 'nixos/modules')
-rw-r--r--nixos/modules/services/x11/window-managers/i3.nix15
1 files changed, 15 insertions, 0 deletions
diff --git a/nixos/modules/services/x11/window-managers/i3.nix b/nixos/modules/services/x11/window-managers/i3.nix
index 5bb73cd0bfb17..5b939e7fa602e 100644
--- a/nixos/modules/services/x11/window-managers/i3.nix
+++ b/nixos/modules/services/x11/window-managers/i3.nix
@@ -4,6 +4,10 @@ with lib;
 
 let
   cfg = config.services.xserver.windowManager.i3;
+  updateSessionEnvironmentScript = ''
+    systemctl --user import-environment PATH DISPLAY XAUTHORITY DESKTOP_SESSION XDG_CONFIG_DIRS XDG_DATA_DIRS XDG_RUNTIME_DIR XDG_SESSION_ID DBUS_SESSION_BUS_ADDRESS || true
+    dbus-update-activation-environment --systemd --all || true
+  '';
 in
 
 {
@@ -19,6 +23,15 @@ in
       '';
     };
 
+    updateSessionEnvironment = mkOption {
+      default = true;
+      type = types.bool;
+      description = lib.mdDoc ''
+        Whether to run dbus-update-activation-environment and systemctl import-environment before session start.
+        Required for xdg portals to function properly.
+      '';
+    };
+
     extraSessionCommands = mkOption {
       default     = "";
       type        = types.lines;
@@ -58,6 +71,8 @@ in
       start = ''
         ${cfg.extraSessionCommands}
 
+        ${lib.optionalString cfg.updateSessionEnvironment updateSessionEnvironmentScript}
+
         ${cfg.package}/bin/i3 ${optionalString (cfg.configFile != null)
           "-c /etc/i3/config"
         } &