1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-27 05:29:46 +01:00

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.
This commit is contained in:
Marcial Gaißert 2018-12-13 15:25:09 +01:00 committed by Nikita Uvarov
parent 6b5e0efd1e
commit 9052131aef
No known key found for this signature in database
GPG key ID: F7A5FB3A7C10EF96

View file

@ -12,6 +12,7 @@ let
relToDotDir "plugins" else ".zsh/plugins"; relToDotDir "plugins" else ".zsh/plugins";
envVarsStr = config.lib.zsh.exportAll cfg.sessionVariables; envVarsStr = config.lib.zsh.exportAll cfg.sessionVariables;
localVarsStr = config.lib.zsh.defineAll cfg.localVariables;
aliasesStr = concatStringsSep "\n" ( aliasesStr = concatStringsSep "\n" (
mapAttrsToList (k: v: "alias ${k}='${v}'") cfg.shellAliases mapAttrsToList (k: v: "alias ${k}='${v}'") cfg.shellAliases
@ -265,6 +266,15 @@ in
default = {}; default = {};
description = "Options to configure oh-my-zsh."; 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 <filename>.zshrc</filename>.
'';
};
}; };
}; };
@ -321,6 +331,8 @@ in
${getAttr cfg.defaultKeymap bindkeyCommands} ${getAttr cfg.defaultKeymap bindkeyCommands}
''} ''}
${localVarsStr}
${concatStrings (map (plugin: '' ${concatStrings (map (plugin: ''
path+="$HOME/${pluginsDir}/${plugin.name}" path+="$HOME/${pluginsDir}/${plugin.name}"
fpath+="$HOME/${pluginsDir}/${plugin.name}" fpath+="$HOME/${pluginsDir}/${plugin.name}"