I'm trying to use opam2nix with OCaml 5.0.0 (beta1), but had a few problems:
First, the --ocaml-version option actually selects a version of ocaml-base-compiler, which is confusing as the version numbers aren't always the same. ocaml-base-compiler.5.0.0~beta1 is used with ocaml.5.0.0.
However, that didn't quite work. First, it prints this warning:
trace: warning: Dependencies were selected for ocaml version 5.0.0~beta1 but you are building with 5.0.0-beta1
However, editing the version to match what it wants doesn't work (if you have any dependencies).
It looks like opam2nixHooks only adds libraries to OCAMLPATH if there is an ocaml.version directory.
Nix reports ocaml.version as 5.0.0-beta1, but the directory is just 5.0.0.
The solution here is to override the version number like this:
ocaml5 = pkgs.ocaml-ng.ocamlPackages_5_0.ocaml // { version = "5.0.0"; };
The next problem is that it didn't install:
$ nix build . --impure
trace: warning: Dependencies were selected for ocaml version 5.0.0~beta1 but you are building with 5.0.0
[...]
> + dune build -p demo -j 8 --promote-install-files=false @install
> + dune install -p demo --create-install-files demo
> Error: The mandir installation directory is unknown.
It's looking for $OPAM_SWITCH_PREFIX to decide where to install the files.
This happens when my dune-project used (lang dune 2.9). Changing that to 3.5, it seems to work! (but some of my dependencies use 2.9 too and also fail)
I'm trying to use opam2nix with OCaml 5.0.0 (beta1), but had a few problems:
First, the
--ocaml-version
option actually selects a version ofocaml-base-compiler
, which is confusing as the version numbers aren't always the same.ocaml-base-compiler.5.0.0~beta1
is used withocaml.5.0.0
.So first, you need to pass the beta part:
To try using it, I then added this
flake.nix
:However, that didn't quite work. First, it prints this warning:
However, editing the version to match what it wants doesn't work (if you have any dependencies). It looks like
opam2nixHooks
only adds libraries toOCAMLPATH
if there is anocaml.version
directory. Nix reportsocaml.version
as5.0.0-beta1
, but the directory is just5.0.0
.The solution here is to override the version number like this:
The next problem is that it didn't install:
It's looking for
$OPAM_SWITCH_PREFIX
to decide where to install the files. This happens when mydune-project
used(lang dune 2.9)
. Changing that to3.5
, it seems to work! (but some of my dependencies use 2.9 too and also fail)Also, Nix requires opam2nix to be run with
--impure
. I have an experimental branch at https://github.com/timbertson/opam2nix/compare/v1...talex5:opam2nix:flakes?expand=1 that fixes that.Hope that's useful to someone!