From 2b03dc82bb1c47af32d90edc8ebeb887c93d9b7e Mon Sep 17 00:00:00 2001 From: Austin Horstman Date: Sun, 28 Sep 2025 14:38:55 -0500 Subject: [PATCH] lib/zsh: revert escapeShellArg in toZshValue Causes variables to be generated with single ticks breaking shell expansion. Signed-off-by: Austin Horstman --- modules/lib/zsh.nix | 2 +- tests/modules/programs/zsh/prezto.nix | 2 +- tests/modules/programs/zsh/session-variables.nix | 6 +++--- tests/modules/programs/zsh/session-variables.zshenv | 10 ++++++++++ 4 files changed, 15 insertions(+), 5 deletions(-) create mode 100644 tests/modules/programs/zsh/session-variables.zshenv diff --git a/modules/lib/zsh.nix b/modules/lib/zsh.nix index 26f0133d6..56fa7a161 100644 --- a/modules/lib/zsh.nix +++ b/modules/lib/zsh.nix @@ -7,7 +7,7 @@ rec { if builtins.isBool v then if v then "true" else "false" else if builtins.isString v then - lib.escapeShellArg v + ''"${v}"'' else if builtins.isList v then let shell = import ./shell.nix { inherit lib; }; diff --git a/tests/modules/programs/zsh/prezto.nix b/tests/modules/programs/zsh/prezto.nix index 9605218f7..9a22f6f65 100644 --- a/tests/modules/programs/zsh/prezto.nix +++ b/tests/modules/programs/zsh/prezto.nix @@ -36,6 +36,6 @@ assertFileContains home-files/.zshenv \ '. "/home/hm-user/.nix-profile/etc/profile.d/hm-session-vars.sh"' assertFileContains home-files/.zshenv \ - 'export FOO=bar' + 'export FOO="bar"' ''; } diff --git a/tests/modules/programs/zsh/session-variables.nix b/tests/modules/programs/zsh/session-variables.nix index 0c5ff6b6b..af37da227 100644 --- a/tests/modules/programs/zsh/session-variables.nix +++ b/tests/modules/programs/zsh/session-variables.nix @@ -1,10 +1,11 @@ -{ config, ... }: +{ config, lib, ... }: { programs.zsh = { enable = true; sessionVariables = { + PATH = "$HOME/bin:$PATH"; V1 = "v1"; V2 = "v2-${config.programs.zsh.sessionVariables.V1}"; }; @@ -12,7 +13,6 @@ nmt.script = '' assertFileExists home-files/.zshenv - assertFileRegex home-files/.zshenv 'export V1=v1' - assertFileRegex home-files/.zshenv 'export V2=v2-v1' + assertFileContent home-files/.zshenv ${./session-variables.zshenv} ''; } diff --git a/tests/modules/programs/zsh/session-variables.zshenv b/tests/modules/programs/zsh/session-variables.zshenv new file mode 100644 index 000000000..da36f4887 --- /dev/null +++ b/tests/modules/programs/zsh/session-variables.zshenv @@ -0,0 +1,10 @@ +# Environment variables +. "/home/hm-user/.nix-profile/etc/profile.d/hm-session-vars.sh" + +# Only source this once +if [[ -z "$__HM_ZSH_SESS_VARS_SOURCED" ]]; then + export __HM_ZSH_SESS_VARS_SOURCED=1 + export PATH="$HOME/bin:$PATH" +export V1="v1" +export V2="v2-v1" +fi