all repos — nixfiles @ 50c21877dc2515e2eeae20049baac08e03b9f3ef

System and user configuration, managed by nix and home-manager

extract network functions into library module

Alin
commit

50c21877dc2515e2eeae20049baac08e03b9f3ef

parent

58dffa0d966e07eefac139ecb4086a65acc7d6f8

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 + ; +}