-
Notifications
You must be signed in to change notification settings - Fork 1
/
flake.nix
72 lines (63 loc) · 2.08 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
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
opam-repository = { url = "github:ocaml/opam-repository"; flake = false; };
flake-utils.url = "github:numtide/flake-utils";
opam-nix = {
url = "github:tweag/opam-nix";
inputs = {
nixpkgs.follows = "nixpkgs";
flake-utils.follows = "flake-utils";
opam-repository.follows = "opam-repository";
};
};
};
outputs = { self, flake-utils, opam-nix, nixpkgs, opam-repository, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
on = opam-nix.lib.${system};
src = ./.;
localNames =
with builtins;
filter
(f: !isNull f)
(map (f:
let f' = match "(.*)\.opam$" f; in
if isNull f' then null else elemAt f' 0)
(attrNames (readDir ./.)));
localPackagesQuery =
with builtins; listToAttrs (map (p: {
name = p;
value = "*";
}) localNames);
devPackagesQuery = {
ocaml-lsp-server = "*";
utop = "*";
ocamlformat = pkgs.callPackage ./nix/ocamlformat.nix { ocamlformat = ./.ocamlformat; };
};
query = devPackagesQuery // localPackagesQuery // {
ocaml-system = "*";
};
overlay = final: prev:
builtins.mapAttrs (p: _:
prev.${p}.overrideAttrs (_: {
doNixSupport = false;
})) localPackagesQuery;
scope =
let scp = on.buildOpamProject' {
inherit pkgs;
resolveArgs = { with-test = true; with-doc = true; };
} src query;
in scp.overrideScope' overlay;
devPackages = builtins.attrValues
(pkgs.lib.getAttrs (builtins.attrNames devPackagesQuery) scope);
in {
legacyPackages = scope;
devShells.default =
pkgs.mkShell {
inputsFrom = builtins.map (p: scope.${p} ) localNames;
buildInputs = devPackages;
};
});
}