mirror of
https://github.com/kittywitch/nixfiles.git
synced 2026-02-09 20:39:18 -08:00
feat: overlays + pkgs
This commit is contained in:
parent
bed84b16b0
commit
5da80d3c52
17 changed files with 210 additions and 91 deletions
120
std.nix
120
std.nix
|
|
@ -1,63 +1,77 @@
|
|||
{ inputs, ... }: let
|
||||
{inputs, ...}: let
|
||||
std = let
|
||||
baseStd = inputs.std.lib;
|
||||
inherit (baseStd) set function list bool types optional;
|
||||
mergeWith = let
|
||||
append = {
|
||||
path
|
||||
, values
|
||||
, canMerge
|
||||
, mapToSet
|
||||
path,
|
||||
values,
|
||||
canMerge,
|
||||
mapToSet,
|
||||
}: let
|
||||
mergeWith' = values: mergeWith {
|
||||
inherit canMerge mapToSet path;
|
||||
sets = list.map (v: (mapToSet path v).value) values;
|
||||
};
|
||||
mergeWith' = values:
|
||||
mergeWith {
|
||||
inherit canMerge mapToSet path;
|
||||
sets = list.map (v: (mapToSet path v).value) values;
|
||||
};
|
||||
mergeUntil = list.findIndex (function.not (canMerge path)) values;
|
||||
len = list.length values;
|
||||
in if len == 0 then { }
|
||||
else if len == 1 then list.unsafeHead values
|
||||
else if list.all (canMerge path) values then mergeWith' values
|
||||
else optional.match mergeUntil {
|
||||
just = i: let
|
||||
split = list.splitAt i values;
|
||||
in if i > 0
|
||||
then mergeWith' split._0
|
||||
else list.unsafeHead values;
|
||||
nothing = list.unsafeHead values;
|
||||
in
|
||||
if len == 0
|
||||
then {}
|
||||
else if len == 1
|
||||
then list.unsafeHead values
|
||||
else if list.all (canMerge path) values
|
||||
then mergeWith' values
|
||||
else
|
||||
optional.match mergeUntil {
|
||||
just = i: let
|
||||
split = list.splitAt i values;
|
||||
in
|
||||
if i > 0
|
||||
then mergeWith' split._0
|
||||
else list.unsafeHead values;
|
||||
nothing = list.unsafeHead values;
|
||||
};
|
||||
in
|
||||
{
|
||||
canMerge ? path: v: optional.isJust (mapToSet path v),
|
||||
mapToSet ? _: v: bool.toOptional (types.attrs.check v) v,
|
||||
path ? [],
|
||||
sets,
|
||||
}:
|
||||
set.mapZip (name: values:
|
||||
append {
|
||||
path = path ++ list.One name;
|
||||
inherit canMerge mapToSet values;
|
||||
})
|
||||
sets;
|
||||
merge = sets:
|
||||
mergeWith {
|
||||
inherit sets;
|
||||
};
|
||||
in {
|
||||
canMerge ? path: v: optional.isJust (mapToSet path v),
|
||||
mapToSet ? path: v: bool.toOptional (types.attrs.check v) v,
|
||||
path ? [ ],
|
||||
sets
|
||||
}: set.mapZip (name: values: append {
|
||||
path = path ++ list.One name;
|
||||
inherit canMerge mapToSet values;
|
||||
}) sets;
|
||||
merge = sets: mergeWith {
|
||||
inherit sets;
|
||||
};
|
||||
in merge [
|
||||
baseStd
|
||||
{
|
||||
function = {
|
||||
pipe = list.foldl' (function.flip function.compose) function.id;
|
||||
};
|
||||
set = {
|
||||
inherit merge mergeWith;
|
||||
remap = f: s: set.fromList (list.map f (set.toList s));
|
||||
recursiveMap = f: s: let
|
||||
recurse = str: s: let
|
||||
g = str1: str2:
|
||||
if types.attrs.check str2
|
||||
then f (str ++ [str1]) (recurse (str ++ [str1]) str2)
|
||||
else f (str ++ [str1]) str2;
|
||||
in
|
||||
merge [
|
||||
baseStd
|
||||
{
|
||||
function = {
|
||||
pipe = list.foldl' (function.flip function.compose) function.id;
|
||||
};
|
||||
set = {
|
||||
inherit merge mergeWith;
|
||||
remap = f: s: set.fromList (list.map f (set.toList s));
|
||||
recursiveMap = f: s: let
|
||||
recurse = str: s: let
|
||||
g = str1: str2:
|
||||
if types.attrs.check str2
|
||||
then f (str ++ [str1]) (recurse (str ++ [str1]) str2)
|
||||
else f (str ++ [str1]) str2;
|
||||
in
|
||||
set.map g s;
|
||||
in
|
||||
set.map g s;
|
||||
in
|
||||
f [] (recurse [] s);
|
||||
};
|
||||
}
|
||||
];
|
||||
in std
|
||||
f [] (recurse [] s);
|
||||
};
|
||||
}
|
||||
];
|
||||
in
|
||||
std
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue