diff --git a/modules/programs/zsh/plugins/oh-my-zsh.nix b/modules/programs/zsh/plugins/oh-my-zsh.nix index 6b28df3a0..2f04ef2e5 100644 --- a/modules/programs/zsh/plugins/oh-my-zsh.nix +++ b/modules/programs/zsh/plugins/oh-my-zsh.nix @@ -13,10 +13,12 @@ let types ; - inherit (import ../lib.nix { inherit config lib; }) dotDirRel; + inherit (import ../lib.nix { inherit config lib; }) dotDirRel mkShellVarPathStr; cfg = config.programs.zsh; + shellVarPathArg = path: ''"${lib.escape [ "\\" "\"" "`" ] (mkShellVarPathStr path)}"''; + ohMyZshModule = types.submodule { options = { enable = lib.mkEnableOption "oh-my-zsh"; @@ -98,7 +100,7 @@ in ${optionalString ( cfg.oh-my-zsh.plugins != [ ] ) "plugins=(${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.custom != "") "ZSH_CUSTOM=${shellVarPathArg 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 ''; diff --git a/tests/modules/programs/zsh/default.nix b/tests/modules/programs/zsh/default.nix index b2c1ad89d..a18a9c3f6 100644 --- a/tests/modules/programs/zsh/default.nix +++ b/tests/modules/programs/zsh/default.nix @@ -20,6 +20,7 @@ zsh-history-path-zdotdir-variable = import ./history-path.nix "zdotdir-variable"; zsh-history-substring-search = ./history-substring-search.nix; zsh-legacy-warning = ./legacy-warning.nix; + zsh-oh-my-zsh-custom = ./oh-my-zsh-custom.nix; zsh-plugins-completions-renamed = ./plugins-completions-renamed.nix; zsh-siteFunctions-mkcd = ./siteFunctions-mkcd.nix; zsh-plugins = ./plugins.nix; diff --git a/tests/modules/programs/zsh/oh-my-zsh-custom.nix b/tests/modules/programs/zsh/oh-my-zsh-custom.nix new file mode 100644 index 000000000..d63b3e0aa --- /dev/null +++ b/tests/modules/programs/zsh/oh-my-zsh-custom.nix @@ -0,0 +1,31 @@ +{ + config = { + programs.zsh = { + enable = true; + + oh-my-zsh = { + enable = true; + custom = "$HOME/extra/zsh"; + theme = "sigma"; + }; + }; + + home.file.omz-zsh-theme = { + source = builtins.toFile "sigma.zsh-theme" '' + echo sigma + ''; + target = "extra/zsh/themes/sigma.zsh-theme"; + }; + + test.stubs = { + oh-my-zsh = { }; + zsh = { }; + }; + + nmt.script = '' + assertFileContains home-files/.zshrc 'ZSH_CUSTOM="$HOME/extra/zsh"' + assertFileContains home-files/.zshrc 'ZSH_THEME=sigma' + assertFileExists home-files/extra/zsh/themes/sigma.zsh-theme + ''; + }; +}