1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-11-08 19:46:05 +01:00

lib/zsh: revert escapeShellArg in toZshValue

Causes variables to be generated with single ticks breaking shell
expansion.

Signed-off-by: Austin Horstman <khaneliman12@gmail.com>
This commit is contained in:
Austin Horstman 2025-09-28 14:38:55 -05:00
parent 64a809b198
commit 2b03dc82bb
4 changed files with 15 additions and 5 deletions

View file

@ -7,7 +7,7 @@ rec {
if builtins.isBool v then if builtins.isBool v then
if v then "true" else "false" if v then "true" else "false"
else if builtins.isString v then else if builtins.isString v then
lib.escapeShellArg v ''"${v}"''
else if builtins.isList v then else if builtins.isList v then
let let
shell = import ./shell.nix { inherit lib; }; shell = import ./shell.nix { inherit lib; };

View file

@ -36,6 +36,6 @@
assertFileContains home-files/.zshenv \ assertFileContains home-files/.zshenv \
'. "/home/hm-user/.nix-profile/etc/profile.d/hm-session-vars.sh"' '. "/home/hm-user/.nix-profile/etc/profile.d/hm-session-vars.sh"'
assertFileContains home-files/.zshenv \ assertFileContains home-files/.zshenv \
'export FOO=bar' 'export FOO="bar"'
''; '';
} }

View file

@ -1,10 +1,11 @@
{ config, ... }: { config, lib, ... }:
{ {
programs.zsh = { programs.zsh = {
enable = true; enable = true;
sessionVariables = { sessionVariables = {
PATH = "$HOME/bin:$PATH";
V1 = "v1"; V1 = "v1";
V2 = "v2-${config.programs.zsh.sessionVariables.V1}"; V2 = "v2-${config.programs.zsh.sessionVariables.V1}";
}; };
@ -12,7 +13,6 @@
nmt.script = '' nmt.script = ''
assertFileExists home-files/.zshenv assertFileExists home-files/.zshenv
assertFileRegex home-files/.zshenv 'export V1=v1' assertFileContent home-files/.zshenv ${./session-variables.zshenv}
assertFileRegex home-files/.zshenv 'export V2=v2-v1'
''; '';
} }

View file

@ -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