summaryrefslogtreecommitdiffstats
path: root/flake.nix
diff options
context:
space:
mode:
Diffstat (limited to 'flake.nix')
-rw-r--r--flake.nix104
1 files changed, 104 insertions, 0 deletions
diff --git a/flake.nix b/flake.nix
new file mode 100644
index 0000000..2826989
--- /dev/null
+++ b/flake.nix
@@ -0,0 +1,104 @@
1{
2 description = "Generate documentation for your own projects using the NixOS module system";
3
4 inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-21.05";
5
6 outputs = { self, nixpkgs }:
7 let pkgs = nixpkgs.legacyPackages.x86_64-linux;
8 in
9 {
10
11 lib.modules = {
12 doc-options-md = import ./doc-options-md.nix;
13 mdbook = import ./mdbook.nix;
14 manpage = import ./manpage.nix;
15 };
16
17 checks.x86_64-linux =
18 let
19 evalModules = modules: pkgs.lib.evalModules {
20 modules = [
21 ({ config._module.args = { inherit pkgs; }; })
22 ] ++ modules;
23 };
24 simpleModule = with pkgs.lib; {
25 options.my.simple.module.outputs = mkOption {
26 type = with types; attrsOf package;
27 default = { };
28 description = ''
29 Output products of my simple module system.
30 '';
31 };
32 };
33 params = {
34 outputAttrPath = [ "my" "simple" "module" "outputs" ];
35 optionsAttrPath = [ "my" "simple" "module" "doc" ];
36 optionsInternal = false;
37 };
38
39 simple-manpage = {
40 name = "my simple module system";
41 shortDescription = "A sample module system";
42 };
43
44 advanced-manpage = {
45 name = "my simple module system";
46 section = 5;
47 shortDescription = "A sample module system";
48 description = ''
49 This is a very advanced module system, for advanced people.
50 '';
51
52 textBefore = ''
53 # A SECTION BEFORE
54
55 This is a section before the options.
56 '';
57
58 textAfter = ''
59 # A SECTION AFTER
60
61 This is a section after the options.
62 '';
63 };
64 in
65 {
66 simple-doc-options-md = (evalModules [
67 simpleModule
68 (self.lib.modules.doc-options-md params)
69 ]).config.my.simple.module.outputs.doc-options-md;
70
71 simple-manpage = (evalModules [
72 simpleModule
73 (self.lib.modules.doc-options-md params)
74 (self.lib.modules.manpage params)
75 {
76 my.simple.module.doc.manpage = simple-manpage;
77 }
78 ]).config.my.simple.module.outputs.manpage;
79
80 advanced-manpage = (evalModules [
81 simpleModule
82 (self.lib.modules.doc-options-md params)
83 (self.lib.modules.manpage params)
84 {
85 my.simple.module.doc.manpage = advanced-manpage;
86 }
87 ]).config.my.simple.module.outputs.manpage;
88
89 simple-mdbook = (evalModules [
90 simpleModule
91 (self.lib.modules.doc-options-md params)
92 (self.lib.modules.mdbook params)
93 {
94 my.simple.module.doc.mdbook.src = ./checks/simple-mdbook;
95 }
96 ]).config.my.simple.module.outputs.mdbook;
97
98 };
99
100 devShell.x86_64-linux = pkgs.mkShell {
101 nativeBuildInputs = with pkgs; [ mdbook pandoc ];
102 };
103 };
104}