-
Notifications
You must be signed in to change notification settings - Fork 1
/
flake.nix
79 lines (67 loc) · 1.84 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
{
inputs = {
nixpkgs.url = "nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
opam-nix = {
url = "github:tweag/opam-nix";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "flake-utils";
};
};
outputs = {
self,
flake-utils,
opam-nix,
nixpkgs,
}: let
makeOpamPkgs = {
devPackages,
ocamlVersion,
overlay ? (final: prev: {}),
}: system: let
pkgs = import nixpkgs {
inherit system;
};
opamNixLib = opam-nix.lib.${system};
localPackagesQuery =
builtins.mapAttrs (_: pkgs.lib.last)
(opamNixLib.listRepo (opamNixLib.makeOpamRepo ./.));
devPackagesQuery = devPackages;
query =
devPackagesQuery
// {ocaml-base-compiler = ocamlVersion;};
scope = (opamNixLib.buildOpamProject' {} ./. query).overrideScope overlay;
devPackages' =
builtins.attrValues
(pkgs.lib.getAttrs (builtins.attrNames devPackagesQuery) scope);
packages = pkgs.lib.getAttrs (builtins.attrNames localPackagesQuery) scope;
in {
legacyPackages = scope;
devPackages = devPackages';
inherit packages;
};
perSystem = makeOpamPkgs {
ocamlVersion = "5.1.1";
devPackages = {
ocaml-lsp-server = "*";
ocamlformat = "*";
utop = "*";
};
};
in
flake-utils.lib.eachDefaultSystem (system: let
pkgs = import nixpkgs {
inherit system;
};
p = perSystem system;
in {
legacyPackages = p.legacyPackages;
packages = p.packages;
devShells.default = pkgs.mkShell {
inputsFrom = builtins.attrValues p.packages;
buildInputs =
p.devPackages
++ pkgs.lib.optional (builtins.elem system pkgs.xtrace.meta.platforms) pkgs.xtrace;
};
});
}