Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Original file line Diff line number Diff line change
@@ -1,5 +1,7 @@
# Unreleased # Unreleased


- Remove `flake-utils` Nix Flake dependency

## Features ## Features


- Introduce a configuration option to control dune diagnostics. The option is - Introduce a configuration option to control dune diagnostics. The option is
Expand Down
34 changes: 0 additions & 34 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

127 changes: 54 additions & 73 deletions flake.nix
Original file line number Original file line Diff line number Diff line change
@@ -1,21 +1,39 @@
{ {
inputs = { inputs = {
flake-utils.url = "github:numtide/flake-utils";
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
}; };


outputs = { self, flake-utils, nixpkgs, ... }@inputs: outputs = { self, nixpkgs, ... }@inputs:
let let
package = "ocaml-lsp-server"; package = "ocaml-lsp-server";
overlay = final: prev: {
supportedSystems = [
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not Nix’s defaults (theirs includes 32-bit Linux last I checked), but matches the default systems of flake-utils so the change should have no effect on anyone.

"aarch64-darwin"
"aarch64-linux"
"x86_64-darwin"
"x86_64-linux"
];

forAllSystems = nixpkgs.lib.genAttrs supportedSystems;

nixpkgsFor = forAllSystems (system: import nixpkgs {
inherit system;
overlays = builtins.attrValues self.overlays;
});
in
{
overlays = {
default = final: prev: {
${package} = prev.${package}.overrideAttrs (_: { ${package} = prev.${package}.overrideAttrs (_: {
# Do not add share/nix-support, so that dependencies from # Do not add share/nix-support, so that dependencies from
# the scope don't leak into dependent derivations # the scope don't leak into dependent derivations
doNixSupport = false; doNixSupport = false;
}); });

dune-release = prev.dune-release.overrideAttrs (_: { dune-release = prev.dune-release.overrideAttrs (_: {
doCheck = false; doCheck = false;
}); });

ocamlPackages = prev.ocamlPackages.overrideScope' (oself: osuper: ocamlPackages = prev.ocamlPackages.overrideScope' (oself: osuper:
let let
fixPreBuild = o: { fixPreBuild = o: {
Expand All @@ -32,16 +50,32 @@
dune-action-plugin = osuper.dune-action-plugin.overrideAttrs fixPreBuild; dune-action-plugin = osuper.dune-action-plugin.overrideAttrs fixPreBuild;
dune-rpc = osuper.dune-rpc.overrideAttrs fixPreBuild; dune-rpc = osuper.dune-rpc.overrideAttrs fixPreBuild;
stdune = osuper.stdune.overrideAttrs fixPreBuild; stdune = osuper.stdune.overrideAttrs fixPreBuild;
ocaml-lsp = self.packages.${prev.system}.ocaml-lsp;
}); });
}; };
lspPackage = pkgs:
with pkgs.ocamlPackages; ocaml-lsp-only = final: prev: {
buildDunePackage { ocamlPackages = prev.ocamlPackages.overrideScope' (_: _: {
ocaml-lsp = self.packages.${prev.system}.ocaml-lsp;
});
};
};

packages = forAllSystems (system:
let
pkgs = nixpkgsFor.${system};
inherit (pkgs.ocamlPackages) buildDunePackage;
in
{
# we have a package without opam2nix for easy consumption for nix users
default = self.packages.${system}.ocaml-lsp;

ocaml-lsp = buildDunePackage {
pname = package; pname = package;
version = "n/a"; version = "n/a";
src = ./.; src = ./.;
duneVersion = "3"; duneVersion = "3";
buildInputs = [ buildInputs = with pkgs.ocamlPackages; [
ocamlc-loc ocamlc-loc
astring astring
camlp-streams camlp-streams
Expand All @@ -62,6 +96,8 @@
ppx_yojson_conv_lib ppx_yojson_conv_lib
uutf uutf
merlin-lib merlin-lib
] ++ [
self.packages.${system}.lsp
]; ];
propagatedBuildInputs = [ ]; propagatedBuildInputs = [ ];
doCheck = false; doCheck = false;
Expand All @@ -74,23 +110,8 @@
mainProgram = "ocamllsp"; mainProgram = "ocamllsp";
}; };
}; };
in
{
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;
fast = rec {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these are stubs to speed up the build? I moved them all to packages since it doesn’t hurt while using less recs & temporary attrsets which slow down evaluation.



# stub builds
jsonrpc = buildDunePackage { jsonrpc = buildDunePackage {
pname = "jsonrpc"; pname = "jsonrpc";
version = "n/a"; version = "n/a";
Expand All @@ -106,63 +127,24 @@
src = ./.; src = ./.;
duneVersion = "3"; duneVersion = "3";
propagatedBuildInputs = with pkgs.ocamlPackages; [ propagatedBuildInputs = with pkgs.ocamlPackages; [
jsonrpc
yojson yojson
stdune stdune
ppx_yojson_conv_lib ppx_yojson_conv_lib
uutf uutf
] ++ [
self.packages.${system}.jsonrpc
]; ];
checkInputs = with pkgs.ocamlPackages; [ cinaps ppx_expect ]; checkInputs = with pkgs.ocamlPackages; [ cinaps ppx_expect ];
doCheck = false; doCheck = false;
}; };
});


ocaml-lsp = buildDunePackage { devShells = forAllSystems (system:
pname = "ocaml-lsp"; let pkgs = nixpkgsFor.${system}; in {
version = "n/a";
src = ./.;
duneVersion = "3";
checkInputs = with pkgs.ocamlPackages; [ ppx_expect ];
propagatedBuildInputs = with pkgs.ocamlPackages; [
ocamlc-loc
octavius
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
astring
camlp-streams
merlin-lib
];
doCheck = false;
};
};
in
{
packages =
rec {
# we have a package without opam2nix for easy consumption for nix users
default = lspPackage pkgs;

ocaml-lsp = fast.ocaml-lsp;
};

devShells = {
default = pkgs.mkShell { default = pkgs.mkShell {
buildInputs = (with pkgs; name = package;
[ inputsFrom = builtins.attrValues self.packages.${system};
buildInputs = with pkgs; [
# dev tools # dev tools
ocamlformat_0_26_1 ocamlformat_0_26_1
yarn yarn
Expand All @@ -171,13 +153,12 @@
ocamlPackages.utop ocamlPackages.utop
ocamlPackages.cinaps ocamlPackages.cinaps
ocamlPackages.ppx_yojson_conv ocamlPackages.ppx_yojson_conv
]); ];
inputsFrom = [ fast.ocaml-lsp fast.jsonrpc fast.lsp ];
}; };


release = pkgs.mkShell { release = pkgs.mkShell {
buildInputs = [ pkgs.dune-release ]; buildInputs = [ pkgs.dune-release ];
}; };
});
}; };
}));
} }