nixos/gitea: Allow customizing derivation to use
This commit is contained in:
parent
4810776809
commit
e166aee826
@ -4,6 +4,7 @@ with lib;
|
|||||||
|
|
||||||
let
|
let
|
||||||
cfg = config.services.gitea;
|
cfg = config.services.gitea;
|
||||||
|
gitea = cfg.package;
|
||||||
pg = config.services.postgresql;
|
pg = config.services.postgresql;
|
||||||
usePostgresql = cfg.database.type == "postgres";
|
usePostgresql = cfg.database.type == "postgres";
|
||||||
configFile = pkgs.writeText "app.ini" ''
|
configFile = pkgs.writeText "app.ini" ''
|
||||||
@ -57,6 +58,13 @@ in
|
|||||||
description = "Enable Gitea Service.";
|
description = "Enable Gitea Service.";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
package = mkOption {
|
||||||
|
default = pkgs.gitea;
|
||||||
|
type = types.package;
|
||||||
|
defaultText = "pkgs.gitea";
|
||||||
|
description = "gitea derivation to use";
|
||||||
|
};
|
||||||
|
|
||||||
useWizard = mkOption {
|
useWizard = mkOption {
|
||||||
default = false;
|
default = false;
|
||||||
type = types.bool;
|
type = types.bool;
|
||||||
@ -203,7 +211,7 @@ in
|
|||||||
|
|
||||||
staticRootPath = mkOption {
|
staticRootPath = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
default = "${pkgs.gitea.data}";
|
default = "${gitea.data}";
|
||||||
example = "/var/lib/gitea/data";
|
example = "/var/lib/gitea/data";
|
||||||
description = "Upper level of template and static files path.";
|
description = "Upper level of template and static files path.";
|
||||||
};
|
};
|
||||||
@ -223,7 +231,7 @@ in
|
|||||||
description = "gitea";
|
description = "gitea";
|
||||||
after = [ "network.target" "postgresql.service" ];
|
after = [ "network.target" "postgresql.service" ];
|
||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
path = [ pkgs.gitea.bin ];
|
path = [ gitea.bin ];
|
||||||
|
|
||||||
preStart = let
|
preStart = let
|
||||||
runConfig = "${cfg.stateDir}/custom/conf/app.ini";
|
runConfig = "${cfg.stateDir}/custom/conf/app.ini";
|
||||||
@ -253,7 +261,7 @@ in
|
|||||||
HOOKS=$(find ${cfg.repositoryRoot} -mindepth 4 -maxdepth 4 -type f -wholename "*git/hooks/*")
|
HOOKS=$(find ${cfg.repositoryRoot} -mindepth 4 -maxdepth 4 -type f -wholename "*git/hooks/*")
|
||||||
if [ "$HOOKS" ]
|
if [ "$HOOKS" ]
|
||||||
then
|
then
|
||||||
sed -ri 's,/nix/store/[a-z0-9.-]+/bin/gitea,${pkgs.gitea.bin}/bin/gitea,g' $HOOKS
|
sed -ri 's,/nix/store/[a-z0-9.-]+/bin/gitea,${gitea.bin}/bin/gitea,g' $HOOKS
|
||||||
sed -ri 's,/nix/store/[a-z0-9.-]+/bin/env,${pkgs.coreutils}/bin/env,g' $HOOKS
|
sed -ri 's,/nix/store/[a-z0-9.-]+/bin/env,${pkgs.coreutils}/bin/env,g' $HOOKS
|
||||||
sed -ri 's,/nix/store/[a-z0-9.-]+/bin/bash,${pkgs.bash}/bin/bash,g' $HOOKS
|
sed -ri 's,/nix/store/[a-z0-9.-]+/bin/bash,${pkgs.bash}/bin/bash,g' $HOOKS
|
||||||
sed -ri 's,/nix/store/[a-z0-9.-]+/bin/perl,${pkgs.perl}/bin/perl,g' $HOOKS
|
sed -ri 's,/nix/store/[a-z0-9.-]+/bin/perl,${pkgs.perl}/bin/perl,g' $HOOKS
|
||||||
@ -261,7 +269,7 @@ in
|
|||||||
if [ ! -d ${cfg.stateDir}/conf/locale ]
|
if [ ! -d ${cfg.stateDir}/conf/locale ]
|
||||||
then
|
then
|
||||||
mkdir -p ${cfg.stateDir}/conf
|
mkdir -p ${cfg.stateDir}/conf
|
||||||
cp -r ${pkgs.gitea.out}/locale ${cfg.stateDir}/conf/locale
|
cp -r ${gitea.out}/locale ${cfg.stateDir}/conf/locale
|
||||||
fi
|
fi
|
||||||
'' + optionalString (usePostgresql && cfg.database.createDatabase) ''
|
'' + optionalString (usePostgresql && cfg.database.createDatabase) ''
|
||||||
if ! test -e "${cfg.stateDir}/db-created"; then
|
if ! test -e "${cfg.stateDir}/db-created"; then
|
||||||
@ -288,7 +296,7 @@ in
|
|||||||
User = cfg.user;
|
User = cfg.user;
|
||||||
WorkingDirectory = cfg.stateDir;
|
WorkingDirectory = cfg.stateDir;
|
||||||
PermissionsStartOnly = true;
|
PermissionsStartOnly = true;
|
||||||
ExecStart = "${pkgs.gitea.bin}/bin/gitea web";
|
ExecStart = "${gitea.bin}/bin/gitea web";
|
||||||
Restart = "always";
|
Restart = "always";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user