From 948343e45996a2d6d107012de83bc54ba2e3e348 Mon Sep 17 00:00:00 2001 From: tv Date: Mon, 19 Dec 2022 14:15:40 +0100 Subject: tv alacritty: don't expect $HOME/ref to exists --- tv/5pkgs/simple/alacritty-tv.nix | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tv/5pkgs/simple/alacritty-tv.nix b/tv/5pkgs/simple/alacritty-tv.nix index 466ff27..d80c46c 100644 --- a/tv/5pkgs/simple/alacritty-tv.nix +++ b/tv/5pkgs/simple/alacritty-tv.nix @@ -70,8 +70,7 @@ pkgs.symlinkJoin { # Install stored configuration if it has changed. # This allows for both declarative updates and runtime modifications. ${pkgs.coreutils}/bin/mkdir -p "$HOME" - ref=$(${pkgs.coreutils}/bin/cat "$HOME"/ref) - if test "$ref" != ${config-file}; then + if test "$(${pkgs.coreutils}/bin/cat "$HOME"/ref)" != ${config-file}; then echo ${config-file} > "$HOME"/ref ${pkgs.coreutils}/bin/cp ${config-file} "$HOME"/.alacritty.yml fi -- cgit v1.2.3 From 19701a1ed870ea1846fdb931b2a52f8b6f0ea24c 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(+) diff --git a/lib/default.nix b/lib/default.nix index 149b97a..1a57df2 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 6c4e84fe87aace5daf6915f26ea930a99b149555 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(+) diff --git a/lib/default.nix b/lib/default.nix index 1a57df2..280f042 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 0d661dd94a6215d49397aabbaeaedab06a1fb66e 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(-) diff --git a/lib/haskell.nix b/lib/haskell.nix index 4f0ee05..f87cfa7 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