Skip to content

flake: add nix targets that implement dune --version #12042

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

gridbugs
Copy link
Collaborator

Existing nix targets produce binaries whose version according to dune --version is "n/a". This adds a mechanism to the flake for determining the version number and building a dune binary which outputs the appropriate version number from dune --version.

Note that this depends on two hacks which are explained in more detail in a comment:

  • determining the version number from the changelog file
  • creating a temporary git repo with a tag named after the version to allow dune subst to find out the current version

In the longer term we could remove the needs for these workarounds. In the short term this feature is needed to determine the current version of dune when dune is shipped as a binary, as we use the flake to build said binaries.

Existing nix targets produce binaries whose version according to `dune
--version` is "n/a". This adds a mechanism to the flake for determining
the version number and building a dune binary which outputs the
appropriate version number from `dune --version`.

Note that this depends on two hacks which are explained in more detail
in a comment:
 - determining the version number from the changelog file
 - creating a temporary git repo with a tag named after the version to
   allow `dune subst` to find out the current version

In the longer term we could remove the needs for these workarounds. In
the short term this feature is needed to determine the current version
of dune when dune is shipped as a binary, as we use the flake to build
said binaries.

Signed-off-by: Stephen Sherratt <[email protected]>
@gridbugs gridbugs force-pushed the nix-targets-with-dune-version branch from cb370e4 to 18602e0 Compare July 18, 2025 05:51
@rgrinberg
Copy link
Member

@anmonteiro could you review this one?

@anmonteiro
Copy link
Collaborator

It's a bit hacky, but I'm not sure what the alternative is. The only other solution I can think of is committing a file that has the current version and falling back to that if Build_info.V1 returns n/a. It requires a manual step for promoting the file into the source tree (e.g. a dune rule that produces fallback.ml via a git invocation) but it wouldn't require the rigmarole of parsing changelog + generating an empty repo.

@gridbugs
Copy link
Collaborator Author

I agree that would be a more elegant solution, though it would take some time to design it properly. We can always switch to that approach later without affecting the output of the flake or anything downstream of it. Would you be satisfied merging this in its current state and doing it the "right way" when we have some more time for maintenance? Could probably even be a good first issue.

@gridbugs
Copy link
Collaborator Author

I'll close this for the time being. I found that it doesn't work properly on macos and I think fixing it here would be too invasive to be worth it.

@gridbugs gridbugs closed this Jul 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants