-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
100 lines (98 loc) · 2.65 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
{
description = "Ocaml WebAssembly toolings";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = {
self,
nixpkgs,
flake-utils,
...
}:
flake-utils.lib.eachDefaultSystem (
system: let
pkgs = import nixpkgs {inherit system;};
frameworks = pkgs.darwin.apple_sdk.frameworks;
in rec {
devShells.default = pkgs.mkShell {
buildInputs = with pkgs;
[
nil
alejandra
opam
ocamlPackages.ocaml
ocamlPackages.dune_3
ocamlPackages.ocaml-lsp
ocamlPackages.batteries
ocamlPackages.alcotest
ocamlPackages.findlib
ocamlPackages.ocamlformat
ocamlPackages.odoc
wabt
wasmtime
]
++ lib.optional stdenv.isDarwin [
frameworks.Security
frameworks.CoreFoundation
frameworks.CoreServices
];
shellHook = ''
eval $(opam env)
'';
};
checks = {
tests = pkgs.ocamlPackages.buildDunePackage {
pname = "wascaml";
version = "0.1.0";
src = ./.;
duneVersion = "3";
doBuild = false;
doCheck = true;
checkPhase = ''
runHook preCheck
export HOME=$(pwd)
dune runtest
runHook postCheck
'';
checkInputs = with pkgs; [
ocamlPackages.alcotest
];
nativeCheckInputs = with pkgs; [
wasmtime
];
};
};
packages.wascaml = pkgs.ocamlPackages.buildDunePackage {
pname = "wascaml";
version = "0.1.0";
src = ./.;
duneVersion = "3";
doCheck = false;
};
packages.docs = pkgs.stdenv.mkDerivation {
pname = "generate-dune-documents";
version = "0.1.0";
src = ./.;
buildInputs = with pkgs; [
ocamlPackages.ocaml
ocamlPackages.dune_3
ocamlPackages.odoc
opam
];
buildPhase = ''
dune build @doc
'';
installPhase = ''
mkdir -p $out/share/doc
cp -r _build/default/_doc/_html/* $out/share/doc
'';
};
packages.default = packages.wascaml;
apps.${system}.default = {
type = "app";
program = "${self.packages.default}/bin/wascaml";
};
}
);
}