print module pathname if it contains services
so that the user knows what to add to their imports
This commit is contained in:
parent
d7785d9d75
commit
bd908307c4
1 changed files with 17 additions and 6 deletions
|
@ -18,6 +18,13 @@
|
||||||
:until (not (= (string.sub l 1 2) "##"))]
|
:until (not (= (string.sub l 1 2) "##"))]
|
||||||
(.. (or lines "") (string.gsub l "^## *" "") "\n"))))))
|
(.. (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]
|
(fn strip-newlines [text]
|
||||||
(-> text
|
(-> text
|
||||||
(string.gsub "\n([^\n])" " %1")
|
(string.gsub "\n([^\n])" " %1")
|
||||||
|
@ -108,10 +115,14 @@
|
||||||
(tset modules path e))))
|
(tset modules path e))))
|
||||||
(tset modules "lib/modules.nix" nil)
|
(tset modules "lib/modules.nix" nil)
|
||||||
(let [modules (sort-modules modules)]
|
(let [modules (sort-modules modules)]
|
||||||
(each [_ {: name : module} (ipairs modules)]
|
(each [_ {: name : module : service?} (ipairs modules)]
|
||||||
(let [options (sort-options module)]
|
(let [options (sort-options module)]
|
||||||
|
(when (> (# options) 0)
|
||||||
(print (or (read-preamble name) (headline name)))
|
(print (or (read-preamble name) (headline name)))
|
||||||
|
(when service?
|
||||||
|
(print "**path** " (.. ":file:`" (relative-pathname name) "`")))
|
||||||
|
(print)
|
||||||
(each [_ o (ipairs options)]
|
(each [_ o (ipairs options)]
|
||||||
(if (is-service? o)
|
(if (is-service? o)
|
||||||
(print-service o)
|
(print-service o)
|
||||||
(print-option o)))))))
|
(print-option o))))))))
|
||||||
|
|
Loading…
Reference in a new issue