chore: initial commit

This commit is contained in:
technofab 2025-08-05 14:55:13 +02:00
commit 3aeff518bb
Signed by: technofab
SSH key fingerprint: SHA256:bV4h88OqS/AxjbPn66uUdvK9JsgIW4tv3vwJQ8tpMqQ
20 changed files with 1122 additions and 0 deletions

5
lib/compat/default.nix Normal file
View file

@ -0,0 +1,5 @@
{l}: rec {
filter = import ./filter.nix {inherit l;};
select = import ./select.nix {inherit filter;};
get = import ./get.nix {inherit select;};
}

30
lib/compat/filter.nix Normal file
View file

@ -0,0 +1,30 @@
{l}: let
filter = pred: t: p: let
multiplePaths = l.isList (l.elemAt p 0);
hoist = path: let
result =
l.filterAttrs (
n: v:
(l.elem n l.systems.doubles.all)
&& (l.hasAttrByPath path v)
)
t;
in
if result == {}
then builtins.abort "[ren] filter: Path ${toString path} not found in any targets."
else
l.mapAttrs (
_: v: let
attr = l.getAttrFromPath path v;
in
if pred == true
then attr
else l.filterAttrs pred attr
)
result;
in
if multiplePaths
then l.foldl' l.recursiveUpdate {} (map (path: hoist path) p)
else hoist p;
in
filter

8
lib/compat/get.nix Normal file
View file

@ -0,0 +1,8 @@
{select}: let
get = t: p: let
r = select t p;
s = builtins.head (builtins.attrNames r);
in
r.${s};
in
get

2
lib/compat/select.nix Normal file
View file

@ -0,0 +1,2 @@
{filter}:
filter true