lib: filter empty/null DAGs

This commit is contained in:
raf 2025-02-03 14:56:49 +03:00
parent 199babe62c
commit c9ac830a2d
No known key found for this signature in database
GPG key ID: EED98D11B85A2819

View file

@ -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,