From 212da586160c25fd919a308e5fbe30c9b5e565ca Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 20 Dec 2022 19:07:51 +0100 Subject: lib: add on --- lib/default.nix | 2 ++ 1 file changed, 2 insertions(+) (limited to 'lib') diff --git a/lib/default.nix b/lib/default.nix index 149b97a72..1a57df266 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -39,6 +39,8 @@ let ne = x: y: x != y; mod = x: y: x - y * (x / y); + on = b: u: x: y: b (u x) (u y); + genid = lib.genid_uint32; # TODO remove genid_uint31 = x: ((lib.genid_uint32 x) + 16777216) / 2; genid_uint32 = import ./genid.nix { inherit lib; }; -- cgit v1.2.3 From efbcfce7a78d12a5a6adebba5f1ec3bb9f602286 Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 20 Dec 2022 19:08:42 +0100 Subject: lib: add uniq and uniqBy --- lib/default.nix | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'lib') diff --git a/lib/default.nix b/lib/default.nix index 1a57df266..280f04299 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -187,6 +187,30 @@ let in filter (x: x != []) ([acc.chunk] ++ acc.chunks); + # Filter adjacent duplicate elements. + uniq = uniqBy eq; + + # Filter adjacent duplicate elements determined via the given function. + uniqBy = cmp: let + f = a: s: + if length s == 0 then + [] + else let + b = head s; + in + if cmp a b then + f b (tail s) + else + [b] ++ f b (tail s); + in + s: + if length s == 0 then + [] + else let + b = head s; + in + [b] ++ f b (tail s); + warnOldVersion = oldName: newName: if compareVersions oldName newName != -1 then trace "Upstream `${oldName}' gets overridden by `${newName}'." newName -- cgit v1.2.3 From 02751cb50d2791be12476db14554a2093a52b6a0 Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 20 Dec 2022 20:00:01 +0100 Subject: lib.haskell.substitutePkg: sort and dedup deps --- lib/haskell.nix | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/haskell.nix b/lib/haskell.nix index 4f0ee05ab..f87cfa761 100644 --- a/lib/haskell.nix +++ b/lib/haskell.nix @@ -39,7 +39,12 @@ rec { in if parse == null then (pkgs.writeText name s).overrideAttrs (old: { - dependencies = old.dependencies or [] ++ dependencies; + dependencies = + lib.uniq + (lib.sort (lib.on lib.lessThan (lib.getAttr "name")) + (filter + (lib.ne null) + (old.dependencies or [] ++ dependencies))); }) else -- cgit v1.2.3 From ea9dbc8caf3111f80cc94de51eb6d6dace05e3c4 Mon Sep 17 00:00:00 2001 From: lassulus Date: Tue, 27 Dec 2022 12:20:42 +0100 Subject: types host: remove cores --- lib/types.nix | 3 --- 1 file changed, 3 deletions(-) (limited to 'lib') diff --git a/lib/types.nix b/lib/types.nix index 67a0c6f1b..9f278c650 100644 --- a/lib/types.nix +++ b/lib/types.nix @@ -18,9 +18,6 @@ rec { type = label; default = config._module.args.name; }; - cores = mkOption { - type = uint; - }; nets = mkOption { type = attrsOf net; default = {}; -- cgit v1.2.3 From 4adca5a98417c089e36d27f5a33c454d3d4ff3d8 Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 30 Dec 2022 17:51:23 +0100 Subject: lib.types.net.ip*: add prefixLength --- lib/types.nix | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'lib') diff --git a/lib/types.nix b/lib/types.nix index 9f278c650..32b4541ae 100644 --- a/lib/types.nix +++ b/lib/types.nix @@ -146,6 +146,14 @@ rec { }.${config._module.args.name} or { default = "${ip4.config.addr}/32"; }); + prefixLength = mkOption ({ + type = uint; + } // { + retiolum.default = 16; + wiregrill.default = 16; + }.${config._module.args.name} or { + default = 32; + }); }; })); default = null; @@ -165,6 +173,14 @@ rec { }.${config._module.args.name} or { default = "${ip6.config.addr}/128"; }); + prefixLength = mkOption ({ + type = uint; + } // { + retiolum.default = 32; + wiregrill.default = 32; + }.${config._module.args.name} or { + default = 128; + }); }; })); default = null; -- cgit v1.2.3