@@ -56,25 +56,27 @@ with lib.types; {
56
56
config = mkIf cfg . enable ( {
57
57
networking . firewall . allowedUDPPorts = mkIf cfg . openPort [ cfg . port ] ;
58
58
59
- networking . "${ cfg . kind } " . interfaces = {
60
- "wg0" = {
61
- ips = [ ( builtins . head cfg . nodes . "${ hostname } " . ips ) ] ;
62
- mtu = cfg . mtu ;
63
- privateKeyFile = cfg . privateKeyFile ;
64
- listenPort = cfg . port ;
65
- peers = ( builtins . map ( l :
66
- let
67
- other = ( lib . head ( lib . remove hostname l ) ) ;
68
- other_node = cfg . nodes . "${ other } " ;
69
- in ( {
70
- name = other ;
71
- publicKey = ( ( cfg . publicKey ) other ) ;
72
- allowedIPs = ( other_node . ips ) ;
73
- persistentKeepalive = 25 ;
74
- endpoint = other_node . endpoint ;
75
- } ) ) our_connections ) ;
59
+ networking . "${ cfg . kind } " . interfaces =
60
+ let ips_name = if cfg . kind == "wireguard" then "ips" else "address" ;
61
+ in {
62
+ "wg0" = {
63
+ ${ ips_name } = [ ( builtins . head cfg . nodes . "${ hostname } " . ips ) ] ;
64
+ mtu = cfg . mtu ;
65
+ privateKeyFile = cfg . privateKeyFile ;
66
+ listenPort = cfg . port ;
67
+ peers = ( builtins . map ( l :
68
+ let
69
+ other = ( lib . head ( lib . remove hostname l ) ) ;
70
+ other_node = cfg . nodes . "${ other } " ;
71
+ in ( {
72
+ publicKey = ( ( cfg . publicKey ) other ) ;
73
+ allowedIPs = ( other_node . ips ) ;
74
+ persistentKeepalive = 25 ;
75
+ endpoint = other_node . endpoint ;
76
+ } // ( if cfg . kind == "wireguard" then { name = other ; } else { } ) ) )
77
+ our_connections ) ;
78
+ } ;
76
79
} ;
77
- } ;
78
80
79
81
} ) ;
80
82
}
0 commit comments