mirror of
https://github.com/nix-community/home-manager.git
synced 2026-06-05 21:02:51 +00:00
sshAuthSock: add option for initialization in Zsh
Initialization in Zsh defaults to the Bash initialization code since Zsh is mostly Bash-compatible. This commit adds a dedicated Zsh initialization code option to make the defaulting behaviour transparent while also enabling overrides.
This commit is contained in:
committed by
Austin Horstman
parent
efe95f113a
commit
f4534a4f3c
@@ -37,6 +37,11 @@ in
|
||||
nushell = mkShellInitOption "nushell" // {
|
||||
example = "$env.SSH_AUTH_SOCK = $HOME/.ssh/agent.sock";
|
||||
};
|
||||
zsh = mkShellInitOption "zsh" // {
|
||||
example = "export SSH_AUTH_SOCK=$HOME/.ssh/agent.sock";
|
||||
default = cfg.initialization.bash;
|
||||
defaultText = lib.literalExpression "config.sshAuthSock.initialization.bash";
|
||||
};
|
||||
};
|
||||
|
||||
};
|
||||
@@ -45,11 +50,13 @@ in
|
||||
let
|
||||
# Preserve $SSH_AUTH_SOCK if it stems from a forwarded agent which is the
|
||||
# case if both $SSH_AUTH_SOCK and $SSH_CONNECTION are set.
|
||||
bashIntegration = ''
|
||||
mkShIntegration = code: ''
|
||||
if [ -z "$SSH_AUTH_SOCK" -o -z "$SSH_CONNECTION" ]; then
|
||||
${cfg.initialization.bash}
|
||||
${code}
|
||||
fi
|
||||
'';
|
||||
bashIntegration = mkShIntegration cfg.initialization.bash;
|
||||
zshIntegration = mkShIntegration cfg.initialization.zsh;
|
||||
fishIntegration = ''
|
||||
if test -z "$SSH_AUTH_SOCK"; or test -z "$SSH_CONNECTION"
|
||||
${cfg.initialization.fish}
|
||||
@@ -70,6 +77,6 @@ in
|
||||
programs.bash.profileExtra = lib.mkOrder 900 bashIntegration;
|
||||
programs.fish.shellInit = lib.mkOrder 900 fishIntegration;
|
||||
programs.nushell.extraConfig = lib.mkOrder 900 nushellIntegration;
|
||||
programs.zsh.envExtra = lib.mkOrder 900 bashIntegration;
|
||||
programs.zsh.envExtra = lib.mkOrder 900 zshIntegration;
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user