!QCCCSJHEsTIfozrZxz:nixos.org

Nix + Go

231 Members
Go packaging for and with Nixpkgs. | Be excellent to each other.50 Servers

You have reached the beginning of time (for this room).


SenderMessageTime
12 Jul 2025
@sleroq:sleroq.linksleroq left the room.14:02:56
19 Jul 2025
@xgwq:nerdberg.dexgwq joined the room.18:06:28
@xgwq:nerdberg.dexgwq

Hi, I currrently try to package a go package that fetches the version from Buildinfo like this

func GetVersion() (ret string) {
	if b, ok := debug.ReadBuildInfo(); ok && len(b.Main.Version) > 0 {
		ret = b.Main.Version
	} else {
		ret = "unknown"
	}
	return
}

Building that with nix gets (devel) as version, how can I set the version to the real package version?

18:12:15
@diamondburned:matrix.orgdiamond (it/its)you could look into fetchgit with preserving .git22:14:48
@diamondburned:matrix.orgdiamond (it/its)https://discourse.nixos.org/t/keep-git-folder-in-when-fetching-a-git-repo/859022:15:04
@diamondburned:matrix.orgdiamond (it/its)https://pkg.go.dev/cmd/go -buildvcs=true will also enforce this22:21:49
@diamondburned:matrix.orgdiamond (it/its)which you should have that set22:21:52
@xgwq:nerdberg.dexgwq This seems to go in the right direction but does not find the tag to get its version from and instead results in v0.0.0-20250719172851-d68c15f4dc17+dirty. 23:52:25
@xgwq:nerdberg.dexgwq Adding preBuild = "git tag v${version}"; adds the right version but still keeps the +dirty. 23:55:46
20 Jul 2025
@diamondburned:matrix.orgdiamond (it/its) fetchTags = true i think 03:29:11
@diamondburned:matrix.orgdiamond (it/its)although that dirty seems to be because nix patches the package maybe?03:29:19

Show newer messages


Back to Room ListRoom Version: 9