summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--sys/net/options.nix14
1 files changed, 11 insertions, 3 deletions
diff --git a/sys/net/options.nix b/sys/net/options.nix
index 292989a..a0d29d5 100644
--- a/sys/net/options.nix
+++ b/sys/net/options.nix
@@ -81,9 +81,17 @@ with lib; {
config = {
address =
- if v6config.bits != 0
- then "${v6config.prefix}::${config.suffix}"
- else config.suffix;
+ let
+ hextets = fragment: length (splitString ":" fragment);
+ separator = if doubleColon then "::" else ":";
+ doubleColon = hextets v6config.prefix + hextets config.suffix < 8;
+
+ joined =
+ if v6config.bits != 0
+ then "${v6config.prefix}${separator}${config.suffix}"
+ else config.suffix;
+ in
+ joined;
cidr = "${config.address}/${toString v6config.bits}";
single = "${config.address}/128";