1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-03-19 23:03:01 +00:00
home-manager/tests/modules/home-environment/session-variables.nix
Thiago Kenji Okada db4386d686
home-environment: add line-break after sessionSearchVariables (#6596)
PR #6593 broke activation when `sessionVariablesExtra` is used, e.g.:
`services.ssh-agent` because it concatenate the strings without a line
break, so the resulting `hm-session-vars.sh` file became:

```bash
export XCURSOR_PATH="/etc/profiles/per-user/thiagoko/share/icons${XCURSOR_PATH:+:}$XCURSOR_PATH"if [ -z "$SSH_AUTH_SOCK" ]; then
  export SSH_AUTH_SOCK=$XDG_RUNTIME_DIR/ssh-agent
fi
```

This commit fixes it by enforcing a line break between
`sessionSearchVariables` and `sessionVariablesExtra`.
2025-03-09 12:57:44 -05:00

52 lines
1.3 KiB
Nix

{ config, pkgs, ... }:
let
inherit (pkgs.stdenv.hostPlatform) isDarwin;
linuxExpected = ''
# Only source this once.
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"
export V1="v1"
export V2="v2-v1"
export XDG_CACHE_HOME="/home/hm-user/.cache"
export XDG_CONFIG_HOME="/home/hm-user/.config"
export XDG_DATA_HOME="/home/hm-user/.local/share"
export XDG_STATE_HOME="/home/hm-user/.local/state"
'';
darwinExpected = ''
# Only source this once.
if [ -n "$__HM_SESS_VARS_SOURCED" ]; then return; fi
export __HM_SESS_VARS_SOURCED=1
export V1="v1"
export V2="v2-v1"
export XDG_CACHE_HOME="/home/hm-user/.cache"
export XDG_CONFIG_HOME="/home/hm-user/.config"
export XDG_DATA_HOME="/home/hm-user/.local/share"
export XDG_STATE_HOME="/home/hm-user/.local/state"
'';
expected = pkgs.writeText "expected"
(if isDarwin then darwinExpected else linuxExpected);
in {
config = {
home.sessionVariables = {
V1 = "v1";
V2 = "v2-${config.home.sessionVariables.V1}";
};
nmt.script = ''
assertFileExists home-path/etc/profile.d/hm-session-vars.sh
assertFileContent home-path/etc/profile.d/hm-session-vars.sh \
${expected}
'';
};
}