Files
home-manager/tests/modules/misc/ssh-auth-sock/socket-provider.nix
Austin Horstman e9cbe69850 sshAuthSock: avoid cycles for socket providers
PR #9420 added set-SSH_AUTH_SOCK.service and ordered it before sshAuthSock.systemd.socketProviderUnit. When that provider is a socket unit, systemd default dependencies already order the socket before sockets.target while service defaults place set-SSH_AUTH_SOCK.service after basic.target. That creates a sockets.target -> basic.target -> set-SSH_AUTH_SOCK.service -> provider.socket -> sockets.target cycle.

For gpg-agent this makes systemd drop gpg-agent-ssh.socket, leaving SSH_AUTH_SOCK pointing at the expected S.gpg-agent.ssh path but with no socket listening there.

Only order and install the environment service against non-socket providers. Socket providers still get SSH_AUTH_SOCK imported through default.target.

Fixes #9432.
2026-06-08 12:04:33 -05:00

23 lines
592 B
Nix

{ config, lib, ... }:
{
sshAuthSock = {
enable = true;
initialization = {
bash = "echo bash/zsh";
fish = "echo fish";
nushell = "echo nushell";
};
systemd.socketProviderUnit = "foo.socket";
};
nmt.script = lib.optionalString config.systemd.user.enable ''
serviceFile=home-files/.config/systemd/user/set-SSH_AUTH_SOCK.service
assertFileExists $serviceFile
assertFileContains $serviceFile 'WantedBy=default.target'
assertFileNotRegex $serviceFile 'Before=foo\.socket'
assertFileNotRegex $serviceFile 'WantedBy=foo\.socket'
'';
}