mirror of
https://github.com/LnL7/nix-darwin.git
synced 2025-03-31 04:04:45 +00:00
zsh: move environment variables to zshenv
This commit is contained in:
parent
af0579f4a1
commit
94fddd38af
2 changed files with 14 additions and 18 deletions
|
@ -3,7 +3,6 @@
|
||||||
with lib;
|
with lib;
|
||||||
|
|
||||||
let
|
let
|
||||||
|
|
||||||
cfg = config.programs.zsh;
|
cfg = config.programs.zsh;
|
||||||
|
|
||||||
zshVariables =
|
zshVariables =
|
||||||
|
@ -21,12 +20,10 @@ let
|
||||||
mkdir -p $out/bin
|
mkdir -p $out/bin
|
||||||
makeWrapper ${pkgs.zsh}/bin/zsh $out/bin/zsh
|
makeWrapper ${pkgs.zsh}/bin/zsh $out/bin/zsh
|
||||||
'';
|
'';
|
||||||
|
|
||||||
in
|
in
|
||||||
|
|
||||||
{
|
{
|
||||||
options = {
|
options = {
|
||||||
|
|
||||||
programs.zsh.enable = mkOption {
|
programs.zsh.enable = mkOption {
|
||||||
type = types.bool;
|
type = types.bool;
|
||||||
default = false;
|
default = false;
|
||||||
|
@ -105,7 +102,6 @@ in
|
||||||
default = false;
|
default = false;
|
||||||
description = "Enable zsh-syntax-highlighting.";
|
description = "Enable zsh-syntax-highlighting.";
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
|
@ -130,6 +126,13 @@ in
|
||||||
if [ -n "$__ETC_ZSHENV_SOURCED" ]; then return; fi
|
if [ -n "$__ETC_ZSHENV_SOURCED" ]; then return; fi
|
||||||
export __ETC_ZSHENV_SOURCED=1
|
export __ETC_ZSHENV_SOURCED=1
|
||||||
|
|
||||||
|
# Don't execute this file when running in a pure nix-shell.
|
||||||
|
if test -n "$IN_NIX_SHELL"; then return; fi
|
||||||
|
|
||||||
|
export PATH=${config.environment.systemPath}
|
||||||
|
${config.system.build.setEnvironment}
|
||||||
|
${config.environment.extraInit}
|
||||||
|
|
||||||
${cfg.shellInit}
|
${cfg.shellInit}
|
||||||
|
|
||||||
# Read system-wide modifications.
|
# Read system-wide modifications.
|
||||||
|
@ -147,6 +150,7 @@ in
|
||||||
__ETC_ZPROFILE_SOURCED=1
|
__ETC_ZPROFILE_SOURCED=1
|
||||||
|
|
||||||
${concatStringsSep "\n" zshVariables}
|
${concatStringsSep "\n" zshVariables}
|
||||||
|
${config.system.build.setAliases}
|
||||||
|
|
||||||
${cfg.loginShellInit}
|
${cfg.loginShellInit}
|
||||||
|
|
||||||
|
@ -165,12 +169,6 @@ in
|
||||||
${optionalString cfg.enableFzfGit "source ${fzfGit}"}
|
${optionalString cfg.enableFzfGit "source ${fzfGit}"}
|
||||||
${optionalString cfg.enableFzfHistory "source ${fzfHistory}"}
|
${optionalString cfg.enableFzfHistory "source ${fzfHistory}"}
|
||||||
|
|
||||||
# Don't execute this file when running in a nix-shell.
|
|
||||||
if test ''${IN_NIX_SHELL:-0} -eq 1; then
|
|
||||||
PS1='%F{green}%B[nix-shell:%~]%#%b%f '
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Only execute this file once per shell.
|
# Only execute this file once per shell.
|
||||||
if [ -n "$__ETC_ZSHRC_SOURCED" -o -n "$NOSYSZSHRC" ]; then return; fi
|
if [ -n "$__ETC_ZSHRC_SOURCED" -o -n "$NOSYSZSHRC" ]; then return; fi
|
||||||
__ETC_ZSHRC_SOURCED=1
|
__ETC_ZSHRC_SOURCED=1
|
||||||
|
@ -182,14 +180,8 @@ in
|
||||||
|
|
||||||
setopt HIST_IGNORE_DUPS SHARE_HISTORY HIST_FCNTL_LOCK
|
setopt HIST_IGNORE_DUPS SHARE_HISTORY HIST_FCNTL_LOCK
|
||||||
|
|
||||||
export PATH=${config.environment.systemPath}
|
|
||||||
${config.system.build.setEnvironment}
|
|
||||||
${config.system.build.setAliases}
|
|
||||||
|
|
||||||
${config.environment.extraInit}
|
|
||||||
${config.environment.interactiveShellInit}
|
${config.environment.interactiveShellInit}
|
||||||
${cfg.interactiveShellInit}
|
${cfg.interactiveShellInit}
|
||||||
${cfg.promptInit}
|
|
||||||
|
|
||||||
# Tell zsh how to find installed completions
|
# Tell zsh how to find installed completions
|
||||||
for p in ''${(z)NIX_PROFILES}; do
|
for p in ''${(z)NIX_PROFILES}; do
|
||||||
|
@ -203,6 +195,10 @@ in
|
||||||
"source ${pkgs.zsh-syntax-highlighting}/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh"
|
"source ${pkgs.zsh-syntax-highlighting}/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
${cfg.promptInit}
|
||||||
|
|
||||||
|
if test -n "$IN_NIX_SHELL"; then PS1='%F{green}%B[nix-shell:%~]%#%b%f '; fi
|
||||||
|
|
||||||
# Read system-wide modifications.
|
# Read system-wide modifications.
|
||||||
if test -f /etc/zshrc.local; then
|
if test -f /etc/zshrc.local; then
|
||||||
source /etc/zshrc.local
|
source /etc/zshrc.local
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
programs.zsh.enable = true;
|
programs.zsh.enable = true;
|
||||||
|
|
||||||
test = ''
|
test = ''
|
||||||
echo checking systemPath in /etc/zshrc >&2
|
echo checking systemPath in /etc/zshenv >&2
|
||||||
grep 'export PATH=${pkgs.hello}/bin' ${config.out}/etc/zshrc
|
grep 'export PATH=${pkgs.hello}/bin' ${config.out}/etc/zshenv
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue