-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdefault.nix
100 lines (78 loc) · 1.91 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
{ lib
, buildNpmPackage
, writeShellScriptBin
, julia
, python3
, glibcLocales
, gnugrep
, which
, validator-nu
, lychee
}:
buildNpmPackage rec {
name = "cgdct-moe";
src = ../..;
npmDepsHash = "sha256-iqUwXXAQSjKgghyavvwqoTukqSMG57OUFJFDDmMsmSg=";
site = "__site";
julia' = julia.withPackages [
"Dates"
"Franklin"
"JSON"
"JuliaFormatter"
"SHA"
];
python' = python3.withPackages (ps: with ps; [
beautifulsoup4
lxml
]);
# filter spurious warning messages during build
filter = writeShellScriptBin "filter" ''
${lib.getExe gnugrep} \
--invert-match \
--regexp 'Unicode text character "[女時金悪]" used in math mode' \
"$@"
'';
configurePhase = ''
runHook preConfigure
export LOCALE_ARCHIVE="${glibcLocales}/lib/locale/locale-archive"
export LANG=en_US.UTF-8
# give a valid node binary to Franklin.jl
# https://github.com/tlienart/Franklin.jl/pull/1069
NODE="$(which node)"
export NODE
runHook postConfigure
'';
strictDeps = true;
nativeBuildInputs = [ julia' python' which ];
buildPhase = ''
runHook preBuild
julia --optimize=0 --color=yes --eval "
using Franklin: optimize
optimize(clear=true, prerender=true, minify=false)
" 2> >("${lib.getExe filter}" >&2)
runHook postBuild
'';
postBuild = ''
python src/postprocess --verbose ${site}
# don't ignore files in .gitignore
npx prettier --write ${site} --ignore-path=.prettierignore
'';
doCheck = true;
nativeCheckInputs = [ validator-nu lychee ];
checkPhase = ''
runHook preCheck
source bin/vnu ${site}
runHook postCheck
'';
installPhase = ''
runHook preInstall
cp -r ${site} -T $out
runHook postInstall
'';
meta = with lib; {
description = "Stephen Huan's personal website";
homepage = "https://cgdct.moe/";
license = licenses.unlicense;
maintainers = [ ];
};
}