mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-09-06 10:21:31 +00:00
treewide: make lib calls explicit
This commit is contained in:
parent
a7531186a8
commit
974bfcc78e
56 changed files with 589 additions and 496 deletions
21
lib/dag.nix
21
lib/dag.nix
|
@ -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 [];
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue