gomi: embed version information (#403076)
This commit is contained in:
parent
dbaabd27e1
commit
c5427604c7
@ -12,13 +12,32 @@ buildGoModule rec {
|
|||||||
owner = "b4b4r07";
|
owner = "b4b4r07";
|
||||||
repo = "gomi";
|
repo = "gomi";
|
||||||
tag = "v${version}";
|
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=";
|
vendorHash = "sha256-8aw81DKBmgNsQzgtHCsUkok5e5+LeAC8BUijwKVT/0s=";
|
||||||
|
|
||||||
subPackages = [ "." ];
|
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 = {
|
meta = {
|
||||||
description = "Replacement for UNIX rm command";
|
description = "Replacement for UNIX rm command";
|
||||||
homepage = "https://github.com/b4b4r07/gomi";
|
homepage = "https://github.com/b4b4r07/gomi";
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user