mirror of
https://github.com/nix-community/home-manager.git
synced 2026-06-05 21:02:51 +00:00
`SSH_AUTH_SOCK` is exported in shells only, which systemd does not inherit from. With this commit, it is also set in systemd such that systemd-managed applications can access the SSH agent by declaring dependencies onto 'sshAuthSock.systemd.socketProviderUnit'. Closes #7971.
39 lines
1.3 KiB
Nix
39 lines
1.3 KiB
Nix
{ config, lib, ... }:
|
|
|
|
{
|
|
programs.bash.enable = true;
|
|
programs.fish.enable = true;
|
|
programs.nushell.enable = true;
|
|
programs.zsh.enable = true;
|
|
|
|
sshAuthSock = {
|
|
enable = true;
|
|
initialization = {
|
|
bash = "echo bash/zsh";
|
|
fish = "echo fish";
|
|
nushell = "echo nushell";
|
|
};
|
|
systemd.socketProviderUnit = "foo.socket";
|
|
};
|
|
|
|
nmt.script = ''
|
|
assertFileContains \
|
|
home-files/.profile \
|
|
'if [ -z "$SSH_AUTH_SOCK" -o -z "$SSH_CONNECTION" ]; then'
|
|
assertFileContains \
|
|
home-files/.config/fish/config.fish \
|
|
'if test -z "$SSH_AUTH_SOCK"; or test -z "$SSH_CONNECTION"'
|
|
assertFileContains \
|
|
home-files/.config/nushell/config.nu \
|
|
'if ("SSH_AUTH_SOCK" not-in $env) or ($env.SSH_AUTH_SOCK | is-empty) or ("SSH_CONNECTION" not-in $env) or ($env.SSH_CONNECTION | is-empty) {'
|
|
assertFileContains \
|
|
home-files/.zshenv \
|
|
'if [ -z "$SSH_AUTH_SOCK" -o -z "$SSH_CONNECTION" ]; then'
|
|
''
|
|
+ lib.optionalString config.systemd.user.enable ''
|
|
assertFileExists home-files/.config/systemd/user/set-SSH_AUTH_SOCK.service
|
|
assertFileContains home-files/.config/systemd/user/set-SSH_AUTH_SOCK.service 'Before=foo.socket'
|
|
assertFileContains home-files/.config/systemd/user/set-SSH_AUTH_SOCK.service 'WantedBy=foo.socket'
|
|
'';
|
|
}
|