about summary refs log tree commit diff
path: root/pkgs/applications
diff options
context:
space:
mode:
authoremilylange <git@emilylange.de>2024-04-02 17:04:16 +0200
committeremilylange <git@emilylange.de>2024-04-07 16:46:12 +0200
commitaa4d120c505746827097ffdd9120f127d08df2bf (patch)
tree7b3ab4b4bd38d70a0af25906bb068fdc3a94cf80 /pkgs/applications
parent3206d851a6279ed361022027bc1d6ac5a8d42f14 (diff)
forgejo: add missing internal version ldflags
Those two ldlfags provide the version string for the
/api/forgejo/v1/version API endpoint and the forgejo_sem_ver database
table.

Prio to this change, /api/forgejo/v1/version returned "development" and
the database table "1.0.0".

The proper version string, which we are now providing, is a combination
of a hardcoded version compatibility string (like "gitea-1.21.8") and
the forgejo semver version.

The forgejo semver version in forgejo v1.21.8-0 is technically hardcoded
in the Makefile, but will use git describe starting with the next major
release (which will also be the release when forgejo makes this semver
user facing).

So in summary, this commit is a bug fix in our nixpkgs packaging and
prepares us for the next major release.

(cherry picked from commit dab7aa20ed898ed1264edbc7f1ae241427cc3ba6)
Diffstat (limited to 'pkgs/applications')
-rw-r--r--pkgs/applications/version-management/forgejo/default.nix22
1 files changed, 21 insertions, 1 deletions
diff --git a/pkgs/applications/version-management/forgejo/default.nix b/pkgs/applications/version-management/forgejo/default.nix
index 0b99af3e7c7e8..25b129e208460 100644
--- a/pkgs/applications/version-management/forgejo/default.nix
+++ b/pkgs/applications/version-management/forgejo/default.nix
@@ -50,7 +50,23 @@ buildGoModule rec {
     # https://codeberg.org/forgejo/forgejo/pulls/2443
     # https://codeberg.org/forgejo/forgejo/commit/2fe5f6f73283c2f6935ded62440a1f15ded12dcd
     rev = "2fe5f6f73283c2f6935ded62440a1f15ded12dcd";
-    hash = "sha256-qk30Sixd4G9ivkpC1c9IAjCkSNU2ohzDPL9WSyQ6NIw=";
+    hash = "sha256-U80HfHDSOKN+MGOX9Tu85lgN+8KeEzjSjpZXVFGmLKQ=";
+    # Forgejo has multiple different version strings that need to be provided
+    # via ldflags.  main.ForgejoVersion for example is a combination of a
+    # hardcoded gitea compatibility version string (in the Makefile) and
+    # git describe and is easiest to get by invoking the Makefile.
+    # So we do that, store it the src FOD to then extend the ldflags array
+    # in preConfigure.
+    # The `echo -e >> Makefile` is temporary and already part of the next
+    # major release.  Furthermore, the ldflags will change next major release
+    # and need to be updated accordingly.
+    leaveDotGit = true;
+    postFetch = ''
+      cd "$out"
+      echo -e 'show-version-full:\n\t@echo ''${FORGEJO_VERSION}' >> Makefile
+      make show-version-full > FULL_VERSION
+      find "$out" -name .git -print0 | xargs -0 rm -rf
+    '';
   };
 
   vendorHash = "sha256-HDKirjQI4KvHvzDCqKe9nHvQUv3VNRl5tkr0rO7gcAY=";
@@ -80,6 +96,10 @@ buildGoModule rec {
     "-X 'main.Tags=${lib.concatStringsSep " " tags}'"
   ];
 
+  preConfigure = ''
+    export ldflags+=" -X code.gitea.io/gitea/routers/api/forgejo/v1.ForgejoVersion=$(cat FULL_VERSION) -X main.ForgejoVersion=$(cat FULL_VERSION)"
+  '';
+
   preBuild = ''
     go run build/merge-forgejo-locales.go
   '';