timbertson / opam2nix

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

Version selection not working? #56

Closed rgrinberg closed 3 years ago

rgrinberg commented 3 years ago

I'm trying the example in examples/package, and I'm unable to select a version:

$ ./build.sh ocamlformat 0.17.0
...
+ /nix/store/b9im8b3kvr6895k9rmfi0bl4yxk66fln-ocaml4.10.2-opam2nix-1.1.0/bin/opam2nix resolve --dest /Users/rgrinberg/github/timbertson/opam2nix/examples/package/opam-selection.nix --ocaml-version 4.10.2 ocamlformat@0.17.0
Fatal error: exception Failure("Invalid character in package name \"ocamlformat@0.17.0\"")
rgrinberg commented 3 years ago

After abrief glance, it seems like this patch should fix the problem:

diff --git a/examples/package/generic.nix b/examples/package/generic.nix
index bdc881f..87b76d6 100644
--- a/examples/package/generic.nix
+++ b/examples/package/generic.nix
@@ -9,7 +9,7 @@ let
 in
 {
    resolve = opam2nix.resolve opam-args ([
-       (if version == null then name else "${name}@${version}")
+       (if version == null then name else "${name}=${version}")
    ] ++ resolveArgs);
    selection = opam2nix.build opam-args;
 }
timbertson commented 3 years ago

Applied, thanks!