mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-02-07 09:33:23 +00:00
lib: filter empty/null DAGs
This commit is contained in:
parent
199babe62c
commit
c9ac830a2d
1 changed files with 19 additions and 9 deletions
28
lib/dag.nix
28
lib/dag.nix
|
@ -24,7 +24,7 @@ in {
|
||||||
entryAfter, and entryBefore to a topologically sorted list of
|
entryAfter, and entryBefore to a topologically sorted list of
|
||||||
entries.
|
entries.
|
||||||
|
|
||||||
Internally this function uses the `toposort` function in
|
Internally this function uses the `topoSort` function in
|
||||||
`<nixpkgs/lib/lists.nix>` and its value is accordingly.
|
`<nixpkgs/lib/lists.nix>` and its value is accordingly.
|
||||||
|
|
||||||
Specifically, the result on success is
|
Specifically, the result on success is
|
||||||
|
@ -136,16 +136,26 @@ in {
|
||||||
entriesAfter = tag: entriesBetween tag [];
|
entriesAfter = tag: entriesBetween tag [];
|
||||||
entriesBefore = tag: before: entriesBetween tag before [];
|
entriesBefore = tag: before: entriesBetween tag before [];
|
||||||
|
|
||||||
# mkLuarcSection and mkVimrcSection take a section DAG
|
# mkLuarcSection takes a section DAG, containing 'name' and 'data' fields
|
||||||
# and return a string containing a comment to identify
|
# then returns a string containing a comment to identify the section, and
|
||||||
|
# the data contained within the section.
|
||||||
# the section, and the data contained within the section
|
# the section, and the data contained within the section
|
||||||
#
|
#
|
||||||
# all operations are done without any modifications
|
# All operations are done without any modifications to the inputted section
|
||||||
# to the inputted section data
|
# data, but if a non-string is passed to name or data, then it will try to
|
||||||
mkLuarcSection = section: ''
|
# coerce it into a string, which may fail. Setting data to "" or null will
|
||||||
-- SECTION: ${section.name}
|
# return an empty string.
|
||||||
${section.data}
|
#
|
||||||
'';
|
# section.data should never be null, though taking 'null' as a value that
|
||||||
|
# can "clear" the DAG might come in handy for filtering sections more easily.
|
||||||
|
# Or perhaps simply unsetting them from an user perspective.
|
||||||
|
mkLuarcSection = section:
|
||||||
|
if section.data == "" || section.data == null
|
||||||
|
then ""
|
||||||
|
else ''
|
||||||
|
-- SECTION: ${section.name}
|
||||||
|
${section.data}
|
||||||
|
'';
|
||||||
|
|
||||||
resolveDag = {
|
resolveDag = {
|
||||||
name,
|
name,
|
||||||
|
|
Loading…
Add table
Reference in a new issue