Zulip Chat Archive

Stream: lean4

Topic: Package version from git tag?


Miles Sabin (Dec 29 2025 at 17:13):

It seems that the package command only supports pure values ... is there any mechanism for deriving a package version from git info in a lakefile.lean?

The motivation is to have a package release process which is driven by tagging in git. Something similar is possible in Haskell with a cabal Setup.hs using a confHook.

Kim Morrison (Jan 06 2026 at 00:15):

I think this is a question for @Mac Malone.

Mac Malone (Jan 06 2026 at 00:31):

You can run arbitrary IO in a lakefile.lean via the run_io syntax. For example, you could derive the version of a package from a Git tag like so:

def getVersion : IO StdVer := do
  let repo := GitRepo.mk __dir__
  let some tag  repo.findTag?
    | return v!"0.0.0"
  let .ok ver := StdVer.parse tag
    | return v!"0.0.0"
  return ver

package mypkg where
  version := run_io getVersion

Miles Sabin (Feb 08 2026 at 16:58):

@Mac Malone very belated thanks ... that works perfectly.


Last updated: Feb 28 2026 at 14:05 UTC