|
9 | 9 | pkgs, |
10 | 10 | system, |
11 | 11 | ... |
12 | | - }: { |
| 12 | + }: let |
| 13 | + mkDocs = { |
| 14 | + loc, |
| 15 | + options, |
| 16 | + }: |
| 17 | + pkgs.nixosOptionsDoc { |
| 18 | + inherit options; |
| 19 | + |
| 20 | + # Default is currently "appendix". |
| 21 | + documentType = "none"; |
| 22 | + |
| 23 | + # We only want Markdown |
| 24 | + allowDocBook = false; |
| 25 | + markdownByDefault = true; |
| 26 | + |
| 27 | + # Only include our own options. |
| 28 | + transformOptions = let |
| 29 | + ourPrefix = "${toString self}/"; |
| 30 | + link = { |
| 31 | + url = "/${loc}"; |
| 32 | + name = loc; |
| 33 | + }; |
| 34 | + in |
| 35 | + opt: |
| 36 | + opt |
| 37 | + // { |
| 38 | + visible = opt.visible && (lib.any (lib.hasPrefix ourPrefix) opt.declarations); |
| 39 | + declarations = map (decl: |
| 40 | + if lib.hasPrefix ourPrefix decl |
| 41 | + then link |
| 42 | + else decl) |
| 43 | + opt.declarations; |
| 44 | + }; |
| 45 | + }; |
| 46 | + in { |
13 | 47 | packages = { |
14 | 48 | default = config.packages.anything-sync-daemon; |
15 | 49 |
|
|
82 | 116 | }; |
83 | 117 | }; |
84 | 118 |
|
85 | | - docs = let |
| 119 | + nixosDocs = let |
86 | 120 | # Use a full NixOS system rather than (say) the result of |
87 | 121 | # `lib.evalModules`. This is because our NixOS module refers to |
88 | 122 | # `security.sudo`, which may itself refer to any number of other |
|
96 | 130 | ]; |
97 | 131 | }; |
98 | 132 |
|
99 | | - allDocs = pkgs.nixosOptionsDoc { |
| 133 | + allDocs = mkDocs { |
100 | 134 | inherit (eval) options; |
| 135 | + loc = "nix/nixos-modules.nix"; |
| 136 | + }; |
| 137 | + in |
| 138 | + allDocs.optionsCommonMark; |
101 | 139 |
|
102 | | - # Default is currently "appendix". |
103 | | - documentType = "none"; |
104 | | - |
105 | | - # We only want Markdown |
106 | | - allowDocBook = false; |
107 | | - markdownByDefault = true; |
| 140 | + homeManagerDocs = let |
| 141 | + # Use a full Home Manager configuration for reasons similar to those |
| 142 | + # given above with respect to the NixOS module documentation. |
| 143 | + eval = inputs.home-manager.lib.homeManagerConfiguration { |
| 144 | + inherit pkgs; |
| 145 | + modules = [ |
| 146 | + ({config, ...}: { |
| 147 | + home.stateVersion = config.home.version.release; |
| 148 | + home.username = "ignored"; |
| 149 | + home.homeDirectory = "/home/ignored"; |
| 150 | + }) |
| 151 | + self.homeModules.anything-sync-daemon |
| 152 | + ]; |
| 153 | + }; |
108 | 154 |
|
109 | | - # Only include our own options. |
110 | | - transformOptions = let |
111 | | - ourPrefix = "${toString self}/"; |
112 | | - nixosModules = "nix/nixos-modules.nix"; |
113 | | - link = { |
114 | | - url = "/${nixosModules}"; |
115 | | - name = nixosModules; |
116 | | - }; |
117 | | - in |
118 | | - opt: |
119 | | - opt |
120 | | - // { |
121 | | - visible = opt.visible && (lib.any (lib.hasPrefix ourPrefix) opt.declarations); |
122 | | - declarations = map (decl: |
123 | | - if lib.hasPrefix ourPrefix decl |
124 | | - then link |
125 | | - else decl) |
126 | | - opt.declarations; |
127 | | - }; |
| 155 | + allDocs = mkDocs { |
| 156 | + inherit (eval) options; |
| 157 | + loc = "nix/home-modules.nix"; |
128 | 158 | }; |
129 | 159 | in |
130 | | - allDocs.optionsCommonMark; |
| 160 | + allDocs.optionsCommonMark // { |
| 161 | + passthru = (allDocs.OptionsCommonMark.passthru or {}) // { |
| 162 | + inherit eval; |
| 163 | + }; |
| 164 | + }; |
131 | 165 | }; |
132 | 166 | }; |
133 | 167 | } |
0 commit comments