nixos-config/utils/getInternalIP.nix

12 lines
409 B
Nix
Raw Normal View History

2022-01-15 09:55:15 +00:00
config:
let
removeCIDR = cidr: builtins.elemAt (builtins.split "/" cidr) 0;
2022-01-15 13:44:34 +00:00
filterIPsBare = cidrs: builtins.map removeCIDR cidrs;
2022-01-15 09:55:15 +00:00
filterIPs = cidrs: builtins.map (f: "[${removeCIDR f}]") cidrs;
in
rec {
listenIPs = filterIPs config.networking.wireguard.interfaces."wg0".ips;
2022-01-15 13:44:34 +00:00
listenIPsBare = filterIPsBare config.networking.wireguard.interfaces."wg0".ips;
2022-01-15 09:55:15 +00:00
listenIP = builtins.elemAt listenIPs 0;
}