-
Notifications
You must be signed in to change notification settings - Fork 1
/
flake.nix
46 lines (43 loc) · 1.49 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
{
inputs = {
opam-nix.url = "github:RyanGibb/opam-nix/pin-depends-path";
flake-utils.url = "github:numtide/flake-utils";
# we pin opam-nix's nixpkgs to follow the flakes, avoiding using two different instances
opam-nix.inputs.nixpkgs.follows = "nixpkgs";
# maintain a different opam-repository to those pinned upstream
opam-repository = {
url = "github:ocaml/opam-repository";
flake = false;
};
opam-nix.inputs.opam-repository.follows = "opam-repository";
# deduplicate flakes
opam-nix.inputs.flake-utils.follows = "flake-utils";
};
outputs = { self, nixpkgs, flake-utils, opam-nix, ... }@inputs:
# create outputs for each default system
flake-utils.lib.eachDefaultSystem (system:
let
package = "shark";
pkgs = nixpkgs.legacyPackages.${system};
opam-nix-lib = opam-nix.lib.${system};
devPackagesQuery = {
ocaml-lsp-server = "*";
ocamlformat = "*";
utop = "*";
};
query = {
ocaml-base-compiler = "*";
};
scope = opam-nix-lib.buildOpamProject' { } ./. (query // devPackagesQuery);
in {
packages = scope;
defaultPackage = scope.${package};
devShells.default = let
devPackages = builtins.attrValues
(pkgs.lib.getAttrs (builtins.attrNames devPackagesQuery) scope);
in pkgs.mkShell {
inputsFrom = [ scope.${package} ];
buildInputs = devPackages;
};
});
}