From 7f0726f4431b07c2ca3f2329bd356c5a81550354 Mon Sep 17 00:00:00 2001 From: hektor Date: Sat, 7 Feb 2026 12:00:07 +0100 Subject: [PATCH] fix: add ssh keys to agent for all hosts --- home/modules/ssh.nix | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/home/modules/ssh.nix b/home/modules/ssh.nix index 988d55a..0ee8c3e 100644 --- a/home/modules/ssh.nix +++ b/home/modules/ssh.nix @@ -18,20 +18,25 @@ in enable = true; enableDefaultConfig = false; - matchBlocks = lib.genAttrs hostsWithKeys ( - hostname: - let - hostConfig = outputs.nixosConfigurations.${hostname}.config; - publicHostname = hostConfig.ssh.publicHostname; - targetUser = hostConfig.ssh.username; - in - { - host = hostname; - user = targetUser; - } - // lib.optionalAttrs (publicHostname != "") { - hostname = publicHostname; - } - ); + matchBlocks = + lib.genAttrs hostsWithKeys ( + hostname: + let + hostConfig = outputs.nixosConfigurations.${hostname}.config; + inherit (hostConfig.ssh) publicHostname username; + in + { + host = hostname; + user = username; + } + // lib.optionalAttrs (publicHostname != "") { + hostname = publicHostname; + } + ) + // { + "*" = { + addKeysToAgent = "yes"; + }; + }; }; }