modules: services: wireguard: simplify

This commit is contained in:
Bruno BELANYI 2023-05-03 14:44:10 +00:00
parent 49b2cb9781
commit 2f3989bba1

View file

@ -8,16 +8,7 @@ let
secrets = config.age.secrets; secrets = config.age.secrets;
hostName = config.networking.hostName; hostName = config.networking.hostName;
peers = peers = {
let
mkPeer = name: attrs: {
inherit (attrs) clientNum publicKey;
privateKeyFile = secrets."wireguard/private-key".path;
} // lib.optionalAttrs (attrs ? externalIp) {
inherit (attrs) externalIp;
};
in
lib.mapAttrs mkPeer {
# "Server" # "Server"
porthos = { porthos = {
clientNum = 1; clientNum = 1;
@ -60,7 +51,7 @@ let
"${v4.subnet}.${toString thisPeer.clientNum}/${toString v4.mask}" "${v4.subnet}.${toString thisPeer.clientNum}/${toString v4.mask}"
"${v6.subnet}::${toString thisPeer.clientNum}/${toHexString v6.mask}" "${v6.subnet}::${toString thisPeer.clientNum}/${toHexString v6.mask}"
]; ];
inherit (thisPeer) privateKeyFile; privateKeyFile = secrets."wireguard/private-key".path;
peers = peers =
let let