Skip to content

Commit 87cc935

Browse files
committed
ssh-agent: set $SSH_AUTH_SOCK in non-interactive shells
Since PR #8099, the module sets `$SSH_AUTH_SOCK` through shells' options for interactive shell initialization instead of `home.sessionVariablesExtra`. The replacement was not faithful, however, since `home.sessionVariablesExtra` is sourced also in non-interactive shells. With this commit, the shells' profile options (where `home.sessionVariablesExtra` is sourced) are used to set `$SSH_AUTH_SOCK`. Fixes #8129.
1 parent ea164b7 commit 87cc935

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

modules/services/ssh-agent.nix

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,11 @@ in
8484
'';
8585
in
8686
{
87-
bash.initExtra = lib.mkIf cfg.enableBashIntegration bashIntegration;
88-
89-
zsh.initContent = lib.mkIf cfg.enableZshIntegration bashIntegration;
90-
91-
fish.interactiveShellInit = lib.mkIf cfg.enableFishIntegration fishIntegration;
92-
93-
nushell.extraConfig = lib.mkIf cfg.enableNushellIntegration nushellIntegration;
87+
# $SSH_AUTH_SOCK has to be set early since other tools rely on it
88+
bash.profileExtra = lib.mkIf cfg.enableBashIntegration (lib.mkOrder 900 bashIntegration);
89+
fish.shellInit = lib.mkIf cfg.enableFishIntegration (lib.mkOrder 900 fishIntegration);
90+
nushell.extraConfig = lib.mkIf cfg.enableNushellIntegration (lib.mkOrder 900 nushellIntegration);
91+
zsh.envExtra = lib.mkIf cfg.enableZshIntegration (lib.mkOrder 900 bashIntegration);
9492
};
9593
}
9694

tests/modules/services/ssh-agent/darwin/bash-integration.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
nmt.script = ''
1010
assertFileContains \
11-
home-files/.bashrc \
11+
home-files/.profile \
1212
'export SSH_AUTH_SOCK=$(@getconf-system_cmds@/bin/getconf DARWIN_USER_TEMP_DIR)/ssh-agent'
1313
'';
1414
}

0 commit comments

Comments
 (0)