diff options
author | Kai Norman Clasen <k.clasen@protonmail.com> | 2024-05-21 07:29:06 +0200 |
---|---|---|
committer | Kai Norman Clasen <k.clasen@protonmail.com> | 2024-05-21 09:15:47 +0200 |
commit | 5616e55b1722235f2db1720c6b7cfd40285edfb5 (patch) | |
tree | 8801085b89cfa19155ddd7a0f8e7b7642ddc10f0 /pkgs/by-name/im | |
parent | 05cd6cddcbb73e139720bb384732ff527270d470 (diff) |
immich-go: refactor linker data
Follow upstream more closely and set `commit` and `date` metadata to avoid confusion. Co-authored-by: Anderson Torres <torres.anderson.85@protonmail.com>
Diffstat (limited to 'pkgs/by-name/im')
-rw-r--r-- | pkgs/by-name/im/immich-go/package.nix | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/pkgs/by-name/im/immich-go/package.nix b/pkgs/by-name/im/immich-go/package.nix index 097df465ba925..439c4768ea15e 100644 --- a/pkgs/by-name/im/immich-go/package.nix +++ b/pkgs/by-name/im/immich-go/package.nix @@ -7,7 +7,21 @@ buildGoModule rec { owner = "simulot"; repo = "immich-go"; rev = "${version}"; - hash = "sha256-TibDbA4rrr9+WmKAyd3CQ0lxFFv3v/A2HO6Iu66mgFM="; + hash = "sha256-5dgEyg55ffJLH8zxp6mFVsUqAzyPnY18XnX+jMethUc="; + + # Inspired by: https://github.com/NixOS/nixpkgs/blob/f2d7a289c5a5ece8521dd082b81ac7e4a57c2c5c/pkgs/applications/graphics/pdfcpu/default.nix#L20-L32 + # The intention here is to write the information into files in the `src`'s + # `$out`, and use them later in other phases (in this case `preBuild`). + # In order to keep determinism, we also delete the `.git` directory + # afterwards, imitating the default behavior of `leaveDotGit = false`. + # More info about git log format can be found at `git-log(1)` manpage. + leaveDotGit = true; + postFetch = '' + cd "$out" + git log -1 --pretty=%H > "COMMIT" + git log -1 --pretty=%cd --date=format:'%Y-%m-%dT%H:%M:%SZ' > "SOURCE_DATE" + rm -rf ".git" + ''; }; vendorHash = "sha256-nOJJz5KEXqxl3tP1Q12Cb/fugtxR67RjzH6khKg3ppE="; @@ -19,10 +33,13 @@ buildGoModule rec { "-w" "-extldflags=-static" "-X main.version=${version}" - "-X main.commit=${version}" - "-X main.date=unknown" ]; + preBuild = '' + ldflags+=" -X main.commit=$(cat COMMIT)" + ldflags+=" -X main.date=$(cat SOURCE_DATE)" + ''; + passthru = { updateScript = nix-update-script { }; tests.versionTest = testers.testVersion { |