blob: d33604214372f7d9fa12f1507ffbaad5f7b930ea (
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
|
{ 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;
};
};
};
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
mdbook build
cp -r book "$out"
'';
};
}
|