tweag / opam-nix

Turn opam-based OCaml projects into Nix derivations
MIT License
111 stars 33 forks source link

Fake `opam` support of the `exec` subcommand #29

Closed Niols closed 1 year ago

Niols commented 2 years ago

Is your feature request related to a problem? Please describe.

I am contributing on an OPAM-based OCaml project with both Nix and non-Nix people. I setup opam-nix for my convenience, but not everyone goes through it to work on the project in question. Now, for non-Nix OPAM-based scripts, it is common to prefix commands by opam exec -- to make sure that they are run in the correct environment. Because the fake opam command does not support exec, though, those scripts do not work for me. Depending on the version of opam-nix, I get either:

$ opam exec -- echo foo
2.0.0

or

$ opam exec -- echo foo
opam-nix fake opam doesn't understand these arguments: exec -- echo foo

Describe the solution you'd like

I would like for the fake opam command to recognize the exec subcommand. Considering that the fake opam only exists when in a Nix context, then opam exec should basically be a no-op running the given command (eg. opam exec - echo foo just runs echo foo).

Describe alternatives you've considered

For now, I am just stripping all uses of opam exec from scripts before running anything. This is doable and not very difficult. Alternatively, I could provide yet another fake opam in my Nix flake, taking precedence over opam-nix's, and recognizing exec. I feel the best would still be for it to be supported in opam-nix.

Niols commented 1 year ago

Yay :tada: