From a8ac7d88b25d1eafc49594af4db592d889705b65 Mon Sep 17 00:00:00 2001 From: Daniel Poelzleithner Date: Mon, 16 Oct 2023 21:13:15 +0200 Subject: [PATCH] home-manager: include hm-session-vars.sh in activation script The activation script should active the new environment. The new environments variable are not available yet. Source the environment file when activating --- modules/home-environment.nix | 3 ++- tests/modules/home-environment/session-variables-expected.txt | 2 +- tests/modules/home-environment/session-variables.nix | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/modules/home-environment.nix b/modules/home-environment.nix index 870464608..85746b780 100644 --- a/modules/home-environment.nix +++ b/modules/home-environment.nix @@ -551,7 +551,7 @@ in destination = "/etc/profile.d/hm-session-vars.sh"; text = '' # Only source this once. - if [ -n "$__HM_SESS_VARS_SOURCED" ]; then return; fi + if [ -n "''${__HM_SESS_VARS_SOURCED-}" ]; then return; fi export __HM_SESS_VARS_SOURCED=1 ${config.lib.shell.exportAll cfg.sessionVariables} @@ -715,6 +715,7 @@ in export PATH="${activationBinPaths}" ${config.lib.bash.initHomeManagerLib} + source ${config.home.sessionVariablesPackage}/etc/profile.d/hm-session-vars.sh ${builtins.readFile ./lib-bash/activation-init.sh} diff --git a/tests/modules/home-environment/session-variables-expected.txt b/tests/modules/home-environment/session-variables-expected.txt index a96f61956..cf8581e22 100644 --- a/tests/modules/home-environment/session-variables-expected.txt +++ b/tests/modules/home-environment/session-variables-expected.txt @@ -1,5 +1,5 @@ # Only source this once. -if [ -n "$__HM_SESS_VARS_SOURCED" ]; then return; fi +if [ -n "${__HM_SESS_VARS_SOURCED-}" ]; then return; fi export __HM_SESS_VARS_SOURCED=1 @exportLocaleVar@ export V1="v1" diff --git a/tests/modules/home-environment/session-variables.nix b/tests/modules/home-environment/session-variables.nix index e1c8bedf8..98526666e 100644 --- a/tests/modules/home-environment/session-variables.nix +++ b/tests/modules/home-environment/session-variables.nix @@ -6,7 +6,7 @@ let linuxExpected = '' # Only source this once. - if [ -n "$__HM_SESS_VARS_SOURCED" ]; then return; fi + if [ -n "''${__HM_SESS_VARS_SOURCED-}" ]; then return; fi export __HM_SESS_VARS_SOURCED=1 export LOCALE_ARCHIVE_2_27="${config.i18n.glibcLocales}/lib/locale/locale-archive" @@ -20,7 +20,7 @@ let darwinExpected = '' # Only source this once. - if [ -n "$__HM_SESS_VARS_SOURCED" ]; then return; fi + if [ -n "''${__HM_SESS_VARS_SOURCED-}" ]; then return; fi export __HM_SESS_VARS_SOURCED=1 export V1="v1"