extract network functions into library module
1 file changed, 22 insertions(+), 0 deletions(-)
changed files
A lib/net.nix
@@ -0,0 +1,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 + ; +}