-
Notifications
You must be signed in to change notification settings - Fork 70
/
default.nix
101 lines (87 loc) · 2.67 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
101
{ # Is this a nix-shell invocation?
inNixShell ? false
# Do we want the full Agda package for interactive use? Set to false in CI
, interactive ? true
, system ? builtins.currentSystem
}:
let
pkgs = import ./support/nix/nixpkgs.nix { inherit system; };
inherit (pkgs) lib;
our-ghc = pkgs.labHaskellPackages.ghcWithPackages (ps: with ps; ([
shake directory tagsoup
text containers uri-encode
process aeson Agda pandoc SHA
fsnotify
] ++ (if interactive then [ haskell-language-server ] else [])));
our-texlive = pkgs.texlive.combine {
inherit (pkgs.texlive)
collection-basic
collection-latex
xcolor
preview
pgf tikz-cd braids
mathpazo
varwidth xkeyval standalone;
};
shakefile = pkgs.callPackage ./support/nix/build-shake.nix {
inherit our-ghc;
name = "1lab-shake";
main = "Main.hs";
};
sort-imports = let
script = builtins.readFile support/sort-imports.hs;
# Extract the list of dependencies from the stack shebang comment.
deps = lib.concatLists (lib.filter (x: x != null)
(map (builtins.match ".*--package +([^[:space:]]*).*")
(lib.splitString "\n" script)));
in pkgs.writers.writeHaskellBin "sort-imports" {
ghc = pkgs.labHaskellPackages.ghc;
libraries = lib.attrVals deps pkgs.labHaskellPackages;
} script;
deps = with pkgs; [
# For driving the compilation:
shakefile
# For building the text and maths:
gitMinimal nodePackages.sass
# For building diagrams:
poppler_utils our-texlive
] ++ (if interactive then [
our-ghc
sort-imports
] else [
labHaskellPackages.Agda.data
labHaskellPackages.pandoc.data
]);
in
pkgs.stdenv.mkDerivation rec {
name = "1lab";
src = if inNixShell then null else
with pkgs.nix-gitignore; gitignoreFilterSourcePure (_: _: true) [
# Keep .git around for extracting page authors
(compileRecursiveGitignore ./.)
".github"
] ./.;
nativeBuildInputs = deps;
shellHook = ''
export out=_build/site
'';
LANG = "C.UTF-8";
buildPhase = ''
1lab-shake all -j
'';
installPhase = ''
# Copy our build artifacts
mkdir -p $out
cp -Lrvf _build/html/* $out
# Copy KaTeX CSS and fonts
mkdir -p $out/css
cp -Lrvf --no-preserve=mode ${pkgs.nodePackages.katex}/lib/node_modules/katex/dist/{katex.min.css,fonts} $out/css/
mkdir -p $out/static/ttf
cp -Lrvf --no-preserve=mode ${pkgs.julia-mono}/share/fonts/truetype/JuliaMono-Regular.ttf $out/static/ttf/julia-mono.ttf
'';
passthru = {
inherit deps shakefile sort-imports;
texlive = our-texlive;
ghc = our-ghc;
};
}