chore: initial commit

This commit is contained in:
Jake Hamilton 2022-09-07 17:06:33 -07:00
commit 7e8aabfaff
No known key found for this signature in database
GPG key ID: 9762169A1B35EA68
19 changed files with 2505 additions and 0 deletions

36
lib/attrs/default.nix Normal file
View file

@ -0,0 +1,36 @@
{ core-inputs
, user-inputs
, snowfall-lib
}:
let
inherit (core-inputs.nixpkgs.lib)
assertMsg
mapAttrsToList
flatten
fold
recursiveUpdate
mergeAttrs;
in
{
attrs = {
# Map and flatten an attribute set into a list.
# Type: (a -> b -> [c]) -> Attrs -> [c]
# Usage: map-concat-attrs-to-list (name: value: [name value]) { x = 1; y = 2; }
# result: [ "x" 1 "y" 2 ]
map-concat-attrs-to-list = f: attrs:
flatten (mapAttrsToList f attrs);
# Recursively merge a list of attribute sets.
# Type: [Attrs] -> Attrs
# Usage: merge-deep [{ x = 1; } { x = 2; }]
# result: { x = 2; }
merge-deep = fold recursiveUpdate { };
# Merge the root of a list of attribute sets.
# Type: [Attrs] -> Attrs
# Usage: merge-shallow [{ x = 1; } { x = 2; }]
# result: { x = 2; }
merge-shallow = fold mergeAttrs { };
};
}