summaryrefslogtreecommitdiffstats
path: root/lib/default.nix
diff options
context:
space:
mode:
authormakefu <github@syntax-fehler.de>2023-01-10 13:20:04 +0100
committermakefu <github@syntax-fehler.de>2023-01-10 13:20:04 +0100
commitc691e94c45e6c5bdac531186374b185ea1790311 (patch)
tree024f2e5b8aed015687f03b31b6e7c1ce743f009c /lib/default.nix
parent1929733c03dbff92f830cb81b57cf4ccf859d364 (diff)
parent2818476f710410f1c752ce12becce10be0a8a293 (diff)
Merge remote-tracking branch 'lass/master'
Diffstat (limited to 'lib/default.nix')
-rw-r--r--lib/default.nix26
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/default.nix b/lib/default.nix
index 149b97a7..280f0429 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; };
@@ -185,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