blob: 9c2dd66b559a02b18410b45d09ab1eb4bdfe0a39 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
{ outputAttrPath, optionsAttrPath, optionsInternal ? true, }:
{ config, lib, pkgs, ... }:
with lib;
let
cfg = getAttrFromPath (optionsAttrPath ++ [ "mdbook" ]) config;
in
{
options = setAttrByPath optionsAttrPath {
mdbook = {
src = mkOption {
type = with types; either path package;
description = ''
Root directory of mdbook sources to compile.
'';
internal = optionsInternal;
};
preBuild = mkOption {
type = types.lines;
description = ''
Extra commands executed before running `mdbook build`.
'';
default = "";
internal = optionsInternal;
};
postBuild = mkOption {
type = types.lines;
description = ''
Extra commands executed after running `mdbook build`.
'';
default = "";
internal = optionsInternal;
};
};
};
config = setAttrByPath outputAttrPath {
# TODO: make pandoc pre-processor
mdbook = pkgs.runCommand "mdbook"
{
src = cfg.src;
nativeBuildInputs = with pkgs; [ mdbook ];
} ''
unpackFile "$src"
chmod -R u+w .
cd */
mkdir theme
cp ${pkgs.documentation-highlighter}/highlight.pack.js theme/highlight.js
cp ${pkgs.documentation-highlighter}/mono-blue.css theme/highlight.css
cp "${getAttrFromPath (outputAttrPath ++ ["doc-options-md"]) config}" src/options.md
${cfg.preBuild}
mdbook build
${cfg.postBuild}
cp -r book "$out"
'';
};
}
|