Repository navigation
Expand file tree
/
Copy pathsite.nix
More file actions
74 lines (68 loc) · 1.64 KB
/
Copy pathsite.nix
File metadata and controls
74 lines (68 loc) · 1.64 KB
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
68
69
70
71
72
73
74
# The nixidae site: a landing page, and the docs site of each source under
# `<source>/`. nixidae/nixidae#1105.
{
lib,
stdenvNoCC,
python,
sphinx,
myst-parser,
furo,
nixvenv,
# Each source with a site, as { description; site; }.
sites,
}:
let
pythonEnv = nixvenv {
inherit python;
packages = _: [
sphinx
myst-parser
furo
];
executables = [ "sphinx-build" ];
};
# HTML and not a Markdown list: MyST reads a relative Markdown link as a
# cross-reference, and finds no page for a site it did not build. The links
# are relative, so that the site works at any base URL.
list = ''
<ul>
${
lib.concatStrings (
lib.mapAttrsToList (name: source: ''
<li><a href="${name}/index.html">${name}</a>: ${source.description}</li>
'') sites
)
}</ul>
'';
in
stdenvNoCC.mkDerivation {
pname = "nixidae-site";
version = "0";
src = lib.fileset.toSource {
root = ../.;
fileset = lib.fileset.unions [
../docs
./shared/sphinx_shared.py
];
};
nativeBuildInputs = [ pythonEnv ];
inherit list;
passAsFile = [ "list" ];
buildPhase = ''
runHook preBuild
cp "$listPath" docs/sources.md
NIXIDAE_DOCS_OFFLINE=1 sphinx-build -b html docs "$out" -W
runHook postBuild
'';
# Copies, not links: a Pages artifact keeps a link as a link, and a link
# into the store points nowhere on the host that serves it.
installPhase = ''
runHook preInstall
${lib.concatStrings (
lib.mapAttrsToList (name: source: ''
cp -r --no-preserve=mode ${source.site} "$out/${name}"
'') sites
)}
runHook postInstall
'';
}