type loc = [%import: Lexing.position] [@@deriving show]
let a:loc = Lexing.dummy_pos
let _ = print_endline (show_loc a)
The build output:
$ nix-shell
$ dune build
Entering directory '/alt/programming/ocaml'
File "_none_", line 1:
Error: No implementations provided for the following modules:
Migrate_parsetree__Migrate_parsetree_versions referenced from /nix/store/107myxypfawcs0mrvcrrmvj6wa4cpgx3-ocaml4.12.0-ppx_import-1.8.0/lib/ocaml/4.12.0/site-lib/ppx_import/ppx_import.cmxa(Ppx_import__Ppx_types_migrate),
/nix/store/107myxypfawcs0mrvcrrmvj6wa4cpgx3-ocaml4.12.0-ppx_import-1.8.0/lib/ocaml/4.12.0/site-lib/ppx_import/ppx_import.cmxa(Ppx_import)
Migrate_parsetree__Migrate_parsetree_driver referenced from /nix/store/107myxypfawcs0mrvcrrmvj6wa4cpgx3-ocaml4.12.0-ppx_import-1.8.0/lib/ocaml/4.12.0/site-lib/ppx_import/ppx_import.cmxa(Ppx_import)
Trying to build it at home, I noticed that the dependencies for that derivation include both ocaml-migrate-parsetree-1.8.0 and ocaml-migrate-parsetree-2.1.0. (Enter nix-shell and then examine the OCAMLPATH variable.) I wonder whether ocamlfind is being confused by the multiple versions on the path.
It is a recent project that never worked with the OCaml packages provided in nixpkgs.
Currently I am installing opam (from nixpkgs) and using opam to install the dependencies of the project. But this may not work when the system is updated. Sometimes I have to reinstall the opam packages, after updating the system.
Is this demo working when using opam with “ppx_deriving>=5.2.1”?
[I suspect Opam is suggesting (which Nix doesn’t do) a different version than Nix. Likely ppx_imports requires an older version of ppx_deriving.)
Certify it works with all packages on latest using opam. If doesn’t work, we have ruled out Nix (for now).
Then, certify all Nix packages used are of same version (ideally latest).
ocaml-migrate-parsetree-2 and ppxlib uses cinaps. Which has an unreleased fix:
I “solved” this by overriding ocaml-migrate-parsetree-2 = self.ocaml-migrate-parsetree. Then all dependencies of the project compile, but the project itself fails with Error: Too many incompatible ppx drivers were found: ppxlib and ocaml-migrate-parsetree.
The problem here is just package version. When you lock to the proper version it builds and works.
Opam does automatic version management. Nix only does dependency management. So we have to manually enforce the correct version of packages. One or some dependency here has to be downgraded and it will work.