-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
197 lines (172 loc) · 5.05 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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
utils.url = "github:numtide/flake-utils";
pre-commit.url = "github:cachix/pre-commit-hooks.nix";
crane = {
url = "github:ipetkov/crane";
inputs.nixpkgs.follows = "nixpkgs";
};
fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = {
self,
nixpkgs,
utils,
crane,
pre-commit,
fenix,
...
}:
utils.lib.eachDefaultSystem (system: let
pkgs = nixpkgs.legacyPackages.${system};
craneLib = (crane.mkLib pkgs).overrideToolchain toolchain;
craneLibWindows = (crane.mkLib pkgs).overrideToolchain toolchainWindows;
toolchain = with fenix.packages.${system};
combine [
stable.rustc
stable.cargo
stable.rustfmt
stable.rust-analyzer
targets.wasm32-unknown-unknown.stable.rust-std
];
toolchainWindows = with fenix.packages.${system};
combine [
stable.rustc
stable.cargo
targets.x86_64-pc-windows-gnu.stable.rust-std
];
libPath = with pkgs;
lib.makeLibraryPath [
libGL
libxkbcommon
wayland
xorg.libX11
xorg.libXcursor
xorg.libXrandr
xorg.libXi
];
src = pkgs.lib.cleanSourceWith {
src = ./.;
filter = path: type:
(pkgs.lib.hasSuffix "\.html" path)
|| (pkgs.lib.hasSuffix "\.scss" path)
|| (pkgs.lib.hasInfix "/assets/" path)
|| (craneLib.filterCargoSources path type);
};
commonArgs = {
inherit src;
strictDeps = true;
};
cargoArtifacts = craneLib.buildDepsOnly {
inherit src;
buildInputs = with pkgs;
[pkg-config]
++ lib.optional (stdenv.isLinux) alsa-lib;
doCheck = false;
};
cargoArtifactsWasm = craneLib.buildDepsOnly {
inherit src;
doCheck = false;
CARGO_BUILD_TARGET = "wasm32-unknown-unknown";
};
in {
packages.default = craneLib.buildPackage (commonArgs
// {
inherit cargoArtifacts;
buildInputs = with pkgs;
[pkg-config]
++ lib.optional (stdenv.isLinux) alsa-lib;
LD_LIBRARY_PATH = libPath;
});
packages.x86_64-pc-windows-gnu = craneLibWindows.buildPackage (commonArgs
// {
inherit src;
depsBuildBuild = with pkgs; [
pkg-config
pkgsCross.mingwW64.stdenv.cc
pkgsCross.mingwW64.windows.pthreads
];
doCheck = false;
CARGO_BUILD_TARGET = "x86_64-pc-windows-gnu";
});
packages.gh-pages = craneLib.buildTrunkPackage (commonArgs
// {
inherit (pkgs) wasm-bindgen-cli;
inherit cargoArtifactsWasm;
trunkExtraBuildArgs = "--public-url octarou/";
CARGO_BUILD_TARGET = "wasm32-unknown-unknown";
});
formatter = pkgs.alejandra;
checks.pre-commit-check = pre-commit.lib.${system}.run {
src = ./.;
hooks = {
alejandra = {
enable = true;
excludes = ["doc"];
};
taplo.enable = true;
rustfmt.enable = true;
# clippy.enable = true;
};
};
devShell = craneLib.devShell {
inherit (self.checks.${system}.pre-commit-check) shellHook;
inputsFrom = [self.packages.${system}.default];
packages = with pkgs; [
trunk
nodePackages.conventional-changelog-cli
];
LD_LIBRARY_PATH = libPath;
};
packages.paper = with pkgs;
stdenvNoCC.mkDerivation rec {
name = "ocatrou-paper";
src = ./doc/paper/src;
buildInputs = [
coreutils
biber
python311Packages.pygments
which
(texlive.combine {
inherit
(texlive)
scheme-medium
biblatex
csquotes
minted
ifoddpage
relsize
tablefootnote
xifthen
ifmtarg
;
})
];
phases = ["unpackPhase" "buildPhase" "installPhase"];
buildPhase = ''
export PATH="${lib.makeBinPath buildInputs}"
mkdir -p .cache/texmf-var
which pygmentize 1> /dev/null
env TEXMFHOME=.cache TEXMFVAR=.cache/texmf-var \
latexmk -interaction=nonstopmode -pdf -lualatex -pdflualatex="lualatex -shell-escape %O %S"
'';
installPhase = ''
mkdir -p $out/doc
cp main.pdf $out/doc/paper.pdf
'';
};
devShells.paper = with pkgs;
mkShell {
inherit (self.checks.${system}.pre-commit-check) shellHook;
inputsFrom = [self.packages.${system}.paper];
packages = [
texlab
bibtex-tidy
];
};
});
}