forked from dfinity/interface-spec
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdefault.nix
72 lines (64 loc) · 2.14 KB
/
default.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
62
63
64
65
66
67
68
69
70
71
72
{
system ? builtins.currentSystem,
}:
let nixpkgs = import ./nix { inherit system; }; in
let stdenv = nixpkgs.stdenv; in
let subpath = p: import ./nix/gitSource.nix p; in
rec {
interface-spec =
nixpkgs.stdenv.mkDerivation {
name = "interface-spec";
src = subpath ./spec;
phases = [ "unpackPhase" "buildPhase" "checkPhase" ];
buildInputs = with nixpkgs;
[ asciidoctor plantuml jre graphviz python cpio html-proofer cddl ];
FONTCONFIG_FILE = nixpkgs.makeFontsConf { fontDirectories = []; };
asciidoctor_args = [
"-r asciidoctor-diagram"
"-a sectanchors"
"-a plantuml-format=svg"
"-a ditaa-format=svg"
"-a graphviz-format=svg"
"-a source-highlighter=rouge"
"-a rouge-css=style"
];
buildPhase = ''
doc_path="spec"
mkdir -p $out/$doc_path
asciidoctor $asciidoctor_args --failure-level WARN -v \
-a toc2 -a toclevels=3 \
-a example -a partial \
-a attachmentsdir=. \
-R $PWD -D $out/$doc_path/ index.adoc
find . -type f -name '*.png' | cpio -pdm $out/$doc_path/
cp *.cddl $out/$doc_path
cp *.did $out/$doc_path
cp *.txt $out/$doc_path
mkdir -p $out/nix-support
echo "report spec $out/$doc_path index.html" >> $out/nix-support/hydra-build-products
'';
# These ones are needed for htmlproofer
LOCALE_ARCHIVE = nixpkgs.lib.optionalString nixpkgs.stdenv.isLinux "${nixpkgs.glibcLocales}/lib/locale/locale-archive";
LANG = "en_US.UTF-8";
LC_TYPE = "en_US.UTF-8";
LANGUAGE = "en_US.UTF-8";
doCheck = true;
checkPhase = ''
htmlproofer --disable-external $out/$doc_path
if [[ ! -s $out/$doc_path/index.html ]]; then
>&2 echo "There is no $out/$doc_path/index.html or it is empty, aborting."
exit 1
fi
# also check cddl
for file in *.cddl; do cddl $file generate 1 > /dev/null; done
'';
};
# for compatibility with the deployment to https://docs.dfinity.systems/public/v
public-spec = interface-spec;
all-systems-go = nixpkgs.releaseTools.aggregate {
name = "all-systems-go";
constituents = [
interface-spec
];
};
}