zsh/oh-my-zsh: improve escaping of shell arguments

This commit is contained in:
Felix Stupp 2026-04-05 01:11:46 +00:00 committed by Austin Horstman
parent 46ecfa22a6
commit 89b2d575ee

View file

@ -5,7 +5,13 @@
...
}:
let
inherit (lib) mkOption optionalString types;
inherit (lib)
escapeShellArg
escapeShellArgs
mkOption
optionalString
types
;
inherit (import ../lib.nix { inherit config lib; }) dotDirRel;
@ -75,8 +81,8 @@ in
file = {
"${dotDirRel}/.zshenv".text = ''
ZSH="${cfg.oh-my-zsh.package}/share/oh-my-zsh";
ZSH_CACHE_DIR="${config.xdg.cacheHome}/oh-my-zsh";
ZSH=${escapeShellArg cfg.oh-my-zsh.package}/share/oh-my-zsh;
ZSH_CACHE_DIR=${escapeShellArg config.xdg.cacheHome}/oh-my-zsh;
'';
# Make sure we create a cache directory since some plugins expect it to exist
@ -91,9 +97,9 @@ in
# oh-my-zsh configuration generated by NixOS
${optionalString (
cfg.oh-my-zsh.plugins != [ ]
) "plugins=(${lib.concatStringsSep " " cfg.oh-my-zsh.plugins})"}
${optionalString (cfg.oh-my-zsh.custom != "") ''ZSH_CUSTOM="${cfg.oh-my-zsh.custom}"''}
${optionalString (cfg.oh-my-zsh.theme != "") ''ZSH_THEME="${cfg.oh-my-zsh.theme}"''}
) "plugins=(${lib.concatStringsSep " " (escapeShellArgs cfg.oh-my-zsh.plugins)})"}
${optionalString (cfg.oh-my-zsh.custom != "") "ZSH_CUSTOM=${escapeShellArg cfg.oh-my-zsh.custom}"}
${optionalString (cfg.oh-my-zsh.theme != "") "ZSH_THEME=${escapeShellArg cfg.oh-my-zsh.theme}"}
source $ZSH/oh-my-zsh.sh
'';
};