gomi: embed version information (#403076)

This commit is contained in:
nsfisis 2025-05-12 01:11:32 +09:00 committed by GitHub
parent dbaabd27e1
commit c5427604c7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -12,13 +12,32 @@ buildGoModule rec {
owner = "b4b4r07";
repo = "gomi";
tag = "v${version}";
hash = "sha256-FZCvUG6lQH8CFivV/hbIgGQx4FCk1UtreiWXTQVi4+4=";
hash = "sha256-0C+us4GO8Jd51ATaaf0aRU3NnhmDvu0I3qDDXBoaiXU=";
# populate values that require us to use git. By doing this in postFetch we
# can delete .git afterwards and maintain better reproducibility of the src.
leaveDotGit = true;
postFetch = ''
cd $out
git show --format='%h' HEAD --quiet > ldflags_revision
date --utc --date="@$(git show --format='%ct' HEAD --quiet)" +'%Y-%m-%dT%H:%M:%SZ' > ldflags_buildDate
find . -type d -name .git -print0 | xargs -0 rm -rf
'';
};
vendorHash = "sha256-8aw81DKBmgNsQzgtHCsUkok5e5+LeAC8BUijwKVT/0s=";
subPackages = [ "." ];
# Add version information fetched from the repository to ldflags.
# https://github.com/babarot/gomi/blob/v1.6.0/.goreleaser.yaml#L20-L22
ldflags = [
"-X main.version=v${version}"
];
preBuild = ''
ldflags+=" -X main.revision=$(cat ldflags_revision)"
ldflags+=" -X main.buildDate=$(cat ldflags_buildDate)"
'';
meta = {
description = "Replacement for UNIX rm command";
homepage = "https://github.com/b4b4r07/gomi";