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.
This commit is contained in:
Luna Nova 2023-07-16 10:31:18 -07:00
parent 2fe81aa7e6
commit d47bb3261f
No known key found for this signature in database

View File

@ -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"
} &