Skip to content

Commit

Permalink
refactor: switch to nixpkgs
Browse files Browse the repository at this point in the history
Use nixpkgs instead of opam-nix by default.

It's far faster and does everything we need.

Signed-off-by: Rudi Grinberg <me@rgrinberg.com>

<!-- ps-id: d2e443b7-3973-4cdb-a678-6a5eafbc9f39 -->
  • Loading branch information
rgrinberg committed Jun 8, 2023
1 parent 73678a6 commit 33498c6
Show file tree
Hide file tree
Showing 2 changed files with 150 additions and 18 deletions.
48 changes: 33 additions & 15 deletions flake.lock

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

120 changes: 117 additions & 3 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
url = "github:ocaml/opam-repository";
flake = false;
};
cmarkit-src = {
url = "github:dbuenzli/cmarkit/?ref=v0.2.0";
flake = false;
};
};

outputs = { self, flake-utils, opam-nix, opam-repository, nixpkgs, ... }@inputs:
Expand All @@ -24,11 +28,102 @@
dune-release = prev.dune-release.overrideAttrs (_: {
doCheck = false;
});
ocamlPackages = prev.ocamlPackages.overrideScope' (oself: osuper:
let
fixPreBuild = o: {
propagatedBuildInputs = o.propagatedBuildInputs ++ [ oself.pp ];
preBuild = ''
rm -r vendor/csexp vendor/pp
'';
};
in
{
dyn = osuper.dyn.overrideAttrs fixPreBuild;
dune-private-libs = osuper.dune-private-libs.overrideAttrs fixPreBuild;
dune-glob = osuper.dune-glob.overrideAttrs fixPreBuild;
dune-action-plugin = osuper.dune-action-plugin.overrideAttrs fixPreBuild;
dune-rpc = osuper.dune-rpc.overrideAttrs fixPreBuild;
stdune = osuper.stdune.overrideAttrs fixPreBuild;
});
};
in
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { overlays = [ overlay ]; inherit system; };
inherit (pkgs.ocamlPackages) buildDunePackage;
fast = rec {

# these packages do not use opam2nix
jsonrpc = buildDunePackage {
pname = "jsonrpc";
version = "n/a";
src = ./.;
duneVersion = "3";
propagatedBuildInputs = with pkgs.ocamlPackages; [ ];
doCheck = false;
};

lsp = buildDunePackage {
pname = "lsp";
version = "n/a";
src = ./.;
duneVersion = "3";
propagatedBuildInputs = with pkgs.ocamlPackages; [
jsonrpc
yojson
stdune
ppx_yojson_conv_lib
uutf
];
checkInputs = with pkgs.ocamlPackages; [ cinaps ppx_expect ];
doCheck = false;
};

cmarkit = buildDunePackage {
pname = "cmarkit";
version = "0.2.0";
src = inputs.cmarkit;
propagatedBuildInputs = with pkgs.ocamlPackages; [
jsonrpc
yojson
stdune
ppx_yojson_conv_lib
uutf
];
};

ocaml-lsp = buildDunePackage {
pname = "ocaml-lsp";
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
odoc-parser
cmarkit
];
doCheck = false;
};
};
on = opam-nix.lib.${system};
localPackages = {
jsonrpc = "*";
Expand Down Expand Up @@ -67,7 +162,7 @@
{
packages =
opam2nixPackages //
{
rec {
# we have a package without opam2nix for easy consumption for nix users
default = pkgs.ocamlPackages.buildDunePackage {
pname = package;
Expand Down Expand Up @@ -104,10 +199,12 @@
runHook postBuild
'';
};

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

devShell =
pkgs.mkShell {
devShells = {
opam2nix = pkgs.mkShell {
buildInputs = (with pkgs;
[
# dev tools
Expand All @@ -117,5 +214,22 @@
]) ++ packagesFromNames devPackages;
inputsFrom = packagesFromNames opam2nixPackages;
};

default = pkgs.mkShell {
buildInputs = (with pkgs;
[
# dev tools
ocamlformat_0_24_1
yarn
dune-release

ocamlPackages.ppx_expect
ocamlPackages.utop
ocamlPackages.cinaps
ocamlPackages.ppx_yojson_conv
]);
inputsFrom = [ fast.ocaml-lsp fast.jsonrpc fast.lsp ];
};
};
});
}

0 comments on commit 33498c6

Please sign in to comment.