[modules] vpn use hostName as fallback name
All checks were successful
Evaluate Hydra Jobs / eval-hydra-jobs (push) Successful in 4m46s
Evaluate Hydra Jobs / eval-hydra-jobs (pull_request) Successful in 4m44s

This commit is contained in:
2024-12-17 11:22:24 +01:00
parent 13d1f68bc2
commit c53efb04bc

View File

@@ -5,7 +5,7 @@ with lib;
let let
cfg = config.services.malobeo.vpn; cfg = config.services.malobeo.vpn;
peers = import ./peers.nix; peers = import ./peers.nix;
myPeer = peers.${cfg.name}; myPeer = if cfg.name == "" then peers.${config.networking.hostName} else peers.${cfg.name};
peerList = builtins.filter (peer: peer.role != myPeer.role) (builtins.attrValues peers); peerList = builtins.filter (peer: peer.role != myPeer.role) (builtins.attrValues peers);
peerListWithEndpoint = map (host: peerListWithEndpoint = map (host:
@@ -14,7 +14,12 @@ let
else else
host host
) peerList; ) peerList;
filteredPeerlist = map (host: builtins.removeAttrs host [ "role" "ips" "listenPort" "publicIp" ] ) peerListWithEndpoint; filteredPeerlist = map (host: builtins.removeAttrs host [
"role"
"ips"
"listenPort"
"publicIp"
] ) peerListWithEndpoint;
in in
{ {
options = { options = {
@@ -29,7 +34,7 @@ in
default = ""; default = "";
type = types.str; type = types.str;
description = '' description = ''
Name of the host in peers.nix Name of the host in peers.nix, if empty uses hostname
''; '';
}; };