treewide: make lib calls explicit

This commit is contained in:
Frothy 2024-03-23 20:14:39 -04:00
commit 974bfcc78e
56 changed files with 589 additions and 496 deletions

View file

@ -8,13 +8,16 @@
# - the addition of the function `entryBefore` indicating a "wanted
# by" relationship.
{lib}: let
inherit (lib) all filterAttrs nvim mapAttrs toposort;
inherit (builtins) isAttrs attrValues attrNames elem all;
inherit (lib.attrsets) filterAttrs mapAttrs;
inherit (lib.lists) toposort;
inherit (lib.nvim.dag) isEntry entryBetween;
in {
empty = {};
isEntry = e: e ? data && e ? after && e ? before;
isDag = dag:
builtins.isAttrs dag && all nvim.dag.isEntry (builtins.attrValues dag);
isAttrs dag && all isEntry (attrValues dag);
/*
Takes an attribute set containing entries built by entryAnywhere,
@ -76,8 +79,8 @@ in {
*/
topoSort = dag: let
dagBefore = dag: name:
builtins.attrNames
(filterAttrs (_n: v: builtins.elem name v.before) dag);
attrNames
(filterAttrs (_n: v: elem name v.before) dag);
normalizedDag =
mapAttrs (n: v: {
name = n;
@ -85,8 +88,8 @@ in {
after = v.after ++ dagBefore dag n;
})
dag;
before = a: b: builtins.elem a.name b.after;
sorted = toposort before (builtins.attrValues normalizedDag);
before = a: b: elem a.name b.after;
sorted = toposort before (attrValues normalizedDag);
in
if sorted ? result
then {
@ -100,8 +103,8 @@ in {
entryBetween = before: after: data: {inherit data before after;};
# Create a DAG entry with no particular dependency information.
entryAnywhere = nvim.dag.entryBetween [] [];
entryAnywhere = entryBetween [] [];
entryAfter = nvim.dag.entryBetween [];
entryBefore = before: nvim.dag.entryBetween before [];
entryAfter = entryBetween [];
entryBefore = before: entryBetween before [];
}