Consider dune-project environment variables
#13329
Replies: 3 comments 12 replies
-
|
I was just made aware of https://ocaml.org/p/dune-build-info/latest/doc/index.html which seems to do this without environment variables through some library magic, albeit with a very limited api. Regardless I'll keep this discussion open on the off chance its well received, though feel free to close if not. 🙂 |
Beta Was this translation helpful? Give feedback.
-
|
Here's a nix implementation I wrote today which just parses dune-project into a nix expression which can then be used to populate the derivation attrs: https://github.com/eureka-cpu/dunix. This solves my issue on the nix side, but it would still be great to have more than just the version available in the |
Beta Was this translation helpful? Give feedback.
-
|
How does cargo handle recompilation when these environment variables change? For example, if I update my "crate description" which is supposedly exposed via an environment variable, how does cargo know which recompilation actions need to re-run? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi there, I opened this thread on discourse where my main inquiry was how to properly get the version information from my dune-project into my code so I can use it with
cmdliner.The discourse thread is pretty short, but to summarize I'm coming from using Rust and I really enjoy how clap handles Cargo package/workspace information. It's able to do this because Cargo makes environment variables available at compile time which can then be picked by
clap, or any other Rust code for that matter using theenv!macro. This particular part of the thread shows how if dune also made similarly named environment variables available, it could achieve the same ease of use for OCaml programs, in particular command line applications and build orchestration tools, like nix.I am new to OCaml, and also not familiar with the dune repository, but the following could be a short route to achieving this:
Cmdliner.Cmd.InfoThe theoretical deriver might look like:
This could be a nice addition, which avoids generating files via
actionand uses the dune-project file as the singular source of truth for package/workspace data.Beta Was this translation helpful? Give feedback.
All reactions