summaryrefslogtreecommitdiff
path: root/flake.nix
diff options
context:
space:
mode:
Diffstat (limited to 'flake.nix')
-rw-r--r--flake.nix54
1 files changed, 54 insertions, 0 deletions
diff --git a/flake.nix b/flake.nix
new file mode 100644
index 0000000..bcd9ed1
--- /dev/null
+++ b/flake.nix
@@ -0,0 +1,54 @@
1{
2 inputs = {
3 opam-nix.url = "github:tweag/opam-nix";
4 flake-utils.url = "github:numtide/flake-utils";
5 nixpkgs.follows = "opam-nix/nixpkgs";
6 };
7 outputs = { self, nixpkgs, flake-utils, opam-nix, ... }:
8 flake-utils.lib.eachDefaultSystem (system:
9 let
10 pkgs = import nixpkgs { inherit system; };
11
12 package = "sand";
13 on = opam-nix.lib.${system};
14 localPackagesQuery = builtins.mapAttrs (_: pkgs.lib.last)
15 (on.listRepo (on.makeOpamRepo ./.));
16 devPackagesQuery = {
17 ocaml-lsp-server = "*";
18 ocamlformat = "*";
19 utop = "*";
20 };
21 query = devPackagesQuery // {
22 ocaml-base-compiler = "*";
23 };
24 scope = on.buildDuneProject { } package ./. query;
25 overlay = final: prev:
26 {
27 # You can add overrides here
28 };
29 scope' = scope.overrideScope' overlay;
30 # Packages from devPackagesQuery
31 devPackages = builtins.attrValues
32 (pkgs.lib.getAttrs (builtins.attrNames devPackagesQuery) scope');
33 # Packages in this workspace
34 packages =
35 pkgs.lib.getAttrs (builtins.attrNames localPackagesQuery) scope';
36 in {
37 legacyPackages = scope';
38
39 inherit packages;
40
41 devShells.default = pkgs.mkShell {
42
43 inputsFrom = builtins.attrValues packages;
44
45 buildInputs = devPackages ++ [
46 # You can add packages from nixpkgs here
47 ];
48
49 shellHook = ''
50 echo "version = `ocamlformat --version`" > .ocamlformat
51 '';
52 };
53 });
54}