Skip to content

Commit

Permalink
nix: export an overlay that adds ocaml-lsp itself to pkgs.ocamlPackag…
Browse files Browse the repository at this point in the history
…es (#1231)
  • Loading branch information
anmonteiro committed Feb 22, 2024
1 parent a74fb4a commit 922a726
Showing 1 changed file with 53 additions and 41 deletions.
94 changes: 53 additions & 41 deletions flake.nix
Expand Up @@ -34,8 +34,58 @@
stdune = osuper.stdune.overrideAttrs fixPreBuild;
});
};
lspPackage = pkgs:
with pkgs.ocamlPackages;
buildDunePackage {
pname = package;
version = "n/a";
src = ./.;
duneVersion = "3";
buildInputs = [
ocamlc-loc
astring
camlp-streams
dune-build-info
re
dune-rpc
chrome-trace
dyn
fiber
xdg
ordering
spawn
pp
csexp
ocamlformat-rpc-lib
stdune
yojson
ppx_yojson_conv_lib
uutf
merlin-lib
];
propagatedBuildInputs = [ ];
doCheck = false;
buildPhase = ''
runHook preBuild
dune build ${package}.install --release ''${enableParallelBuilding:+-j $NIX_BUILD_CORES}
runHook postBuild
'';
meta = {
mainProgram = "ocamllsp";
};
};
in
flake-utils.lib.eachDefaultSystem (system:
{
overlays.default = (final: prev: {
ocamlPackages = prev.ocamlPackages.overrideScope (oself: osuper:
with oself;

{
ocaml-lsp = lspPackage final;
}
);
});
} // (flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { overlays = [ overlay ]; inherit system; };
inherit (pkgs.ocamlPackages) buildDunePackage;
Expand Down Expand Up @@ -104,45 +154,7 @@
packages =
rec {
# we have a package without opam2nix for easy consumption for nix users
default = pkgs.ocamlPackages.buildDunePackage {
pname = package;
version = "n/a";
src = ./.;
duneVersion = "3";
buildInputs = with pkgs.ocamlPackages; [
ocamlc-loc
astring
camlp-streams
dune-build-info
re
dune-rpc
chrome-trace
dyn
fiber
xdg
ordering
spawn
pp
csexp
ocamlformat-rpc-lib
stdune
yojson
ppx_yojson_conv_lib
uutf
lsp
merlin-lib
];
propagatedBuildInputs = [ ];
doCheck = false;
buildPhase = ''
runHook preBuild
dune build ${package}.install --release ''${enableParallelBuilding:+-j $NIX_BUILD_CORES}
runHook postBuild
'';
meta = {
mainProgram = "ocamllsp";
};
};
default = lspPackage pkgs;

ocaml-lsp = fast.ocaml-lsp;
};
Expand All @@ -167,5 +179,5 @@
buildInputs = [ pkgs.dune-release ];
};
};
});
}));
}

0 comments on commit 922a726

Please sign in to comment.