From 9052131aef8f2654ebcf39f0949ba28e104d959b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcial=20Gai=C3=9Fert?= Date: Thu, 13 Dec 2018 15:25:09 +0100 Subject: [PATCH] programs.zsh: option localVariables Add option "extraLocalVars" for additional local variable definitions in .zshrc, at the top of the file. Some zsh plugins/themes expect configuration in local variables before they are loaded (example: https://github.com/bhilburn/powerlevel9k). Exporting those clutters the environment and is unnecessary. --- modules/programs/zsh.nix | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/modules/programs/zsh.nix b/modules/programs/zsh.nix index d6e15e622..1b7ccf7a6 100644 --- a/modules/programs/zsh.nix +++ b/modules/programs/zsh.nix @@ -12,6 +12,7 @@ let relToDotDir "plugins" else ".zsh/plugins"; envVarsStr = config.lib.zsh.exportAll cfg.sessionVariables; + localVarsStr = config.lib.zsh.defineAll cfg.localVariables; aliasesStr = concatStringsSep "\n" ( mapAttrsToList (k: v: "alias ${k}='${v}'") cfg.shellAliases @@ -265,6 +266,15 @@ in default = {}; description = "Options to configure oh-my-zsh."; }; + + localVariables = mkOption { + type = types.attrs; + default = {}; + example = { POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=["dir" "vcs"]; }; + description = '' + Extra local variables defined at the top of .zshrc. + ''; + }; }; }; @@ -321,6 +331,8 @@ in ${getAttr cfg.defaultKeymap bindkeyCommands} ''} + ${localVarsStr} + ${concatStrings (map (plugin: '' path+="$HOME/${pluginsDir}/${plugin.name}" fpath+="$HOME/${pluginsDir}/${plugin.name}"