forked from dan/liminix
1
0
Fork 0

print module pathname if it contains services

so that the user knows what to add to their imports
This commit is contained in:
Daniel Barlow 2023-08-12 21:12:57 +01:00
parent d7785d9d75
commit bd908307c4
1 changed files with 17 additions and 6 deletions

View File

@ -18,6 +18,13 @@
:until (not (= (string.sub l 1 2) "##"))]
(.. (or lines "") (string.gsub l "^## *" "") "\n"))))))
(fn relative-pathname [pathname]
(let [pathname
(if (string.match pathname ".nix$")
pathname
(.. pathname "/default.nix"))]
(pick-values 1 (string.gsub pathname "^/nix/store/[^/]+/" "modules/"))))
(fn strip-newlines [text]
(-> text
(string.gsub "\n([^\n])" " %1")
@ -108,10 +115,14 @@
(tset modules path e))))
(tset modules "lib/modules.nix" nil)
(let [modules (sort-modules modules)]
(each [_ {: name : module} (ipairs modules)]
(each [_ {: name : module : service?} (ipairs modules)]
(let [options (sort-options module)]
(print (or (read-preamble name) (headline name)))
(each [_ o (ipairs options)]
(if (is-service? o)
(print-service o)
(print-option o)))))))
(when (> (# options) 0)
(print (or (read-preamble name) (headline name)))
(when service?
(print "**path** " (.. ":file:`" (relative-pathname name) "`")))
(print)
(each [_ o (ipairs options)]
(if (is-service? o)
(print-service o)
(print-option o))))))))