nixos-config/utils/getInternalIP.nix

10 lines
383 B
Nix
Raw Normal View History

2022-06-12 15:39:15 +00:00
config: let
2022-01-15 09:55:15 +00:00
removeCIDR = cidr: builtins.elemAt (builtins.split "/" cidr) 0;
2022-06-12 15:42:42 +00:00
filterIPsBare = builtins.map removeCIDR;
filterIPs = builtins.map (f: "[${removeCIDR f}]");
2022-06-12 15:39:15 +00:00
in rec {
2022-01-15 09:55:15 +00:00
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;
}