From 3346c7f455d34a3b7c704ceff8000a74960aa86d Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sat, 21 Oct 2017 14:37:30 +0200 Subject: [PATCH] xsession: prepare for session in `~/.xprofile` This works around the way NixOS starts up the systemd graphical session target. --- modules/xsession.nix | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/modules/xsession.nix b/modules/xsession.nix index 5c9ee7778..dde0a7fe6 100644 --- a/modules/xsession.nix +++ b/modules/xsession.nix @@ -58,6 +58,12 @@ in ''; }; + profileExtra = mkOption { + type = types.lines; + default = ""; + description = "Extra shell commands to run before session start."; + }; + initExtra = mkOption { type = types.lines; default = ""; @@ -139,14 +145,14 @@ in }; }; - home.file.".xsession" = { - mode = "555"; - text = '' + home.file.".xprofile".text = '' if [[ -e "$HOME/.profile" ]]; then . "$HOME/.profile" fi # If there are any running services from a previous session. + # Need to run this in xprofile because the NixOS xsession + # script starts up graphical-session.target. systemctl --user stop graphical-session.target graphical-session-pre.target systemctl --user import-environment DBUS_SESSION_BUS_ADDRESS @@ -157,6 +163,19 @@ in systemctl --user import-environment XDG_RUNTIME_DIR systemctl --user import-environment XDG_SESSION_ID + ${cfg.profileExtra} + + export HM_XPROFILE_SOURCED=1 + ''; + + home.file.".xsession" = { + mode = "555"; + text = '' + if [[ ! -v HM_XPROFILE_SOURCED ]]; then + . ~/.xprofile + fi + unset HM_XPROFILE_SOURCED + systemctl --user start hm-graphical-session.target ${cfg.initExtra}