-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmkDocs.nix
61 lines (56 loc) · 1.57 KB
/
mkDocs.nix
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
{ pkgs, lib, ... }:
let
eval = lib.evalModules {
specialArgs = {
inherit pkgs;
};
modules = [
{ _module.check = false; }
./modules
];
};
cleanEval = lib.filterAttrsRecursive (n: v: n != "_module") eval;
ordenadaPath = toString ./.;
repoDeclaration = subpath: {
url = "https://github.com/migalmoreno/ordenada/blob/master/${subpath}";
name = "<ordenada/${subpath}>";
};
optionsDoc = pkgs.nixosOptionsDoc {
inherit (cleanEval) options;
transformOptions =
opt:
opt
// {
declarations = map (
decl:
if lib.hasPrefix ordenadaPath (toString decl) then
repoDeclaration (lib.removePrefix "/" (lib.removePrefix ordenadaPath (toString decl)))
else
decl
) opt.declarations;
};
};
in
pkgs.runCommand "ordenada-docs"
{
buildInputs = [
pkgs.pandoc
pkgs.emacs
];
}
''
tmpdir=$(mktemp -d)
mkdir -p $out
sed '$ d' ${./README} > $tmpdir/README
cat ${optionsDoc.optionsCommonMark} > $tmpdir/options.md
cat $tmpdir/options.md > $out/options.md
emacs --batch --eval \
"(progn (require 'ox) (require 'ox-md) \
(find-file \"$tmpdir/README\") \
(org-export-to-file 'md \"$tmpdir/readme.md\") (bury-buffer))"
cat $tmpdir/readme.md $tmpdir/options.md > $out/index.md
pandoc -f markdown -o $tmpdir/options.org $tmpdir/options.md
cat $tmpdir/README $tmpdir/options.org > $out/index.org
cat $tmpdir/README > $out/readme.org
pandoc -f markdown+smart -o $out/index.html $out/index.md
''