|
3 | 3 |
|
4 | 4 | inputs = { |
5 | 5 | nix-filter.url = "github:numtide/nix-filter"; |
6 | | - flake-utils.url = "github:numtide/flake-utils"; |
7 | | - nixpkgs = { |
8 | | - url = "github:nix-ocaml/nix-overlays"; |
9 | | - inputs.flake-utils.follows = "flake-utils"; |
10 | | - }; |
| 6 | + nixpkgs.url = "github:nix-ocaml/nix-overlays"; |
11 | 7 | }; |
12 | 8 |
|
13 | | - outputs = { self, nixpkgs, flake-utils, nix-filter }: |
14 | | - flake-utils.lib.eachDefaultSystem (system: |
15 | | - let |
16 | | - pkgs = nixpkgs.legacyPackages."${system}".appendOverlays [ |
17 | | - (self: super: { ocamlPackages = super.ocaml-ng.ocamlPackages_5_2; }) |
18 | | - ]; |
19 | | - |
20 | | - makeDevShell = { packages, release-mode ? false }: |
21 | | - pkgs.mkShell { |
22 | | - # dontDetectOcamlConflicts = true; |
23 | | - inputsFrom = pkgs.lib.attrValues packages; |
24 | | - nativeBuildInputs = |
25 | | - with pkgs.ocamlPackages; [ ocamlformat pkgs.nodejs_latest ] |
26 | | - ++ pkgs.lib.optionals release-mode (with pkgs; [ |
27 | | - cacert |
28 | | - curl |
29 | | - ocamlPackages.dune-release |
30 | | - ocamlPackages.odoc |
31 | | - git |
32 | | - ]); |
33 | | - propagatedBuildInputs = with pkgs.ocamlPackages; [ merlin ]; |
34 | | - }; |
35 | | - in |
36 | | - |
37 | | - rec { |
38 | | - packages = with pkgs.ocamlPackages; rec { |
39 | | - reason-react-ppx = buildDunePackage { |
40 | | - pname = "reason-react-ppx"; |
41 | | - version = "n/a"; |
42 | | - src = with nix-filter.lib; filter { |
43 | | - root = ./.; |
44 | | - include = [ |
45 | | - "dune-project" |
46 | | - "dune" |
47 | | - "reason-react-ppx.opam" |
48 | | - "reason-react.opam" |
49 | | - "ppx" |
50 | | - ]; |
| 9 | + outputs = { self, nixpkgs, nix-filter }: |
| 10 | + let |
| 11 | + forAllSystems = f: nixpkgs.lib.genAttrs nixpkgs.lib.systems.flakeExposed (system: |
| 12 | + let |
| 13 | + pkgs = nixpkgs.legacyPackages.${system}.extend (self: super: { |
| 14 | + ocamlPackages = super.ocaml-ng.ocamlPackages_5_2.overrideScope (oself: osuper: { |
| 15 | + ppxlib = osuper.ppxlib.overrideAttrs (o: { |
| 16 | + propagatedBuildInputs = o.propagatedBuildInputs ++ [ osuper.stdio ]; |
| 17 | + }); |
| 18 | + }); |
| 19 | + }); |
| 20 | + in |
| 21 | + f pkgs); |
| 22 | + in |
| 23 | + { |
| 24 | + packages = forAllSystems (pkgs: |
| 25 | + let |
| 26 | + inherit (pkgs.ocamlPackages) |
| 27 | + buildDunePackage melange merlin ppxlib reason; |
| 28 | + packages = rec { |
| 29 | + reason-react-ppx = buildDunePackage { |
| 30 | + pname = "reason-react-ppx"; |
| 31 | + version = "n/a"; |
| 32 | + src = with nix-filter.lib; filter { |
| 33 | + root = ./.; |
| 34 | + include = [ |
| 35 | + "dune-project" |
| 36 | + "dune" |
| 37 | + "reason-react-ppx.opam" |
| 38 | + "reason-react.opam" |
| 39 | + "ppx" |
| 40 | + ]; |
| 41 | + }; |
| 42 | + # Due to a Reason version mismatch, the generated OCaml PPX diff |
| 43 | + # looks different |
| 44 | + doCheck = false; |
| 45 | + checkInputs = [ ]; |
| 46 | + checkPhase = "dune build @runtest -p reason-react,reason-react-ppx"; |
| 47 | + nativeCheckInputs = [ reason merlin pkgs.jq ]; |
| 48 | + propagatedBuildInputs = [ ppxlib ]; |
51 | 49 | }; |
52 | | - # Due to a Reason version mismatch, the generated OCaml PPX diff |
53 | | - # looks different |
54 | | - doCheck = false; |
55 | | - checkInputs = [ ]; |
56 | | - checkPhase = "dune build @runtest -p reason-react,reason-react-ppx"; |
57 | | - nativeCheckInputs = [ reason merlin pkgs.jq ]; |
58 | | - propagatedBuildInputs = [ ppxlib ]; |
59 | | - }; |
60 | 50 |
|
61 | | - reason-react = buildDunePackage { |
62 | | - pname = "reason-react"; |
63 | | - version = "n/a"; |
64 | | - src = with nix-filter.lib; filter { |
65 | | - root = ./.; |
66 | | - include = [ |
67 | | - "dune-project" |
68 | | - "dune" |
69 | | - "reason-react-ppx.opam" |
70 | | - "reason-react.opam" |
71 | | - "src" |
72 | | - "test" |
73 | | - ]; |
| 51 | + reason-react = buildDunePackage { |
| 52 | + pname = "reason-react"; |
| 53 | + version = "n/a"; |
| 54 | + src = with nix-filter.lib; filter { |
| 55 | + root = ./.; |
| 56 | + include = [ |
| 57 | + "dune-project" |
| 58 | + "dune" |
| 59 | + "reason-react-ppx.opam" |
| 60 | + "reason-react.opam" |
| 61 | + "src" |
| 62 | + "test" |
| 63 | + ]; |
| 64 | + }; |
| 65 | + doCheck = true; |
| 66 | + nativeBuildInputs = [ melange reason ]; |
| 67 | + propagatedBuildInputs = [ melange reason-react-ppx ]; |
74 | 68 | }; |
75 | | - doCheck = true; |
76 | | - nativeBuildInputs = [ pkgs.ocamlPackages.melange reason ]; |
77 | | - propagatedBuildInputs = [ |
78 | | - pkgs.ocamlPackages.melange |
79 | | - reason-react-ppx |
80 | | - ]; |
81 | 69 | }; |
| 70 | + in |
| 71 | + packages // { default = packages.reason-react; }); |
82 | 72 |
|
83 | | - default = packages.reason-react; |
84 | | - }; |
85 | | - |
86 | | - devShells = { |
| 73 | + devShells = forAllSystems (pkgs: |
| 74 | + let |
| 75 | + makeDevShell = { packages, release-mode ? false }: |
| 76 | + pkgs.mkShell { |
| 77 | + # dontDetectOcamlConflicts = true; |
| 78 | + inputsFrom = pkgs.lib.attrValues packages; |
| 79 | + nativeBuildInputs = |
| 80 | + with pkgs.ocamlPackages; [ ocamlformat pkgs.nodejs_latest ] |
| 81 | + ++ pkgs.lib.optionals release-mode (with pkgs; [ |
| 82 | + cacert |
| 83 | + curl |
| 84 | + ocamlPackages.dune-release |
| 85 | + ocamlPackages.odoc |
| 86 | + git |
| 87 | + ]); |
| 88 | + propagatedBuildInputs = with pkgs.ocamlPackages; [ merlin ]; |
| 89 | + }; |
| 90 | + packages = self.packages.${pkgs.system}; |
| 91 | + in |
| 92 | + { |
87 | 93 | default = makeDevShell { inherit packages; }; |
88 | 94 | release = makeDevShell { |
89 | 95 | inherit packages; |
90 | 96 | release-mode = true; |
91 | 97 | }; |
92 | | - }; |
93 | | - }); |
| 98 | + }); |
| 99 | + }; |
94 | 100 | } |
0 commit comments