forked from coln-project/Coln
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
270 lines (237 loc) · 8.52 KB
/
Copy pathflake.nix
File metadata and controls
270 lines (237 loc) · 8.52 KB
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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-26.05";
flake-utils.url = "github:numtide/flake-utils";
rust-overlay.url = "github:oxalica/rust-overlay";
ghc-wasm-meta.url = "gitlab:haskell-wasm/ghc-wasm-meta?host=gitlab.haskell.org";
};
outputs =
inputs@{
self,
nixpkgs,
rust-overlay,
...
}:
inputs.flake-utils.lib.eachSystem [ "x86_64-linux" "aarch64-darwin" ] (
system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [
rust-overlay.overlays.default
(import ./nix/haskell-packages.nix)
];
};
inherit (pkgs) colnHaskellPackages;
rustToolchain = pkgs.rust-bin.stable.latest.default.override {
extensions = [ "rust-src" "rust-analyzer" ];
targets = [ "wasm32-unknown-unknown" ];
};
packages = let
nuShellCheck = inputs: f: pkgs.stdenv.mkDerivation {
name = "nuShellCheck";
src = ./.;
nativeBuildInputs = [pkgs.nushell] ++ inputs;
buildPhase = ''
nu ${f}
'';
installPhase = ''
touch $out
'';
};
in rec {
forester = pkgs.callPackage ./nix/forester.nix { };
diagnostician = colnHaskellPackages.callPackage ./packages/diagnostician { };
diagnostician-terminal = colnHaskellPackages.callPackage ./packages/diagnostician-terminal {
inherit diagnostician;
};
diagnostician-html = colnHaskellPackages.callPackage ./packages/diagnostician-html {
inherit diagnostician;
};
fnotation = colnHaskellPackages.callPackage ./packages/fnotation {
inherit diagnostician;
};
coln-compiler = colnHaskellPackages.callPackage ./packages/coln-compiler {
inherit diagnostician fnotation;
};
coln-repl = colnHaskellPackages.callPackage ./packages/coln-repl {
inherit coln-compiler diagnostician diagnostician-terminal fnotation;
};
coln-ls = colnHaskellPackages.callPackage ./packages/coln-ls {
inherit coln-compiler diagnostician fnotation;
};
coln-manual-dev = colnHaskellPackages.callPackage ./packages/coln-manual-dev {};
coln-cli = colnHaskellPackages.callPackage ./packages/coln-cli {
inherit coln-compiler coln-repl coln-ls diagnostician diagnostician-terminal fnotation;
};
haskell-tests = pkgs.writeScript "haskell-tests" ''
echo "built diagnostician: ${diagnostician}"
echo "built diagnostician-terminal: ${diagnostician-terminal}"
echo "built diagnostician-html: ${diagnostician-html}"
echo "built fnotation: ${fnotation}"
echo "built coln-compiler: ${coln-compiler}"
echo "built coln-repl: ${coln-repl}"
echo "built coln-ls: ${coln-ls}"
echo "built coln-cli: ${coln-cli}"
'';
wasm-bodge = pkgs.rustPlatform.buildRustPackage rec {
pname = "wasm-bodge";
version = "0.3.1";
src = pkgs.fetchCrate {
inherit pname version;
hash = "sha256-Vr+ribYXO7+TpXzH8nlbp5cPg5I0lcxXjTfQNwkg3/Y=";
};
cargoHash = "sha256-tARojdKFjnkCeJIhgpMFEvfxrOTOH8L3cAvE2UQm0jY=";
doCheck = false;
};
wasm-bindgen-cli = pkgs.rustPlatform.buildRustPackage rec {
pname = "wasm-bindgen-cli";
version = "0.2.125";
src = pkgs.fetchCrate {
inherit pname version;
hash = "sha256-zRawtjxMOdTMX+mZaiNR3YYfTiZJhf9qj7kXSSeMxrc=";
};
cargoHash = "sha256-aZCfgR23Qb0Pn4Mm4ToMtuuRQqSJjXCR9li/VvP5CTM=";
doCheck = false;
};
build-sync-demo = pkgs.writeShellApplication {
name = "build-sync-demo";
runtimeInputs = [
coln-cli
pkgs.binaryen
pkgs.esbuild
pkgs.nodejs_24
pkgs.pnpm
rustToolchain
wasm-bindgen-cli
wasm-bodge
];
text = ''
repo_root="''${1:-$PWD}"
cd "$repo_root"
export CI="''${CI:-1}"
pnpm_store_dir="''${PNPM_STORE_DIR:-$repo_root/.pnpm-store}"
npm ci --prefix packages/coln-js-runtime
npm run --prefix packages/coln-js-runtime build
pnpm --dir examples/sync-demo install --frozen-lockfile --store-dir "$pnpm_store_dir"
pnpm --dir examples/sync-demo build
echo "Built sync demo at $repo_root/examples/sync-demo/dist"
'';
};
format-hs = nuShellCheck [pkgs.fourmolu] ./nix/checks/format-hs.nu;
format-cabal = nuShellCheck [pkgs.haskellPackages.cabal-gild] ./nix/checks/format-cabal.nu;
manual = pkgs.stdenv.mkDerivation {
name = "coln-manual";
src = ./manual;
buildPhase = ''
${forester}/bin/forester build
'';
installPhase = ''
cp -r output $out
'';
};
vscode-extension = pkgs.buildNpmPackage {
pname = "coln-vscode-extension";
version = "0.1.0";
src = ./packages/coln-ls/client;
npmDeps = lsClientNpmDeps;
npmConfigHook = pkgs.importNpmLock.npmConfigHook;
postUnpack = ''
cp ${coln-cli}/bin/coln $sourceRoot/
cp -r ${./LICENSES} $sourceRoot/LICENSES
cat ${./LICENSES}/Apache-2.0.txt ${./LICENSES}/MIT.txt > $sourceRoot/LICENSE
'';
postPatch = ''
substituteInPlace package.json \
--replace-fail "cp -r ../../../LICENSES LICENSES" "true"
'';
nativeBuildInputs = [ pkgs.vsce ];
dontNpmBuild = true;
buildPhase = ''
vsce package --allow-missing-repository
'';
installPhase = ''
cp *.vsix $out
'';
};
default = coln-cli;
};
inherit (packages) forester coln-manual-dev;
haskell-wasm = inputs.ghc-wasm-meta.packages.${system};
lsTsDir = ./packages/coln-ls/client;
lsClientNpmDeps = pkgs.importNpmLock {
npmRoot = lsTsDir;
};
lsClientNodeModules = pkgs.importNpmLock.buildNodeModules {
npmRoot = lsTsDir;
nodejs = pkgs.nodejs_24;
};
in
{
inherit packages;
apps = let
buildSyncDemo = {
type = "app";
program = "${pkgs.lib.getExe packages.build-sync-demo}";
};
in {
build-sync-demo = buildSyncDemo;
sync-demo = buildSyncDemo;
};
devShells.default = pkgs.mkShell {
name = "coln";
buildInputs = with pkgs; [
cabal-install
cabal2nix
cargo-llvm-cov
cargo-nextest
coln-manual-dev
forester
fourmolu
esbuild
haskell-wasm.wasm32-wasi-ghc-9_14
haskell-wasm.wasm32-wasi-cabal-9_14
haskell.compiler.ghc912
haskell.packages.ghc912.haskell-language-server
haskellPackages.cabal-gild
jq
just
nodejs_24
pnpm
packages.wasm-bodge
rustToolchain
packages.wasm-bindgen-cli
binaryen
openssl
pkg-config
reuse
simple-http-server
tectonic
typescript
vtsls
zlib
zlib.dev
];
shellHook = ''
# GCC 15 (nixos-26.05) defaults to -std=gnu23 which removed ATOMIC_VAR_INIT.
# This breaks mimalloc-rust-sys, which is a dependency of dbsp.
export CFLAGS="''${CFLAGS:+$CFLAGS }-std=gnu17"
'';
};
devShells.vscode-extension = pkgs.mkShell {
name = "coln-vscode-extension";
buildInputs = with pkgs; [
nodejs_24
typescript
vtsls
];
shellHook = ''
ln -sfn ${lsClientNodeModules}/node_modules "$PWD"/node_modules
'';
};
});
nixConfig = {
extra-substituters = [ "https://coln.cachix.org" ];
extra-trusted-public-keys = [ "coln.cachix.org-1:xplHZrvUVve3NSquwwW5QRl6MYbDBHx3rw3Np69kjw4=" ];
};
}