sshAuthSock: for Zsh, initialize in .zprofile and .zshenv

This commit is contained in:
Benedikt Rips
2026-07-24 12:12:39 -05:00
committed by Austin Horstman
parent 40d502faf2
commit 079a3b5d1a
9 changed files with 35 additions and 1 deletions
+11 -1
View File
@@ -103,7 +103,17 @@ in
programs.bash.profileExtra = lib.mkOrder 900 bashIntegration; programs.bash.profileExtra = lib.mkOrder 900 bashIntegration;
programs.fish.shellInit = lib.mkOrder 900 fishIntegration; programs.fish.shellInit = lib.mkOrder 900 fishIntegration;
programs.nushell.extraConfig = lib.mkOrder 900 nushellIntegration; programs.nushell.extraConfig = lib.mkOrder 900 nushellIntegration;
programs.zsh.envExtra = lib.mkOrder 900 zshIntegration; programs.zsh = {
# Mimic how `home.sessionVariablesPackage` is sourced in the Zsh module
# to ensure that session variables which SSH_AUTH_SOCK might rely on are
# set.
envExtra = lib.mkOrder 900 ''
if [[ ! -o login ]]; then
${indentNonEmptyLines zshIntegration}
fi
'';
profileExtra = lib.mkOrder 900 zshIntegration;
};
# Replace this service by an environment generator as soon as they are # Replace this service by an environment generator as soon as they are
# available per-user. See https://github.com/systemd/systemd/issues/32423 # available per-user. See https://github.com/systemd/systemd/issues/32423
@@ -19,6 +19,9 @@
assertFileNotRegex \ assertFileNotRegex \
home-files/.zshenv \ home-files/.zshenv \
'SSH_AUTH_SOCK' 'SSH_AUTH_SOCK'
assertFileNotRegex \
home-files/.zprofile \
'SSH_AUTH_SOCK'
assertPathNotExists home-files/.config/systemd/user/set-SSH_AUTH_SOCK.service assertPathNotExists home-files/.config/systemd/user/set-SSH_AUTH_SOCK.service
''; '';
@@ -29,6 +29,9 @@
assertFileContains \ assertFileContains \
home-files/.zshenv \ home-files/.zshenv \
'if [ -z "$SSH_AUTH_SOCK" -o -z "$SSH_CONNECTION" ]; then' 'if [ -z "$SSH_AUTH_SOCK" -o -z "$SSH_CONNECTION" ]; then'
assertFileContains \
home-files/.zprofile \
'if [ -z "$SSH_AUTH_SOCK" -o -z "$SSH_CONNECTION" ]; then'
'' ''
+ lib.optionalString config.systemd.user.enable '' + lib.optionalString config.systemd.user.enable ''
assertFileExists home-files/.config/systemd/user/set-SSH_AUTH_SOCK.service assertFileExists home-files/.config/systemd/user/set-SSH_AUTH_SOCK.service
@@ -38,5 +38,8 @@
assertFileContains \ assertFileContains \
home-files/.zshenv \ home-files/.zshenv \
'export SSH_AUTH_SOCK="${bashDir}/proton-pass-agent"' 'export SSH_AUTH_SOCK="${bashDir}/proton-pass-agent"'
assertFileContains \
home-files/.zprofile \
'export SSH_AUTH_SOCK="${bashDir}/proton-pass-agent"'
''; '';
} }
@@ -18,5 +18,8 @@
assertFileContains \ assertFileContains \
home-files/.zshenv \ home-files/.zshenv \
'export SSH_AUTH_SOCK="$(@system_cmds@/bin/getconf DARWIN_USER_TEMP_DIR)/ssh-agent"' 'export SSH_AUTH_SOCK="$(@system_cmds@/bin/getconf DARWIN_USER_TEMP_DIR)/ssh-agent"'
assertFileContains \
home-files/.zprofile \
'export SSH_AUTH_SOCK="$(@system_cmds@/bin/getconf DARWIN_USER_TEMP_DIR)/ssh-agent"'
''; '';
} }
@@ -18,5 +18,8 @@
assertFileContains \ assertFileContains \
home-files/.zshenv \ home-files/.zshenv \
'export SSH_AUTH_SOCK="$XDG_RUNTIME_DIR/ssh-agent"' 'export SSH_AUTH_SOCK="$XDG_RUNTIME_DIR/ssh-agent"'
assertFileContains \
home-files/.zprofile \
'export SSH_AUTH_SOCK="$XDG_RUNTIME_DIR/ssh-agent"'
''; '';
} }
@@ -18,5 +18,8 @@
assertFileContains \ assertFileContains \
home-files/.zshenv \ home-files/.zshenv \
'export SSH_AUTH_SOCK="$XDG_RUNTIME_DIR/ssh-tpm-agent.sock"' 'export SSH_AUTH_SOCK="$XDG_RUNTIME_DIR/ssh-tpm-agent.sock"'
assertFileContains \
home-files/.zprofile \
'export SSH_AUTH_SOCK="$XDG_RUNTIME_DIR/ssh-tpm-agent.sock"'
''; '';
} }
@@ -18,5 +18,8 @@
assertFileContains \ assertFileContains \
home-files/.zshenv \ home-files/.zshenv \
'export SSH_AUTH_SOCK="/tmp/yubikey-agent.sock"' 'export SSH_AUTH_SOCK="/tmp/yubikey-agent.sock"'
assertFileContains \
home-files/.zprofile \
'export SSH_AUTH_SOCK="/tmp/yubikey-agent.sock"'
''; '';
} }
@@ -18,5 +18,8 @@
assertFileContains \ assertFileContains \
home-files/.zshenv \ home-files/.zshenv \
'export SSH_AUTH_SOCK="''${XDG_RUNTIME_DIR:-/run/user/$UID}/yubikey-agent/yubikey-agent.sock"' 'export SSH_AUTH_SOCK="''${XDG_RUNTIME_DIR:-/run/user/$UID}/yubikey-agent/yubikey-agent.sock"'
assertFileContains \
home-files/.zprofile \
'export SSH_AUTH_SOCK="''${XDG_RUNTIME_DIR:-/run/user/$UID}/yubikey-agent/yubikey-agent.sock"'
''; '';
} }