diff --git a/modules/lib/zsh.nix b/modules/lib/zsh.nix index 55fafc500..4cce0adb5 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 - ''"${v}"'' + ''"${lib.escape [ "\\" "\"" "`" ] v}"'' else if builtins.isList v then let shell = import ./shell.nix { inherit lib; }; diff --git a/tests/modules/programs/zsh/zshrc-content-priorities.nix b/tests/modules/programs/zsh/zshrc-content-priorities.nix index 6c87e602e..f160c7713 100644 --- a/tests/modules/programs/zsh/zshrc-content-priorities.nix +++ b/tests/modules/programs/zsh/zshrc-content-priorities.nix @@ -14,6 +14,11 @@ home = "$HOME/Documents"; quoted = ''/tmp/with "quotes"''; }; + localVariables = { + BACKTICK = "`literal`"; + QUOTED = ''value "quoted"''; + RUNTIME = "$HOME/bin"; + }; initContent = lib.mkMerge [ (lib.mkBefore '' @@ -54,6 +59,9 @@ HELPDIR="@zsh@/share/zsh/$ZSH_VERSION/help" + BACKTICK="\`literal\`" + QUOTED="value \"quoted\"" + RUNTIME="$HOME/bin" autoload -U compinit && compinit # History options should be set in .zshrc and after oh-my-zsh sourcing. # See https://github.com/nix-community/home-manager/issues/177.