0

This seems like it should be obvious bug how do I have a conditional dependency in dune-project? Specifically I want to depend on a library but only on Unix-like systems:

(package
  (name foo)
  (depends
    (linenoise (and (>= 1.1.0) (= %{os_type} "Unix")))))))))

That doesn't actually work because it is invalid syntax. The only examples of %{os_type} I found were for enabled_if which only can disable or enable an entire package. It doesn't work for dependencies apparently.

This is really easy in Rust; surely OCaml can do this?

1 Answer 1

1

What you want is this:

(package
  (name foo)
  (depends
    (linenoise (and (>= 1.1.0) (= :os "linux")))))

OPAM will convert :os to a OCaml value by the same name os in the OPAM source code. This will be whatever OPAM thinks your operating system is. Note this value can be "" in some cases so be careful.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.