From 66bcaa6e1bcaa34cc29776fb41f343e696e09fd6 Mon Sep 17 00:00:00 2001 From: lassulus Date: Wed, 5 Dec 2018 16:52:32 +0100 Subject: types host: cores can also be 0 --- lib/types.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/types.nix b/lib/types.nix index 0168533..41e7515 100644 --- a/lib/types.nix +++ b/lib/types.nix @@ -19,7 +19,7 @@ rec { default = config._module.args.name; }; cores = mkOption { - type = positive; + type = uint; }; nets = mkOption { type = attrsOf net; -- cgit v1.2.3 From 8a425161078af36d4bbc3af7a866af05cdfdcb29 Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 6 Dec 2018 22:12:50 +0100 Subject: tv xserver: xhost +SI:localuser:tv -LOCAL: --- tv/2configs/xserver/default.nix | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tv/2configs/xserver/default.nix b/tv/2configs/xserver/default.nix index 8d4b13f..1c05166 100644 --- a/tv/2configs/xserver/default.nix +++ b/tv/2configs/xserver/default.nix @@ -64,7 +64,10 @@ in { XMONAD_DATA_DIR = cfg.dataDir; XMONAD_STARTUP_HOOK = pkgs.writeDash "xmonad-startup-hook" '' - ${pkgs.xorg.xhost}/bin/xhost +LOCAL: & + { + ${pkgs.xorg.xhost}/bin/xhost +SI:localuser:${cfg.user.name} + ${pkgs.xorg.xhost}/bin/xhost -LOCAL: + } & ${pkgs.xorg.xmodmap}/bin/xmodmap ${import ./Xmodmap.nix args} & ${pkgs.xorg.xrdb}/bin/xrdb ${import ./Xresources.nix args} & ${pkgs.xorg.xsetroot}/bin/xsetroot -solid '#1c1c1c' & -- cgit v1.2.3 From 0a904df833d4ef1a7cfbcbb4d1738946a3029bfa Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 7 Dec 2018 13:16:41 +0100 Subject: lib.krebs: init --- lib/default.nix | 1 + lib/krebs/default.nix | 3 +++ 2 files changed, 4 insertions(+) create mode 100644 lib/krebs/default.nix diff --git a/lib/default.nix b/lib/default.nix index 348d47e..bf8c65e 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -5,6 +5,7 @@ let evalSource = import ./eval-source.nix; git = import ./git.nix { inherit lib; }; + krebs = import ./krebs lib; krops = import ../submodules/krops/lib; shell = import ./shell.nix { inherit lib; }; types = nixpkgs-lib.types // import ./types.nix { inherit lib; }; diff --git a/lib/krebs/default.nix b/lib/krebs/default.nix new file mode 100644 index 0000000..c9d9bef --- /dev/null +++ b/lib/krebs/default.nix @@ -0,0 +1,3 @@ +lib: +with lib; +mapNixDir (flip import lib) ./. -- cgit v1.2.3 From 232e4d8615cfe9f20915dec25f59679583e80183 Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 7 Dec 2018 13:17:16 +0100 Subject: lib.krebs.genipv6: init --- lib/krebs/genipv6.nix | 92 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 lib/krebs/genipv6.nix diff --git a/lib/krebs/genipv6.nix b/lib/krebs/genipv6.nix new file mode 100644 index 0000000..8d5ca16 --- /dev/null +++ b/lib/krebs/genipv6.nix @@ -0,0 +1,92 @@ +lib: +with lib; +let { + body = netname: subnetname: suffix: rec { + address = let + suffix' = + if hasEmptyGroup (parseAddress suffix) + then suffix + else joinAddress "::" suffix; + in + checkAddress addressLength (joinAddress subnetPrefix suffix'); + addressCIDR = "${address}/${toString addressLength}"; + addressLength = 128; + + inherit netname; + netCIDR = "${netAddress}/${toString netPrefixLength}"; + netAddress = joinAddress netPrefix "::"; + netHash = toString { + retiolum = 0; + wirelum = 1; + }.${netname}; + netPrefix = "42:${netHash}"; + netPrefixLength = { + retiolum = 32; + wirelum = 32; + }.${netname}; + + inherit subnetname; + subnetCIDR = "${subnetAddress}/${toString subnetPrefixLength}"; + subnetAddress = joinAddress subnetPrefix "::"; + subnetHash = hash subnetname; + subnetPrefix = joinAddress netPrefix subnetHash; + subnetPrefixLength = netPrefixLength + 16; + + inherit suffix; + suffixLength = addressLength - subnetPrefixLength; + }; + + hash = s: head (match "0*(.*)" (substring 0 4 (hashString "sha256" s))); + + dropLast = n: xs: reverseList (drop n (reverseList xs)); + takeLast = n: xs: reverseList (take n (reverseList xs)); + + hasEmptyPrefix = xs: take 2 xs == ["" ""]; + hasEmptySuffix = xs: takeLast 2 xs == ["" ""]; + hasEmptyInfix = xs: any (x: x == "") (trimEmpty 2 xs); + + hasEmptyGroup = xs: + any (p: p xs) [hasEmptyPrefix hasEmptyInfix hasEmptySuffix]; + + ltrimEmpty = n: xs: if hasEmptyPrefix xs then drop n xs else xs; + rtrimEmpty = n: xs: if hasEmptySuffix xs then dropLast n xs else xs; + trimEmpty = n: xs: rtrimEmpty n (ltrimEmpty n xs); + + parseAddress = splitString ":"; + formatAddress = concatStringsSep ":"; + + check = s: c: if !c then throw "${s}" else true; + + checkAddress = maxaddrlen: addr: let + parsedaddr = parseAddress addr; + normalizedaddr = trimEmpty 1 parsedaddr; + in + assert (check "address malformed; lone leading colon: ${addr}" ( + head parsedaddr == "" -> tail (take 2 parsedaddr) == "" + )); + assert (check "address malformed; lone trailing colon ${addr}" ( + last parsedaddr == "" -> head (takeLast 2 parsedaddr) == "" + )); + assert (check "address malformed; too many successive colons: ${addr}" ( + length (filter (x: x == "") normalizedaddr) > 1 -> addr == [""] + )); + assert (check "address malformed: ${addr}" ( + all (test "[0-9a-f]{0,4}") parsedaddr + )); + assert (check "address is too long: ${addr}" ( + length normalizedaddr * 16 <= maxaddrlen + )); + addr; + + joinAddress = prefix: suffix: let + parsedPrefix = parseAddress prefix; + parsedSuffix = parseAddress suffix; + normalizePrefix = rtrimEmpty 2 parsedPrefix; + normalizeSuffix = ltrimEmpty 2 parsedSuffix; + delimiter = + optional (length (normalizePrefix ++ normalizeSuffix) < 8 && + (hasEmptySuffix parsedPrefix || hasEmptyPrefix parsedSuffix)) + ""; + in + formatAddress (normalizePrefix ++ delimiter ++ normalizeSuffix); +} -- cgit v1.2.3 From 5f354c6209c26c981dbe61326ad776e5c387be0e Mon Sep 17 00:00:00 2001 From: lassulus Date: Sun, 9 Dec 2018 16:50:58 +0100 Subject: lib types nets: add wireguard --- lib/types.nix | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/lib/types.nix b/lib/types.nix index 41e7515..17c1688 100644 --- a/lib/types.nix +++ b/lib/types.nix @@ -192,6 +192,28 @@ rec { })); default = null; }; + wireguard = mkOption { + type = nullOr (submodule ({ config, ... }: { + options = { + port = mkOption { + type = int; + description = "tinc port to use to connect to host"; + default = 51820; + }; + pubkey = mkOption { + type = wireguard-pubkey; + }; + subnets = mkOption { + type = listOf cidr; + description = '' + wireguard subnets, + this defines how routing behaves for hosts that can't reach each other. + ''; + default = []; + }; + }; + })); + }; }; }); @@ -548,4 +570,6 @@ rec { check = filename.check; merge = mergeOneOption; }; + + wireguard-pubkey = str; } -- cgit v1.2.3 From 39fee0d617e393e35a73a69fe69564f3bfa86209 Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 9 Dec 2018 10:14:09 +0100 Subject: tv xmonad: cleanup service definition --- tv/2configs/xserver/default.nix | 45 +++++++++++++++++++---------------------- 1 file changed, 21 insertions(+), 24 deletions(-) diff --git a/tv/2configs/xserver/default.nix b/tv/2configs/xserver/default.nix index 1c05166..f68e8e6 100644 --- a/tv/2configs/xserver/default.nix +++ b/tv/2configs/xserver/default.nix @@ -48,34 +48,35 @@ in { systemd.services.xmonad = let xmonad = "${pkgs.haskellPackages.xmonad-tv}/bin/xmonad"; + xmonad-prepare = pkgs.writeDash "xmonad-prepare" '' + ${pkgs.coreutils}/bin/mkdir -p "$XMONAD_CACHE_DIR" + ${pkgs.coreutils}/bin/mkdir -p "$XMONAD_CONFIG_DIR" + ${pkgs.coreutils}/bin/mkdir -p "$XMONAD_DATA_DIR" + ''; + xmonad-ready = pkgs.writeDash "xmonad-ready" '' + { + ${pkgs.xorg.xhost}/bin/xhost +SI:localuser:${cfg.user.name} + ${pkgs.xorg.xhost}/bin/xhost -LOCAL: + } & + ${pkgs.xorg.xmodmap}/bin/xmodmap ${import ./Xmodmap.nix args} & + ${pkgs.xorg.xrdb}/bin/xrdb ${import ./Xresources.nix args} & + ${pkgs.xorg.xsetroot}/bin/xsetroot -solid '#1c1c1c' & + wait + ''; in { wantedBy = [ "graphical.target" ]; requires = [ "xserver.service" ]; environment = { DISPLAY = ":${toString config.services.xserver.display}"; - FZMENU_FZF_DEFAULT_OPTS = toString [ "--color=dark,border:126,bg+:090" "--inline-info" ]; - XMONAD_CACHE_DIR = cfg.cacheDir; XMONAD_CONFIG_DIR = cfg.configDir; XMONAD_DATA_DIR = cfg.dataDir; - - XMONAD_STARTUP_HOOK = pkgs.writeDash "xmonad-startup-hook" '' - { - ${pkgs.xorg.xhost}/bin/xhost +SI:localuser:${cfg.user.name} - ${pkgs.xorg.xhost}/bin/xhost -LOCAL: - } & - ${pkgs.xorg.xmodmap}/bin/xmodmap ${import ./Xmodmap.nix args} & - ${pkgs.xorg.xrdb}/bin/xrdb ${import ./Xresources.nix args} & - ${pkgs.xorg.xsetroot}/bin/xsetroot -solid '#1c1c1c' & - wait - ''; - - # XXX JSON is close enough :) - XMONAD_WORKSPACES0_FILE = pkgs.writeText "xmonad.workspaces0" (toJSON [ + XMONAD_STARTUP_HOOK = xmonad-ready; + XMONAD_WORKSPACES0_FILE = pkgs.writeJSON "xmonad-workspaces0.json" [ "Dashboard" # we start here "23" "cr" @@ -85,7 +86,7 @@ in { "mail" "stockholm" "za" "zh" "zj" "zs" - ]); + ]; }; path = [ config.tv.slock.package @@ -96,14 +97,10 @@ in { "/run/wrappers" # for su ]; serviceConfig = { - SyslogIdentifier = "xmonad"; - ExecStartPre = "${pkgs.coreutils}/bin/mkdir -p ${toString [ - "\${XMONAD_CACHE_DIR}" - "\${XMONAD_CONFIG_DIR}" - "\${XMONAD_DATA_DIR}" - ]}"; - ExecStart = "@${xmonad} xmonad-${currentSystem} "; + ExecStartPre = "@${xmonad-prepare} xmonad-prepare"; + ExecStart = "@${xmonad} xmonad-${currentSystem}"; ExecStop = "@${xmonad} xmonad-${currentSystem} --shutdown"; + SyslogIdentifier = "xmonad"; User = cfg.user.name; WorkingDirectory = cfg.user.home; }; -- cgit v1.2.3 From 9f0cb51c75ad234f275d5959178b68373312d5ed Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 11 Dec 2018 19:52:12 +0100 Subject: =?UTF-8?q?lib.krebs.genipv6=20hash:=200000=20->=200=20instead=20o?= =?UTF-8?q?f=20=CE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/krebs/genipv6.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/krebs/genipv6.nix b/lib/krebs/genipv6.nix index 8d5ca16..27df8bf 100644 --- a/lib/krebs/genipv6.nix +++ b/lib/krebs/genipv6.nix @@ -36,7 +36,7 @@ let { suffixLength = addressLength - subnetPrefixLength; }; - hash = s: head (match "0*(.*)" (substring 0 4 (hashString "sha256" s))); + hash = s: head (match "0*(.+)" (substring 0 4 (hashString "sha256" s))); dropLast = n: xs: reverseList (drop n (reverseList xs)); takeLast = n: xs: reverseList (take n (reverseList xs)); -- cgit v1.2.3 From 831e8c31150fd0aca583d40a6cef9ab5a6846fc2 Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 11 Dec 2018 21:37:52 +0100 Subject: lib.krebs.genipv6: can compute suffix from name --- lib/krebs/genipv6.nix | 38 ++++++++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/lib/krebs/genipv6.nix b/lib/krebs/genipv6.nix index 27df8bf..8e105ab 100644 --- a/lib/krebs/genipv6.nix +++ b/lib/krebs/genipv6.nix @@ -1,7 +1,7 @@ lib: with lib; let { - body = netname: subnetname: suffix: rec { + body = netname: subnetname: suffixSpec: rec { address = let suffix' = if hasEmptyGroup (parseAddress suffix) @@ -28,15 +28,45 @@ let { inherit subnetname; subnetCIDR = "${subnetAddress}/${toString subnetPrefixLength}"; subnetAddress = joinAddress subnetPrefix "::"; - subnetHash = hash subnetname; + subnetHash = simplify (hash 4 subnetname); subnetPrefix = joinAddress netPrefix subnetHash; subnetPrefixLength = netPrefixLength + 16; - inherit suffix; + suffix = getAttr (typeOf suffixSpec) { + set = + concatMapStringsSep + ":" + simplify + (stringToGroupsOf 4 (hash (suffixLength / 8) suffixSpec.hostName)); + string = suffixSpec; + }; suffixLength = addressLength - subnetPrefixLength; }; - hash = s: head (match "0*(.+)" (substring 0 4 (hashString "sha256" s))); + # Split string into list of chunks where each chunk is at most n chars long. + # The leftmost chunk might shorter. + # Example: stringToGroupsOf "123456" -> ["12" "3456"] + stringToGroupsOf = n: s: let + acc = + foldl' + (acc: c: if stringLength acc.chunk < n then { + chunk = acc.chunk + c; + chunks = acc.chunks; + } else { + chunk = c; + chunks = acc.chunks ++ [acc.chunk]; + }) + { + chunk = ""; + chunks = []; + } + (stringToCharacters s); + in + filter (x: x != []) ([acc.chunk] ++ acc.chunks); + + simplify = s: head (match "0*(.+)" s); + + hash = n: s: substring 0 n (hashString "sha256" s); dropLast = n: xs: reverseList (drop n (reverseList xs)); takeLast = n: xs: reverseList (take n (reverseList xs)); -- cgit v1.2.3 From 96cdd9c9fbf4f775d64ab2c8b27c1ef672f9752d Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 11 Dec 2018 21:59:41 +0100 Subject: lib.setAttr: RIP --- lib/default.nix | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/default.nix b/lib/default.nix index bf8c65e..54597e5 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -29,8 +29,6 @@ let listToAttrs (map (name: nameValuePair name set.${name}) (filter (flip hasAttr set) names)); - setAttr = name: value: set: set // { ${name} = value; }; - test = re: x: isString x && testString re x; testString = re: x: match re x != null; -- cgit v1.2.3 From 227cc9cab8b9ed6d6514b3fc48511b13803fa865 Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 11 Dec 2018 22:47:27 +0100 Subject: lib.normalize-ip6-addr: only normalize addrs w/o :: --- lib/default.nix | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/default.nix b/lib/default.nix index 54597e5..e352c7b 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -107,7 +107,11 @@ let in a: concatStringsSep ":" (map f (splitString ":" a)); in - a: toLower (group-zeros (drop-leading-zeros a)); + a: + toLower + (if test ".*::.*" a + then a + else group-zeros (drop-leading-zeros a)); }; in -- cgit v1.2.3 From a406dd55bf931d5de11280030bb8750f63b2c266 Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 11 Dec 2018 22:49:14 +0100 Subject: lib.krebs.genipv6: use normalize-ip6-addr --- lib/krebs/genipv6.nix | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/lib/krebs/genipv6.nix b/lib/krebs/genipv6.nix index 8e105ab..bf3ebab 100644 --- a/lib/krebs/genipv6.nix +++ b/lib/krebs/genipv6.nix @@ -3,18 +3,16 @@ with lib; let { body = netname: subnetname: suffixSpec: rec { address = let - suffix' = - if hasEmptyGroup (parseAddress suffix) - then suffix - else joinAddress "::" suffix; + suffix' = prependZeros suffixLength suffix; in - checkAddress addressLength (joinAddress subnetPrefix suffix'); + normalize-ip6-addr + (checkAddress addressLength (joinAddress subnetPrefix suffix')); addressCIDR = "${address}/${toString addressLength}"; addressLength = 128; inherit netname; netCIDR = "${netAddress}/${toString netPrefixLength}"; - netAddress = joinAddress netPrefix "::"; + netAddress = appendZeros netPrefixLength netPrefix; netHash = toString { retiolum = 0; wirelum = 1; @@ -27,22 +25,35 @@ let { inherit subnetname; subnetCIDR = "${subnetAddress}/${toString subnetPrefixLength}"; - subnetAddress = joinAddress subnetPrefix "::"; - subnetHash = simplify (hash 4 subnetname); + subnetAddress = appendZeros subnetPrefixLength subnetPrefix; + subnetHash = hash 4 subnetname; subnetPrefix = joinAddress netPrefix subnetHash; subnetPrefixLength = netPrefixLength + 16; suffix = getAttr (typeOf suffixSpec) { set = - concatMapStringsSep + concatStringsSep ":" - simplify - (stringToGroupsOf 4 (hash (suffixLength / 8) suffixSpec.hostName)); + (stringToGroupsOf 4 (hash (suffixLength / 4) suffixSpec.hostName)); string = suffixSpec; }; suffixLength = addressLength - subnetPrefixLength; }; + appendZeros = n: s: let + n' = n / 16; + zeroCount = n' - length parsedaddr; + parsedaddr = parseAddress s; + in + formatAddress (parsedaddr ++ map (const "0") (range 1 zeroCount)); + + prependZeros = n: s: let + n' = n / 16; + zeroCount = n' - length parsedaddr; + parsedaddr = parseAddress s; + in + formatAddress (map (const "0") (range 1 zeroCount) ++ parsedaddr); + # Split string into list of chunks where each chunk is at most n chars long. # The leftmost chunk might shorter. # Example: stringToGroupsOf "123456" -> ["12" "3456"] @@ -64,8 +75,6 @@ let { in filter (x: x != []) ([acc.chunk] ++ acc.chunks); - simplify = s: head (match "0*(.+)" s); - hash = n: s: substring 0 n (hashString "sha256" s); dropLast = n: xs: reverseList (drop n (reverseList xs)); -- cgit v1.2.3 From 8fb373ff9ca49299b6a8600fb9b181fb21989d1b Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 11 Dec 2018 23:21:42 +0100 Subject: lib: import generally useful stuff from genipv6 --- lib/default.nix | 27 +++++++++++++++++++++++++++ lib/krebs/genipv6.nix | 32 ++++---------------------------- 2 files changed, 31 insertions(+), 28 deletions(-) diff --git a/lib/default.nix b/lib/default.nix index e352c7b..64b2d48 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -112,6 +112,33 @@ let (if test ".*::.*" a then a else group-zeros (drop-leading-zeros a)); + + hashToLength = n: s: substring 0 n (hashString "sha256" s); + + dropLast = n: xs: reverseList (drop n (reverseList xs)); + takeLast = n: xs: reverseList (take n (reverseList xs)); + + # Split string into list of chunks where each chunk is at most n chars long. + # The leftmost chunk might shorter. + # Example: stringToGroupsOf "123456" -> ["12" "3456"] + stringToGroupsOf = n: s: let + acc = + foldl' + (acc: c: if stringLength acc.chunk < n then { + chunk = acc.chunk + c; + chunks = acc.chunks; + } else { + chunk = c; + chunks = acc.chunks ++ [acc.chunk]; + }) + { + chunk = ""; + chunks = []; + } + (stringToCharacters s); + in + filter (x: x != []) ([acc.chunk] ++ acc.chunks); + }; in diff --git a/lib/krebs/genipv6.nix b/lib/krebs/genipv6.nix index bf3ebab..af1df6d 100644 --- a/lib/krebs/genipv6.nix +++ b/lib/krebs/genipv6.nix @@ -26,7 +26,7 @@ let { inherit subnetname; subnetCIDR = "${subnetAddress}/${toString subnetPrefixLength}"; subnetAddress = appendZeros subnetPrefixLength subnetPrefix; - subnetHash = hash 4 subnetname; + subnetHash = hashToLength 4 subnetname; subnetPrefix = joinAddress netPrefix subnetHash; subnetPrefixLength = netPrefixLength + 16; @@ -34,7 +34,9 @@ let { set = concatStringsSep ":" - (stringToGroupsOf 4 (hash (suffixLength / 4) suffixSpec.hostName)); + (stringToGroupsOf + 4 + (hashToLength (suffixLength / 4) suffixSpec.hostName)); string = suffixSpec; }; suffixLength = addressLength - subnetPrefixLength; @@ -54,32 +56,6 @@ let { in formatAddress (map (const "0") (range 1 zeroCount) ++ parsedaddr); - # Split string into list of chunks where each chunk is at most n chars long. - # The leftmost chunk might shorter. - # Example: stringToGroupsOf "123456" -> ["12" "3456"] - stringToGroupsOf = n: s: let - acc = - foldl' - (acc: c: if stringLength acc.chunk < n then { - chunk = acc.chunk + c; - chunks = acc.chunks; - } else { - chunk = c; - chunks = acc.chunks ++ [acc.chunk]; - }) - { - chunk = ""; - chunks = []; - } - (stringToCharacters s); - in - filter (x: x != []) ([acc.chunk] ++ acc.chunks); - - hash = n: s: substring 0 n (hashString "sha256" s); - - dropLast = n: xs: reverseList (drop n (reverseList xs)); - takeLast = n: xs: reverseList (take n (reverseList xs)); - hasEmptyPrefix = xs: take 2 xs == ["" ""]; hasEmptySuffix = xs: takeLast 2 xs == ["" ""]; hasEmptyInfix = xs: any (x: x == "") (trimEmpty 2 xs); -- cgit v1.2.3 From ca73242cda966672b314a7378652bf8294a512e5 Mon Sep 17 00:00:00 2001 From: tv Date: Wed, 12 Dec 2018 00:34:32 +0100 Subject: lib.normalize-ip6-addr: no :: for single section --- lib/default.nix | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/default.nix b/lib/default.nix index 64b2d48..347830e 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -93,7 +93,13 @@ let in if max.pos == 0 then a - else "${concatStringsSep ":" lhs}::${concatStringsSep ":" rhs}"; + else let + sep = + if 8 - (length lhs + length rhs) == 1 + then ":0:" + else "::"; + in + "${concatStringsSep ":" lhs}${sep}${concatStringsSep ":" rhs}"; drop-leading-zeros = let -- cgit v1.2.3