module docs: service modules are listed after plain modules
This commit is contained in:
parent
f20d1cfc01
commit
519de0b55c
1 changed files with 26 additions and 7 deletions
|
@ -73,6 +73,27 @@
|
||||||
["system" "outputs" & _] true
|
["system" "outputs" & _] true
|
||||||
_ false))
|
_ false))
|
||||||
|
|
||||||
|
(fn is-service? [o]
|
||||||
|
(= o.type "parametrisable s6-rc service definition"))
|
||||||
|
|
||||||
|
(fn has-service? [module]
|
||||||
|
(accumulate [found false
|
||||||
|
_ o (ipairs module)]
|
||||||
|
(or found (is-service? o))))
|
||||||
|
|
||||||
|
(fn sort-modules [modules]
|
||||||
|
;; modules containing services should sort _after_ modules
|
||||||
|
;; that contain only options
|
||||||
|
(doto (icollect [n m (pairs modules)]
|
||||||
|
{ :name n :service? (has-service? m) :module m })
|
||||||
|
(table.sort
|
||||||
|
(fn [a b]
|
||||||
|
(if (and a.service? (not b.service?))
|
||||||
|
false
|
||||||
|
(and b.service? (not a.service?))
|
||||||
|
true
|
||||||
|
(< a.name b.name))))))
|
||||||
|
|
||||||
(fn sort-options [module]
|
(fn sort-options [module]
|
||||||
(let [options (icollect [_ o (ipairs module)]
|
(let [options (icollect [_ o (ipairs module)]
|
||||||
(if (not (output? o))
|
(if (not (output? o))
|
||||||
|
@ -87,13 +108,11 @@
|
||||||
(table.insert e option)
|
(table.insert e option)
|
||||||
(tset modules path e))))
|
(tset modules path e))))
|
||||||
(tset modules "lib/modules.nix" nil)
|
(tset modules "lib/modules.nix" nil)
|
||||||
(let [module-names (doto (icollect [n _ (pairs modules)] n) table.sort)]
|
(let [modules (sort-modules modules)]
|
||||||
(io.stderr:write (view module-names))
|
(each [_ {: name : module} (ipairs modules)]
|
||||||
(each [_ name (ipairs module-names)]
|
(let [options (sort-options module)]
|
||||||
(let [module (. modules name)
|
|
||||||
options (sort-options module)]
|
|
||||||
(print (or (read-preamble name) (headline name)))
|
(print (or (read-preamble name) (headline name)))
|
||||||
(each [_ o (ipairs options)]
|
(each [_ o (ipairs options)]
|
||||||
(if (= o.type "parametrisable s6-rc service definition")
|
(if (is-service? o)
|
||||||
(print-service o)
|
(print-service o)
|
||||||
(print-option o)))))))
|
(print-option o)))))))
|
||||||
|
|
Loading…
Reference in a new issue