summaryrefslogtreecommitdiffstats
path: root/mdbook.nix
diff options
context:
space:
mode:
authorMinijackson <minijackson@riseup.net>2021-11-08 16:26:42 +0100
committerMinijackson <minijackson@riseup.net>2021-11-08 16:26:42 +0100
commitc7026a993c4b837dcee39f669e1cc4123f4eb53d (patch)
tree8cfea3898b391a3c2ab8e48a7b1dd2b711456739 /mdbook.nix
downloadnix-module-doc-c7026a993c4b837dcee39f669e1cc4123f4eb53d.tar.gz
nix-module-doc-c7026a993c4b837dcee39f669e1cc4123f4eb53d.zip
initial commit
Diffstat (limited to 'mdbook.nix')
-rw-r--r--mdbook.nix45
1 files changed, 45 insertions, 0 deletions
diff --git a/mdbook.nix b/mdbook.nix
new file mode 100644
index 0000000..d336042
--- /dev/null
+++ b/mdbook.nix
@@ -0,0 +1,45 @@
1{ outputAttrPath, optionsAttrPath, optionsInternal ? true, }:
2
3{ config, lib, pkgs, ... }:
4
5with lib;
6
7let
8 cfg = getAttrFromPath (optionsAttrPath ++ [ "mdbook" ]) config;
9in
10{
11 options = setAttrByPath optionsAttrPath {
12 mdbook = {
13 src = mkOption {
14 type = with types; either path package;
15 description = ''
16 Root directory of mdbook sources to compile.
17 '';
18 internal = optionsInternal;
19 };
20 };
21 };
22
23 config = setAttrByPath outputAttrPath {
24 # TODO: make pandoc pre-processor
25 mdbook = pkgs.runCommand "mdbook"
26 {
27 src = cfg.src;
28 nativeBuildInputs = with pkgs; [ mdbook ];
29 } ''
30 unpackFile "$src"
31 chmod -R u+w .
32 cd */
33
34 mkdir theme
35 cp ${pkgs.documentation-highlighter}/highlight.pack.js theme/highlight.js
36 cp ${pkgs.documentation-highlighter}/mono-blue.css theme/highlight.css
37
38 cp "${getAttrFromPath (outputAttrPath ++ ["doc-options-md"]) config}" src/options.md
39
40 mdbook build
41
42 cp -r book "$out"
43 '';
44 };
45}