File tree Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -12,13 +12,32 @@ buildGoModule rec {
1212 owner = "b4b4r07" ;
1313 repo = "gomi" ;
1414 tag = "v${ version } " ;
15- hash = "sha256-FZCvUG6lQH8CFivV/hbIgGQx4FCk1UtreiWXTQVi4+4=" ;
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+ '' ;
1625 } ;
1726
1827 vendorHash = "sha256-8aw81DKBmgNsQzgtHCsUkok5e5+LeAC8BUijwKVT/0s=" ;
1928
2029 subPackages = [ "." ] ;
2130
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+
2241 meta = {
2342 description = "Replacement for UNIX rm command" ;
2443 homepage = "https://github.com/b4b4r07/gomi" ;
You can’t perform that action at this time.
0 commit comments