make host details like host_pubkey, wg-home.ip be optional

This commit is contained in:
2025-06-01 20:08:49 +00:00
parent ef4373f704
commit b11e329351
3 changed files with 7 additions and 3 deletions

View File

@@ -5,7 +5,10 @@ let
(hostName: hostCfg: (hostName: hostCfg:
# generate `root@servo`, `colin@servo`, `root@servo-hn`, `colin@servo-hn`, ... as a single attrset: # generate `root@servo`, `colin@servo`, `root@servo-hn`, `colin@servo-hn`, ... as a single attrset:
lib.foldl' (acc: alias: acc // { lib.foldl' (acc: alias: acc // {
"root@${alias}" = hostCfg.ssh.host_pubkey; "root@${alias}" = lib.mkIf (hostCfg.ssh.host_pubkey != null) hostCfg.ssh.host_pubkey;
# XXX: ALL `colin@` keys we propagate here are added as authorized keys, in hosts/common/home/ssh.nix.
# so only propagate the ones we want to authorize, here!
# (this is a confusing footgun, should be changed)
"colin@${alias}" = lib.mkIf (hostCfg.ssh.user_pubkey != null && hostCfg.ssh.authorized) hostCfg.ssh.user_pubkey; "colin@${alias}" = lib.mkIf (hostCfg.ssh.user_pubkey != null && hostCfg.ssh.authorized) hostCfg.ssh.user_pubkey;
}) })
{} {}

View File

@@ -18,7 +18,8 @@ let
''; '';
}; };
ssh.host_pubkey = mkOption { ssh.host_pubkey = mkOption {
type = types.str; type = types.nullOr types.str;
default = null;
description = '' description = ''
ssh pubkey which this host will present to connections initiated against it. ssh pubkey which this host will present to connections initiated against it.
e.g. "ssh-ed25519 AAAA<base64>". e.g. "ssh-ed25519 AAAA<base64>".

View File

@@ -44,7 +44,7 @@ let
vpn = if sandbox.net == "vpn" then vpn = if sandbox.net == "vpn" then
lib.findSingle (v: v.isDefault) null null (builtins.attrValues config.sane.vpn) lib.findSingle (v: v.isDefault) null null (builtins.attrValues config.sane.vpn)
else if sandbox.net == "vpn.wg-home" then else if sandbox.net == "vpn.wg-home" then
config.sane.vpn.wg-home config.sane.vpn.wg-home or null
else else
null null
; ;