Skip to content

Instantly share code, notes, and snippets.

@Mic92
Created December 19, 2022 19:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Mic92/f3036714039b7aa379e0c94f08b35be2 to your computer and use it in GitHub Desktop.
Save Mic92/f3036714039b7aa379e0c94f08b35be2 to your computer and use it in GitHub Desktop.
forgejo
{ lib
, buildGoPackage
, fetchurl
, makeWrapper
, git
, bash
, gzip
, openssh
, pam
, sqliteSupport ? true
, pamSupport ? true
, nixosTests
}:
buildGoPackage rec {
pname = "forgejo";
version = "1.18.0-rc1-1";
# not fetching directly from the git repo, because that lacks several vendor files for the web UI
src = fetchurl {
name = "forgejo-${version}.tar.gz";
url = "https://codeberg.org/attachments/976c426a-3e04-49ff-9762-47fab50624a3";
sha256 = "sha256-kreBMHlMVB1UeG67zMbszGrgjaROateCRswH7GrKnEw=";
};
patches = [
./static-root-path.patch
];
postPatch = ''
substituteInPlace modules/setting/setting.go --subst-var data
'';
nativeBuildInputs = [ makeWrapper ];
buildInputs = lib.optional pamSupport pam;
preBuild =
let
tags = lib.optional pamSupport "pam"
++ lib.optional sqliteSupport "sqlite sqlite_unlock_notify";
tagsString = lib.concatStringsSep " " tags;
in
''
export buildFlagsArray=(
-tags="${tagsString}"
-ldflags='-X "main.Version=${version}" -X "main.Tags=${tagsString}"'
)
'';
outputs = [ "out" "data" ];
postInstall = ''
mkdir $data
cp -R ./go/src/${goPackagePath}/{public,templates,options} $data
mkdir -p $out
cp -R ./go/src/${goPackagePath}/options/locale $out/locale
wrapProgram $out/bin/gitea \
--prefix PATH : ${lib.makeBinPath [ bash git gzip openssh ]}
'';
goPackagePath = "code.gitea.io/gitea";
passthru.tests = nixosTests.gitea;
meta = with lib; {
description = "Git with a cup of tea";
homepage = "https://gitea.io";
license = licenses.mit;
maintainers = with maintainers; [ disassembler kolaente ma27 techknowlogick ];
};
}
diff --git a/modules/setting/setting.go b/modules/setting/setting.go
index 45e55a2..9d18ee4 100644
--- a/modules/setting/setting.go
+++ b/modules/setting/setting.go
@@ -667,7 +667,7 @@ func NewContext() {
OfflineMode = sec.Key("OFFLINE_MODE").MustBool()
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment