tangled
alpha
login
or
join now
pyrox.dev
/
nixpkgs
lol
0
fork
atom
overview
issues
pulls
pipelines
docs: Build with a makefile
Graham Christensen
8 years ago
7e25ff71
8c7be592
+93
-103
3 changed files
expand all
collapse all
unified
split
doc
Makefile
default.nix
shell.section.md
+69
doc/Makefile
···
1
1
+
MD_TARGETS=$(addsuffix .xml, $(basename $(wildcard ./*.md ./**/*.md)))
2
2
+
3
3
+
.PHONY: all
4
4
+
all: out/html/index.html out/epub/manual.epub
5
5
+
6
6
+
.PHONY: clean
7
7
+
clean:
8
8
+
rm -f ${MD_TARGETS} .version manual-full.xml
9
9
+
rm -rf ./out/
10
10
+
11
11
+
validate: manual-full.xml
12
12
+
jing "$$RNG" manual-full.xml
13
13
+
14
14
+
out/html/index.html: manual-full.xml style.css
15
15
+
mkdir -p out/html
16
16
+
xsltproc $$xsltFlags \
17
17
+
--nonet --xinclude \
18
18
+
--output $@ \
19
19
+
"$$XSL/docbook/xhtml/docbook.xsl" \
20
20
+
./manual-full.xml
21
21
+
22
22
+
cp ./style.css out/html/style.css
23
23
+
24
24
+
mkdir -p out/html/images/callouts
25
25
+
cp "$$XSL/docbook/images/callouts/"*.gif out/html/images/callouts/
26
26
+
27
27
+
out/epub/manual.epub: manual-full.xml
28
28
+
mkdir -p out/epub/scratch
29
29
+
xsltproc $$xsltFlags --nonet \
30
30
+
--output out/epub/scratch/ \
31
31
+
"$$XSL/docbook/epub/docbook.xsl" \
32
32
+
./manual-full.xml
33
33
+
34
34
+
cp "$$XSL/docbook/images/callouts/"*.gif out/epub/scratch/OEBPS
35
35
+
echo "application/epub+zip" > mimetype
36
36
+
zip -0Xq "out/epub/manual.epub" mimetype
37
37
+
rm mimetype
38
38
+
cd "out/epub/scratch/" && zip -Xr9D "../manual.epub" *
39
39
+
rm -rf "out/epub/scratch/"
40
40
+
41
41
+
manual-full.xml: ${MD_TARGETS} .version *.xml
42
42
+
xmllint --nonet --xinclude --noxincludenode manual.xml --output manual-full.xml
43
43
+
44
44
+
.version:
45
45
+
nix-instantiate --eval \
46
46
+
-E '(import ../lib).nixpkgsVersion' > .version
47
47
+
48
48
+
%.section.xml: %.section.md
49
49
+
pandoc $^ -w docbook+smart \
50
50
+
-f markdown+smart \
51
51
+
| sed -e 's|<ulink url=|<link xlink:href=|' \
52
52
+
-e 's|</ulink>|</link>|' \
53
53
+
-e 's|<sect. id=|<section xml:id=|' \
54
54
+
-e 's|</sect[0-9]>|</section>|' \
55
55
+
-e '1s| id=| xml:id=|' \
56
56
+
-e '1s|\(<[^ ]* \)|\1xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" |' \
57
57
+
| cat > $@
58
58
+
59
59
+
%.chapter.xml: %.chapter.md
60
60
+
pandoc $^ -w docbook+smart \
61
61
+
--top-level-division=chapter \
62
62
+
-f markdown+smart \
63
63
+
| sed -e 's|<ulink url=|<link xlink:href=|' \
64
64
+
-e 's|</ulink>|</link>|' \
65
65
+
-e 's|<sect. id=|<section xml:id=|' \
66
66
+
-e 's|</sect[0-9]>|</section>|' \
67
67
+
-e '1s| id=| xml:id=|' \
68
68
+
-e '1s|\(<[^ ]* \)|\1|' \
69
69
+
| cat > $@
+22
-103
doc/default.nix
···
7
7
pkgs.stdenv.mkDerivation {
8
8
name = "nixpkgs-manual";
9
9
10
10
-
11
10
buildInputs = with pkgs; [ pandoc libxml2 libxslt zip ];
12
11
13
13
-
xsltFlags = ''
14
14
-
--param section.autolabel 1
15
15
-
--param section.label.includes.component.label 1
16
16
-
--param html.stylesheet 'style.css'
17
17
-
--param xref.with.number.and.title 1
18
18
-
--param toc.section.depth 3
19
19
-
--param admon.style '''
20
20
-
--param callout.graphics.extension '.gif'
21
21
-
'';
12
12
+
src = ./.;
22
13
14
14
+
XSL = "${pkgs.docbook5_xsl}/xml/xsl";
15
15
+
RNG = "${pkgs.docbook5}/xml/rng/docbook/docbook.rng";
16
16
+
xsltFlags = lib.concatStringsSep " " [
17
17
+
"--param section.autolabel 1"
18
18
+
"--param section.label.includes.component.label 1"
19
19
+
"--param html.stylesheet 'style.css'"
20
20
+
"--param xref.with.number.and.title 1"
21
21
+
"--param toc.section.depth 3"
22
22
+
"--param admon.style ''"
23
23
+
"--param callout.graphics.extension '.gif'"
24
24
+
];
23
25
24
24
-
buildCommand = let toDocbook = { useChapters ? false, inputFile, outputFile }:
25
25
-
let
26
26
-
extraHeader = lib.optionalString (!useChapters)
27
27
-
''xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" '';
28
28
-
in ''
29
29
-
{
30
30
-
pandoc '${inputFile}' -w docbook+smart ${lib.optionalString useChapters "--top-level-division=chapter"} \
31
31
-
-f markdown+smart \
32
32
-
| sed -e 's|<ulink url=|<link xlink:href=|' \
33
33
-
-e 's|</ulink>|</link>|' \
34
34
-
-e 's|<sect. id=|<section xml:id=|' \
35
35
-
-e 's|</sect[0-9]>|</section>|' \
36
36
-
-e '1s| id=| xml:id=|' \
37
37
-
-e '1s|\(<[^ ]* \)|\1${extraHeader}|'
38
38
-
} > '${outputFile}'
39
39
-
'';
40
40
-
in
41
41
-
42
42
-
''
43
43
-
ln -s '${sources}/'*.xml .
44
44
-
mkdir ./languages-frameworks
45
45
-
cp -s '${sources-langs}'/* ./languages-frameworks
46
46
-
''
47
47
-
+ toDocbook {
48
48
-
inputFile = ./introduction.chapter.md;
49
49
-
outputFile = "introduction.chapter.xml";
50
50
-
useChapters = true;
51
51
-
}
52
52
-
+ toDocbook {
53
53
-
inputFile = ./shell.section.md;
54
54
-
outputFile = "shell.section.xml";
55
55
-
}
56
56
-
+ toDocbook {
57
57
-
inputFile = ./languages-frameworks/python.section.md;
58
58
-
outputFile = "./languages-frameworks/python.section.xml";
59
59
-
}
60
60
-
+ toDocbook {
61
61
-
inputFile = ./languages-frameworks/haskell.section.md;
62
62
-
outputFile = "./languages-frameworks/haskell.section.xml";
63
63
-
}
64
64
-
+ toDocbook {
65
65
-
inputFile = ./languages-frameworks/idris.section.md;
66
66
-
outputFile = "languages-frameworks/idris.section.xml";
67
67
-
}
68
68
-
+ toDocbook {
69
69
-
inputFile = ./languages-frameworks/node.section.md;
70
70
-
outputFile = "languages-frameworks/node.section.xml";
71
71
-
}
72
72
-
+ toDocbook {
73
73
-
inputFile = ./languages-frameworks/r.section.md;
74
74
-
outputFile = "languages-frameworks/r.section.xml";
75
75
-
}
76
76
-
+ toDocbook {
77
77
-
inputFile = ./languages-frameworks/rust.section.md;
78
78
-
outputFile = "./languages-frameworks/rust.section.xml";
79
79
-
}
80
80
-
+ toDocbook {
81
81
-
inputFile = ./languages-frameworks/vim.section.md;
82
82
-
outputFile = "./languages-frameworks/vim.section.xml";
83
83
-
}
84
84
-
+ toDocbook {
85
85
-
inputFile = ./languages-frameworks/emscripten.section.md;
86
86
-
outputFile = "./languages-frameworks/emscripten.section.xml";
87
87
-
}
88
88
-
+ ''
26
26
+
postPatch = ''
89
27
echo ${lib.nixpkgsVersion} > .version
90
90
-
91
91
-
# validate against relaxng schema
92
92
-
xmllint --nonet --xinclude --noxincludenode manual.xml --output manual-full.xml
93
93
-
${pkgs.jing}/bin/jing ${pkgs.docbook5}/xml/rng/docbook/docbook.rng manual-full.xml
94
94
-
95
95
-
dst=$out/share/doc/nixpkgs
96
96
-
mkdir -p $dst
97
97
-
xsltproc $xsltFlags --nonet --xinclude \
98
98
-
--output $dst/manual.html \
99
99
-
${pkgs.docbook5_xsl}/xml/xsl/docbook/xhtml/docbook.xsl \
100
100
-
./manual.xml
28
28
+
'';
101
29
102
102
-
cp ${./style.css} $dst/style.css
30
30
+
installPhase = ''
31
31
+
dest="$out/share/doc/nixpkgs"
32
32
+
mkdir -p "$(dirname "$dest")"
33
33
+
mv out/html "$dest"
34
34
+
mv "$dest/index.html" "$dest/manual.html"
103
35
104
104
-
mkdir -p $dst/images/callouts
105
105
-
cp "${pkgs.docbook5_xsl}/xml/xsl/docbook/images/callouts/"*.gif $dst/images/callouts/
36
36
+
mv out/epub/manual.epub "$dest/nixpkgs-manual.epub"
106
37
107
107
-
mkdir -p $out/nix-support
108
108
-
echo "doc manual $dst manual.html" >> $out/nix-support/hydra-build-products
109
109
-
110
110
-
xsltproc $xsltFlags --nonet --xinclude \
111
111
-
--output $dst/epub/ \
112
112
-
${pkgs.docbook5_xsl}/xml/xsl/docbook/epub/docbook.xsl \
113
113
-
./manual.xml
114
114
-
115
115
-
cp -r $dst/images $dst/epub/OEBPS
116
116
-
echo "application/epub+zip" > mimetype
117
117
-
manual="$dst/nixpkgs-manual.epub"
118
118
-
zip -0Xq "$manual" mimetype
119
119
-
cd $dst/epub && zip -Xr9D "$manual" *
120
120
-
rm -rf $dst/epub
38
38
+
mkdir -p $out/nix-support/
39
39
+
echo "doc manual $dest manual.html" >> $out/nix-support/hydra-build-products
121
40
'';
122
41
}
+2
doc/shell.section.md
···
4
4
date: 2017-10-30
5
5
---
6
6
7
7
+
# mkShell
8
8
+
7
9
pkgs.mkShell is a special kind of derivation that is only useful when using
8
10
it combined with nix-shell. It will in fact fail to instantiate when invoked
9
11
with nix-build.