!QCCCSJHEsTIfozrZxz:nixos.org

Nix + Go

206 Members
Go packaging for and with Nixpkgs. | Be excellent to each other.48 Servers

Load older messages


SenderMessageTime
11 Jul 2025
@elitewhale75:matrix.orgelitewhale75 changed their display name from Vignesh Guruswami to elitewhale75.17:39:46
@elitewhale75:matrix.orgelitewhale75 set a profile picture.17:39:56
12 Jul 2025
@plan9better:matrix.orgplan9better joined the room.11:06:12
@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
@diamondburned:matrix.orgdiamond (it/its)it's doing something w the repo03:29:27
@diamondburned:matrix.orgdiamond (it/its) you can do preBuild = "git status;"; and see 03:29:36
@katexochen:matrix.orgPaul Meyer (katexochen) using fetchgit will result in the source not being reproducible, as it is not possible to get .git deterministic at this point.
I'd suggest to apply a patch or substituteInPlace to make it return the correct version.
09:16:08
@xgwq:nerdberg.dexgwqThat does it. The dirty comes from nix deleting half the repo and untracking the other half.10:30:03
@diamondburned:matrix.orgdiamond (it/its)
In reply to @katexochen:matrix.org
using fetchgit will result in the source not being reproducible, as it is not possible to get .git deterministic at this point.
I'd suggest to apply a patch or substituteInPlace to make it return the correct version.
is that true? pkgs.fetchgit still has to be hash locked afaik
16:38:41
@qyliss:fairydust.spaceAlyssa Ross
In reply to @diamondburned:matrix.org
is that true? pkgs.fetchgit still has to be hash locked afaik
yes but that hash changes sometimes
18:51:14
@qyliss:fairydust.spaceAlyssa Rossit's bad18:51:24
@qyliss:fairydust.spaceAlyssa Rossif you set leaveDotGit18:51:24
@diamondburned:matrix.orgdiamond (it/its)ooof19:00:52
21 Jul 2025
@drupol:matrix.org@drupol:matrix.org joined the room.17:18:43
@drupol:matrix.org@drupol:matrix.orghellow17:18:48
@drupol:matrix.org@drupol:matrix.org

I'm going to copy paste a message I wrote in the dev room:

I'm looking for a bit of help for compiling this Go software: https://github.com/NixOS/nixpkgs/pull/427193 (https://github.com/buildpacks/pack). The issue started to appear after they did this: https://github.com/buildpacks/pack/pull/2390

When I run the build, it end up with:

       > Building subPackage ./testhelpers
       > Building subPackage ./testhelpers/comparehelpers
       > Building subPackage ./tools
       > main module (github.com/buildpacks/pack) does not contain package github.com/buildpacks/pack/tools
       For full logs, run:
         nix log /nix/store/8rhs2qy6cbk637czra3lw4ydjh90w6xd-pack-0.38.2.drv

Can you help?

17:19:13
@drupol:matrix.org@drupol:matrix.org *

I'm going to copy paste a message I wrote in the dev room:

I'm looking for a bit of help for compiling this Go software: https://github.com/NixOS/nixpkgs/pull/427193 (https://github.com/buildpacks/pack). The issue started to appear after they did this: https://github.com/buildpacks/pack/pull/2390 (I added a comment in there just now: https://github.com/buildpacks/pack/pull/2390#issuecomment-3097654347)

When I run the build, it end up with:

       > Building subPackage ./testhelpers
       > Building subPackage ./testhelpers/comparehelpers
       > Building subPackage ./tools
       > main module (github.com/buildpacks/pack) does not contain package github.com/buildpacks/pack/tools
       For full logs, run:
         nix log /nix/store/8rhs2qy6cbk637czra3lw4ydjh90w6xd-pack-0.38.2.drv

Can you help?

17:19:38
@drupol:matrix.org@drupol:matrix.org *

I'm going to copy paste a message I wrote in the dev room:

I'm looking for a bit of help for compiling pack (https://github.com/buildpacks/pack): https://github.com/NixOS/nixpkgs/pull/427193. The issue started to appear after they did this: https://github.com/buildpacks/pack/pull/2390 (I added a comment in there just now: https://github.com/buildpacks/pack/pull/2390#issuecomment-3097654347)

When I run the build, it end up with:

       > Building subPackage ./testhelpers
       > Building subPackage ./testhelpers/comparehelpers
       > Building subPackage ./tools
       > main module (github.com/buildpacks/pack) does not contain package github.com/buildpacks/pack/tools
       For full logs, run:
         nix log /nix/store/8rhs2qy6cbk637czra3lw4ydjh90w6xd-pack-0.38.2.drv

Can you help?

17:21:36
@katexochen:matrix.orgPaul Meyer (katexochen)

Pol: I think you should set subPackages:

subPackages = [ "." ];
17:28:43
@drupol:matrix.org@drupol:matrix.orgLet me try17:28:52

Show newer messages


Back to Room ListRoom Version: 9