-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathflake.nix
113 lines (105 loc) · 3.76 KB
/
flake.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
102
103
104
105
106
107
108
109
110
111
112
113
{
inputs = {
nixpkgs.url = github:NixOS/nixpkgs/nixos-24.05;
opam-nix.url = "github:tweag/opam-nix";
opam-nix.inputs.nixpkgs.follows = "nixpkgs";
opam-repository = {
url = "github:ocaml/opam-repository";
flake = false;
};
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, flake-utils, opam-nix, nixpkgs, opam-repository }@inputs:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
tex = pkgs.texlive.combine {
inherit (pkgs.texlive)
# https://tug.org/texlive/devsrc/Master/doc.html
scheme-minimal latex-bin xetex latexmk beamer
infwarerr kvoptions latex-tools-dev
libertine
mathpartir stmaryrd frankenstein multirow
colortbl cmll euler fontspec tools extsizes
minibox varwidth fragments psnfss csquotes
ulem xltxtra realscripts booktabs todonotes
pdfcomment datetime2 tracklang zref marginnote
soulpos appendixnumberbeamer;
};
on = opam-nix.lib.${system};
localPackagesQuery = builtins.mapAttrs (_: pkgs.lib.last)
(on.listRepo (on.makeOpamRepo ./.));
devPackagesQuery = {
# You can add "development" packages here. They will get
# added to the devShell automatically.
ocaml-lsp-server = "*";
ocamlformat = "*";
utop = "*";
};
query = devPackagesQuery // {
## You can force versions of certain packages here, e.g:
## - force the ocaml compiler to be taken from opam-repository:
ocaml-base-compiler = "5.2.0";
## - or force the compiler to be taken from nixpkgs and be a certain version:
# ocaml-system = "4.14.0";
## - or force ocamlfind to be a certain version:
# ocamlfind = "1.9.2";
};
scope = on.buildOpamProject' { repos = [opam-repository]; } ./. query;
overlay = final: prev:
{
# You can add overrides here
};
scope' = scope.overrideScope overlay;
# Packages from devPackagesQuery
devPackages = builtins.attrValues
(pkgs.lib.getAttrs (builtins.attrNames devPackagesQuery) scope');
# Packages in this workspace
opam_packages =
pkgs.lib.getAttrs (builtins.attrNames localPackagesQuery) scope';
in rec {
# legacyPackages = scope';
packages = opam_packages // {
slides = pkgs.stdenvNoCC.mkDerivation rec {
name = "slides";
src = self;
buildInputs = [ pkgs.coreutils pkgs.bash tex pkgs.gnumake ];
phases = ["unpackPhase" "buildPhase" "installPhase"];
buildPhase = ''
export PATH="${pkgs.lib.makeBinPath buildInputs}";
mkdir -p .cache/texmf-var;
export TEXMFHOME=.cache;
export TEXMFVAR=.cache/texmf-var;
make -C slides -j 8 all
'';
installPhase = ''
mkdir -p $out;
for w in 1 2 3 4 5 6 7 8 9 10; do
outfile=$(printf "week%02d-slides.pdf" $w);
cp slides/week$w.pdf $out/$outfile;
done;
'';
};
site = pkgs.stdenvNoCC.mkDerivation rec {
name = "site";
src = self;
buildInputs = [ packages.site_gen packages.frontend packages.slides ];
phases = ["unpackPhase" "installPhase"];
installPhase = ''
mkdir -p $out;
site_gen pages $out;
cp assets/*.css $out;
cp assets/sat-solver-notes.pdf $out;
cp ${packages.slides}/*.pdf $out;
cp ${packages.frontend}/share/frontend/frontend.bc.js $out;
'';
};
};
devShells.default = pkgs.mkShell {
inputsFrom = builtins.attrValues packages;
buildInputs = devPackages ++ [
pkgs.rsync
];
};
});
}