gomi: embed version information (#403076)

authored by nsfisis and committed by GitHub c5427604 dbaabd27

+20 -1
+20 -1
pkgs/by-name/go/gomi/package.nix
··· 12 owner = "b4b4r07"; 13 repo = "gomi"; 14 tag = "v${version}"; 15 - hash = "sha256-FZCvUG6lQH8CFivV/hbIgGQx4FCk1UtreiWXTQVi4+4="; 16 }; 17 18 vendorHash = "sha256-8aw81DKBmgNsQzgtHCsUkok5e5+LeAC8BUijwKVT/0s="; 19 20 subPackages = [ "." ]; 21 22 meta = { 23 description = "Replacement for UNIX rm command";
··· 12 owner = "b4b4r07"; 13 repo = "gomi"; 14 tag = "v${version}"; 15 + hash = "sha256-0C+us4GO8Jd51ATaaf0aRU3NnhmDvu0I3qDDXBoaiXU="; 16 + # populate values that require us to use git. By doing this in postFetch we 17 + # can delete .git afterwards and maintain better reproducibility of the src. 18 + leaveDotGit = true; 19 + postFetch = '' 20 + cd $out 21 + git show --format='%h' HEAD --quiet > ldflags_revision 22 + date --utc --date="@$(git show --format='%ct' HEAD --quiet)" +'%Y-%m-%dT%H:%M:%SZ' > ldflags_buildDate 23 + find . -type d -name .git -print0 | xargs -0 rm -rf 24 + ''; 25 }; 26 27 vendorHash = "sha256-8aw81DKBmgNsQzgtHCsUkok5e5+LeAC8BUijwKVT/0s="; 28 29 subPackages = [ "." ]; 30 + 31 + # Add version information fetched from the repository to ldflags. 32 + # https://github.com/babarot/gomi/blob/v1.6.0/.goreleaser.yaml#L20-L22 33 + ldflags = [ 34 + "-X main.version=v${version}" 35 + ]; 36 + preBuild = '' 37 + ldflags+=" -X main.revision=$(cat ldflags_revision)" 38 + ldflags+=" -X main.buildDate=$(cat ldflags_buildDate)" 39 + ''; 40 41 meta = { 42 description = "Replacement for UNIX rm command";