Merge pull request #30030 from bobvanderlinden/pr-gogs-static-root-path
gogs: avoid creating symlinks each run
This commit is contained in:
commit
672bf13c1f
@ -25,6 +25,7 @@ let
|
|||||||
HTTP_ADDR = ${cfg.httpAddress}
|
HTTP_ADDR = ${cfg.httpAddress}
|
||||||
HTTP_PORT = ${toString cfg.httpPort}
|
HTTP_PORT = ${toString cfg.httpPort}
|
||||||
ROOT_URL = ${cfg.rootUrl}
|
ROOT_URL = ${cfg.rootUrl}
|
||||||
|
STATIC_ROOT_PATH = ${cfg.staticRootPath}
|
||||||
|
|
||||||
[session]
|
[session]
|
||||||
COOKIE_NAME = session
|
COOKIE_NAME = session
|
||||||
@ -175,6 +176,13 @@ in
|
|||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
staticRootPath = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = "${pkgs.gogs.data}";
|
||||||
|
example = "/var/lib/gogs/data";
|
||||||
|
description = "Upper level of template and static files path.";
|
||||||
|
};
|
||||||
|
|
||||||
extraConfig = mkOption {
|
extraConfig = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
default = "";
|
default = "";
|
||||||
@ -195,6 +203,8 @@ in
|
|||||||
runConfig = "${cfg.stateDir}/custom/conf/app.ini";
|
runConfig = "${cfg.stateDir}/custom/conf/app.ini";
|
||||||
secretKey = "${cfg.stateDir}/custom/conf/secret_key";
|
secretKey = "${cfg.stateDir}/custom/conf/secret_key";
|
||||||
in ''
|
in ''
|
||||||
|
mkdir -p ${cfg.stateDir}
|
||||||
|
|
||||||
# copy custom configuration and generate a random secret key if needed
|
# copy custom configuration and generate a random secret key if needed
|
||||||
${optionalString (cfg.useWizard == false) ''
|
${optionalString (cfg.useWizard == false) ''
|
||||||
mkdir -p ${cfg.stateDir}/custom/conf
|
mkdir -p ${cfg.stateDir}/custom/conf
|
||||||
|
@ -16,9 +16,12 @@ buildGoPackage rec {
|
|||||||
sha256 = "1xn1b4dxf7r8kagps3yvp31zskfxn50k1gfic9abl4kjwpwk78c0";
|
sha256 = "1xn1b4dxf7r8kagps3yvp31zskfxn50k1gfic9abl4kjwpwk78c0";
|
||||||
};
|
};
|
||||||
|
|
||||||
patchPhase = ''
|
patches = [ ./static-root-path.patch ];
|
||||||
|
|
||||||
|
postPatch = ''
|
||||||
patchShebangs .
|
patchShebangs .
|
||||||
'';
|
substituteInPlace pkg/setting/setting.go --subst-var data
|
||||||
|
'';
|
||||||
|
|
||||||
nativeBuildInputs = [ makeWrapper ];
|
nativeBuildInputs = [ makeWrapper ];
|
||||||
|
|
||||||
@ -33,10 +36,7 @@ buildGoPackage rec {
|
|||||||
cp -R $src/{public,templates} $data
|
cp -R $src/{public,templates} $data
|
||||||
|
|
||||||
wrapProgram $bin/bin/gogs \
|
wrapProgram $bin/bin/gogs \
|
||||||
--prefix PATH : ${makeBinPath [ bash git gzip openssh ]} \
|
--prefix PATH : ${makeBinPath [ bash git gzip openssh ]}
|
||||||
--run 'export GOGS_WORK_DIR=''${GOGS_WORK_DIR:-$PWD}' \
|
|
||||||
--run 'mkdir -p "$GOGS_WORK_DIR" && cd "$GOGS_WORK_DIR"' \
|
|
||||||
--run "ln -fs $data/{public,templates} ."
|
|
||||||
'';
|
'';
|
||||||
|
|
||||||
goPackagePath = "github.com/gogits/gogs";
|
goPackagePath = "github.com/gogits/gogs";
|
||||||
|
@ -0,0 +1,13 @@
|
|||||||
|
diff --git a/pkg/setting/setting.go b/pkg/setting/setting.go
|
||||||
|
index f206592d..796da6ef 100644
|
||||||
|
--- a/pkg/setting/setting.go
|
||||||
|
+++ b/pkg/setting/setting.go
|
||||||
|
@@ -474,7 +474,7 @@ func NewContext() {
|
||||||
|
LocalURL = sec.Key("LOCAL_ROOT_URL").MustString(string(Protocol) + "://localhost:" + HTTPPort + "/")
|
||||||
|
OfflineMode = sec.Key("OFFLINE_MODE").MustBool()
|
||||||
|
DisableRouterLog = sec.Key("DISABLE_ROUTER_LOG").MustBool()
|
||||||
|
- StaticRootPath = sec.Key("STATIC_ROOT_PATH").MustString(workDir)
|
||||||
|
+ StaticRootPath = sec.Key("STATIC_ROOT_PATH").MustString("@data@")
|
||||||
|
AppDataPath = sec.Key("APP_DATA_PATH").MustString("data")
|
||||||
|
EnableGzip = sec.Key("ENABLE_GZIP").MustBool()
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user