about summary refs log tree commit diff
diff options
context:
space:
mode:
authoremilylange <git@emilylange.de>2024-03-28 20:10:53 +0100
committeremilylange <git@emilylange.de>2024-03-28 20:10:53 +0100
commit9fb68677e40ad2bfec0cc6cbdbecdf1523c9430a (patch)
tree7f2fed285457e9df32bbc53e68c207653a88d43d
parentb40caf8c8a7e30fa0befedd3e0139c59c3141af1 (diff)
downloadnixlib-9fb68677e40ad2bfec0cc6cbdbecdf1523c9430a.tar
nixlib-9fb68677e40ad2bfec0cc6cbdbecdf1523c9430a.tar.gz
nixlib-9fb68677e40ad2bfec0cc6cbdbecdf1523c9430a.tar.bz2
nixlib-9fb68677e40ad2bfec0cc6cbdbecdf1523c9430a.tar.lz
nixlib-9fb68677e40ad2bfec0cc6cbdbecdf1523c9430a.tar.xz
nixlib-9fb68677e40ad2bfec0cc6cbdbecdf1523c9430a.tar.zst
nixlib-9fb68677e40ad2bfec0cc6cbdbecdf1523c9430a.zip
forgejo: fix applying of our `STATIC_ROOT_PATH` patch
This fixes an issue where running the forgejo package standalone,
without the use of our nixos/forgejo module, would try to use a
directory named `@data@` for its `STATIC_ROOT_PATH` assets.

This went unnoticed until now, because most users use the nixos/forgejo
module in which we explicitly set this option/setting/path to
`cfg.package.data` by default (`pkgs.forgejo.data`).

Also, this commit hard-copies the patch in question from gitea to our
nixpkgs derivation directory.

We decided a long time ago to part ways, and forgejo inheriting the
patch from gitea's drv directory puts strain on gitea.

So we don't do that anymore and instead maintain that patch ourselves
from now on.

Unfortunately, `substituteInPlace --subst-var` does not error, when the
substitution fails.

This would have prevented this issue from going unnoticed.
-rw-r--r--pkgs/applications/version-management/forgejo/default.nix4
-rw-r--r--pkgs/applications/version-management/forgejo/static-root-path.patch13
2 files changed, 15 insertions, 2 deletions
diff --git a/pkgs/applications/version-management/forgejo/default.nix b/pkgs/applications/version-management/forgejo/default.nix
index d7098115dad8..0060dea785dd 100644
--- a/pkgs/applications/version-management/forgejo/default.nix
+++ b/pkgs/applications/version-management/forgejo/default.nix
@@ -59,11 +59,11 @@ buildGoModule rec {
   buildInputs = lib.optional pamSupport pam;
 
   patches = [
-    ./../gitea/static-root-path.patch
+    ./static-root-path.patch
   ];
 
   postPatch = ''
-    substituteInPlace modules/setting/setting.go --subst-var data
+    substituteInPlace modules/setting/server.go --subst-var data
   '';
 
   tags = lib.optional pamSupport "pam"
diff --git a/pkgs/applications/version-management/forgejo/static-root-path.patch b/pkgs/applications/version-management/forgejo/static-root-path.patch
new file mode 100644
index 000000000000..7f70329c6040
--- /dev/null
+++ b/pkgs/applications/version-management/forgejo/static-root-path.patch
@@ -0,0 +1,13 @@
+diff --git a/modules/setting/server.go b/modules/setting/server.go
+index 183906268..fa02e8915 100644
+--- a/modules/setting/server.go
++++ b/modules/setting/server.go
+@@ -319,7 +319,7 @@ func loadServerFrom(rootCfg ConfigProvider) {
+ 	OfflineMode = sec.Key("OFFLINE_MODE").MustBool()
+ 	Log.DisableRouterLog = sec.Key("DISABLE_ROUTER_LOG").MustBool()
+ 	if len(StaticRootPath) == 0 {
+-		StaticRootPath = AppWorkPath
++		StaticRootPath = "@data@"
+ 	}
+ 	StaticRootPath = sec.Key("STATIC_ROOT_PATH").MustString(StaticRootPath)
+ 	StaticCacheTime = sec.Key("STATIC_CACHE_TIME").MustDuration(6 * time.Hour)