lib/net.nix (view raw)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | { lib }:
let
removeMask = (
a:
if builtins.isString a then builtins.head (lib.strings.splitString "/" a) else removeMask a.Address
);
isv6 = (lib.strings.hasInfix ":");
wrapv6 =
addr:
if isv6 addr then
if lib.hasPrefix "[" addr && lib.hasSuffix "]" addr then addr else "[" + addr + "]"
else
addr;
in
{
inherit
removeMask
isv6
wrapv6
;
}
|