tweag / opam-nix

Turn opam-based OCaml projects into Nix derivations
MIT License
109 stars 32 forks source link

unmet availability conditions: 'enable-ocaml-beta-repository' #70

Closed kentookura closed 9 months ago

kentookura commented 9 months ago

I maintain the flake for this project:

https://git.sr.ht/~jonsterling/ocaml-forester

It stopped working after some packages were updated, and I haven't been able to figure out how to fix it:

resolve> [ERROR] No solution including optional dependencies for forester.3.0.0 & ocaml-system:   * Incompatible packages:
resolve>             - forester >= 3.0.0 -> eio_main >= 0.13 -> eio_linux >= 0.13 -> eio >= 0.13 -> ocaml >= 5.1.0 -> ocaml-base-compiler >= 5.1.0~
resolve>             - ocaml-system
resolve>           * Missing dependency:
resolve>             - forester >= 3.0.0 -> eio_main >= 0.13 -> eio_linux >= 0.13 -> eio >= 0.13 -> ocaml >= 5.1.0 -> ocaml-variants < 5.1.1~ -> ocaml-beta
resolve>             unmet availability conditions: 'enable-ocaml-beta-repository'

To Reproduce

nix run sourcehut:~jonsterling/ocaml-forester for the original breakage. After cloning and updating the flake, nix build -L results in the same error

Expected behavior It builds

Environment

kentookura commented 9 months ago

I tracked down the breaking commit to this one, which updates Eio

balsoft commented 9 months ago

It seems the main issue is the ocaml-system = "*" constraint, combined with the fact that the ocaml compiler in your nixpkgs version is not recent enough. Updating opam-repository (so that the compiler version in question is out of beta) and removing this constraint seems to make it build, although you will have to build the ocaml compiler yourself (shouldn't take too long, ~ 4 minutes on my hardware).

The complete diff that makes it work for me is this:

diff --git a/flake.lock b/flake.lock
index dc0ac51..813d188 100644
--- a/flake.lock
+++ b/flake.lock
@@ -140,11 +140,11 @@
     "opam-repository_2": {
       "flake": false,
       "locked": {
-        "lastModified": 1699845376,
-        "narHash": "sha256-RZ+w6CI/K1PO33D5H7mTK0pT4jDh6DzwMT3zSUOsWTo=",
+        "lastModified": 1703856811,
+        "narHash": "sha256-dE+PZI0N8Hahs+D8GuvYktBGPhW9cyBZGxN6K+n2Y1g=",
         "owner": "ocaml",
         "repo": "opam-repository",
-        "rev": "cd93eb224789c7c645f72575b685eec97b0ccbca",
+        "rev": "91155d8f7ba41238a91fbffd093e5bb7a532aa0a",
         "type": "github"
       },
       "original": {
diff --git a/flake.nix b/flake.nix
index 35052b0..255c339 100644
--- a/flake.nix
+++ b/flake.nix
@@ -23,7 +23,7 @@
           let inherit (opam-nix.lib.${system}) buildOpamProject;
             scope = buildOpamProject
               { repos = [ "${opam-repository}" ]; } "forester" ./.
-              { ocaml-system = "*"; };
+              { };
           in
           scope;
         packages.default = self.legacyPackages.${system}."forester";
kentookura commented 9 months ago

This is fine for now, thanks!