mirror of
https://github.com/nix-community/home-manager.git
synced 2026-06-05 21:02:51 +00:00
Use parameter expansion with a default value when checking Home Manager's session-variable sentinels. Users with zsh NO_UNSET or shell nounset enabled were seeing parameter-not-set errors before the generated session variables had a chance to export the sentinel variables. Update the home session-variable and zsh fixtures to cover the generated guards.
66 lines
1.8 KiB
Nix
66 lines
1.8 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 IS_EMPTY=""
|
|
export IS_FALSE="false"
|
|
export IS_TRUE="true"
|
|
export LOCALE_ARCHIVE_2_27="${config.i18n.glibcLocales}/lib/locale/locale-archive"
|
|
export V1="v1"
|
|
export V2="v2-v1"
|
|
export XDG_BIN_HOME="/home/hm-user/.local/bin"
|
|
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 IS_EMPTY=""
|
|
export IS_FALSE="false"
|
|
export IS_TRUE="true"
|
|
export TERMINFO_DIRS="/home/hm-user/.nix-profile/share/terminfo:$TERMINFO_DIRS''${TERMINFO_DIRS:+:}/usr/share/terminfo"
|
|
export V1="v1"
|
|
export V2="v2-v1"
|
|
export XDG_BIN_HOME="/home/hm-user/.local/bin"
|
|
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"
|
|
|
|
# reset TERM with new TERMINFO available (if any)
|
|
export TERM="$TERM"
|
|
'';
|
|
|
|
expected = pkgs.writeText "expected" (if isDarwin then darwinExpected else linuxExpected);
|
|
|
|
in
|
|
{
|
|
home.sessionVariables = {
|
|
V1 = "v1";
|
|
V2 = "v2-${config.home.sessionVariables.V1}";
|
|
IS_EMPTY = "";
|
|
IS_NULL = null;
|
|
IS_TRUE = true;
|
|
IS_FALSE = false;
|
|
};
|
|
|
|
nmt.script = ''
|
|
assertFileExists home-path/etc/profile.d/hm-session-vars.sh
|
|
assertFileContent home-path/etc/profile.d/hm-session-vars.sh \
|
|
${expected}
|
|
'';
|
|
}
|