timbertson / opam2nix

Generate nix expressions from opam packages
MIT License
93 stars 28 forks source link

error message when you omit `--ocaml-version` #77

Open quinn-dougherty opened 2 years ago

quinn-dougherty commented 2 years ago

"$(nix-build --no-out-link ./opam2nix.nix)"/bin/opam2nix resolve ./mytest.opam

error: file 'nixpkgs' was not found in the Nix search path (add it using $NIX_PATH or -I) 
+ /nix/store/1zb2as5f9iqyibwy65ln7b023522sg90-ocaml4.12.0-opam2nix-1.1.0/bin/opam2nix resolve ./mytest.opam
Using current <nixpkgs> ocaml version, pass --ocaml-version to override
Fetching...
Importing opam-repository a349ee914e267237677546599e718e417aaae14d into nix store...
Fatal error: exception (Failure "Couldn't extract ocaml version from nixpkgs, pass --ocaml-version")

What's going on here? what would have to happen to get a better error message? is passing --ocaml-version minimally required behavior?

In my head, I thought omitting --ocaml-version would infer the latest possible ocaml in conformance to packages in mytest.opam.

timbertson commented 2 years ago

I thought omitting --ocaml-version would infer the latest possible ocaml in conformance to packages in mytest.opam.

It's not that clever I'm afraid - it picks the default ocaml version from nixpkgs - thus the error, since you don't appear to have a nixpkgs channel available.

To be honest it's probably better to just always pass --ocaml-version, though it is a little tedious.