nixos/gitea: Move to lib.getExe
This makes it so that alternative packages, such as `pkgs.forgejo` are able to be used instead of the default `pkgs.gitea`. Also adds myself as a maintainer of the module. The varible `gitea`, which was used instead of `cfg.package`, has been replaced with the variable `exe`, and is instead the value of the main executable, as gotten from `lib.getExe`. `cfg.package` is used when this value is not appropriate.
This commit is contained in:
parent
901f0c92f1
commit
98dd7f5307
1 changed files with 15 additions and 15 deletions
|
@ -5,7 +5,7 @@ with lib;
|
||||||
let
|
let
|
||||||
cfg = config.services.gitea;
|
cfg = config.services.gitea;
|
||||||
opt = options.services.gitea;
|
opt = options.services.gitea;
|
||||||
gitea = cfg.package;
|
exe = lib.getExe cfg.package;
|
||||||
pg = config.services.postgresql;
|
pg = config.services.postgresql;
|
||||||
useMysql = cfg.database.type == "mysql";
|
useMysql = cfg.database.type == "mysql";
|
||||||
usePostgresql = cfg.database.type == "postgres";
|
usePostgresql = cfg.database.type == "postgres";
|
||||||
|
@ -248,7 +248,7 @@ in
|
||||||
|
|
||||||
staticRootPath = mkOption {
|
staticRootPath = mkOption {
|
||||||
type = types.either types.str types.path;
|
type = types.either types.str types.path;
|
||||||
default = gitea.data;
|
default = cfg.package.data;
|
||||||
defaultText = literalExpression "package.data";
|
defaultText = literalExpression "package.data";
|
||||||
example = "/var/lib/gitea/data";
|
example = "/var/lib/gitea/data";
|
||||||
description = lib.mdDoc "Upper level of template and static files path.";
|
description = lib.mdDoc "Upper level of template and static files path.";
|
||||||
|
@ -481,14 +481,14 @@ in
|
||||||
|
|
||||||
# If we have a folder or symlink with gitea locales, remove it
|
# If we have a folder or symlink with gitea locales, remove it
|
||||||
# And symlink the current gitea locales in place
|
# And symlink the current gitea locales in place
|
||||||
"L+ '${cfg.stateDir}/conf/locale' - - - - ${gitea.out}/locale"
|
"L+ '${cfg.stateDir}/conf/locale' - - - - ${cfg.package.out}/locale"
|
||||||
];
|
];
|
||||||
|
|
||||||
systemd.services.gitea = {
|
systemd.services.gitea = {
|
||||||
description = "gitea";
|
description = "gitea";
|
||||||
after = [ "network.target" ] ++ lib.optional usePostgresql "postgresql.service" ++ lib.optional useMysql "mysql.service";
|
after = [ "network.target" ] ++ lib.optional usePostgresql "postgresql.service" ++ lib.optional useMysql "mysql.service";
|
||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
path = [ gitea pkgs.git pkgs.gnupg ];
|
path = [ cfg.package pkgs.git pkgs.gnupg ];
|
||||||
|
|
||||||
# In older versions the secret naming for JWT was kind of confusing.
|
# In older versions the secret naming for JWT was kind of confusing.
|
||||||
# The file jwt_secret hold the value for LFS_JWT_SECRET and JWT_SECRET
|
# The file jwt_secret hold the value for LFS_JWT_SECRET and JWT_SECRET
|
||||||
|
@ -512,7 +512,7 @@ in
|
||||||
cp -f ${configFile} ${runConfig}
|
cp -f ${configFile} ${runConfig}
|
||||||
|
|
||||||
if [ ! -s ${secretKey} ]; then
|
if [ ! -s ${secretKey} ]; then
|
||||||
${gitea}/bin/gitea generate secret SECRET_KEY > ${secretKey}
|
${exe} generate secret SECRET_KEY > ${secretKey}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Migrate LFS_JWT_SECRET filename
|
# Migrate LFS_JWT_SECRET filename
|
||||||
|
@ -521,15 +521,15 @@ in
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -s ${oauth2JwtSecret} ]; then
|
if [ ! -s ${oauth2JwtSecret} ]; then
|
||||||
${gitea}/bin/gitea generate secret JWT_SECRET > ${oauth2JwtSecret}
|
${exe} generate secret JWT_SECRET > ${oauth2JwtSecret}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -s ${lfsJwtSecret} ]; then
|
if [ ! -s ${lfsJwtSecret} ]; then
|
||||||
${gitea}/bin/gitea generate secret LFS_JWT_SECRET > ${lfsJwtSecret}
|
${exe} generate secret LFS_JWT_SECRET > ${lfsJwtSecret}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -s ${internalToken} ]; then
|
if [ ! -s ${internalToken} ]; then
|
||||||
${gitea}/bin/gitea generate secret INTERNAL_TOKEN > ${internalToken}
|
${exe} generate secret INTERNAL_TOKEN > ${internalToken}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
chmod u+w '${runConfig}'
|
chmod u+w '${runConfig}'
|
||||||
|
@ -548,15 +548,15 @@ in
|
||||||
''}
|
''}
|
||||||
|
|
||||||
# run migrations/init the database
|
# run migrations/init the database
|
||||||
${gitea}/bin/gitea migrate
|
${exe} migrate
|
||||||
|
|
||||||
# update all hooks' binary paths
|
# update all hooks' binary paths
|
||||||
${gitea}/bin/gitea admin regenerate hooks
|
${exe} admin regenerate hooks
|
||||||
|
|
||||||
# update command option in authorized_keys
|
# update command option in authorized_keys
|
||||||
if [ -r ${cfg.stateDir}/.ssh/authorized_keys ]
|
if [ -r ${cfg.stateDir}/.ssh/authorized_keys ]
|
||||||
then
|
then
|
||||||
${gitea}/bin/gitea admin regenerate keys
|
${exe} admin regenerate keys
|
||||||
fi
|
fi
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
@ -565,7 +565,7 @@ in
|
||||||
User = cfg.user;
|
User = cfg.user;
|
||||||
Group = "gitea";
|
Group = "gitea";
|
||||||
WorkingDirectory = cfg.stateDir;
|
WorkingDirectory = cfg.stateDir;
|
||||||
ExecStart = "${gitea}/bin/gitea web --pid /run/gitea/gitea.pid";
|
ExecStart = "${exe} web --pid /run/gitea/gitea.pid";
|
||||||
Restart = "always";
|
Restart = "always";
|
||||||
# Runtime directory and mode
|
# Runtime directory and mode
|
||||||
RuntimeDirectory = "gitea";
|
RuntimeDirectory = "gitea";
|
||||||
|
@ -635,7 +635,7 @@ in
|
||||||
systemd.services.gitea-dump = mkIf cfg.dump.enable {
|
systemd.services.gitea-dump = mkIf cfg.dump.enable {
|
||||||
description = "gitea dump";
|
description = "gitea dump";
|
||||||
after = [ "gitea.service" ];
|
after = [ "gitea.service" ];
|
||||||
path = [ gitea ];
|
path = [ cfg.package ];
|
||||||
|
|
||||||
environment = {
|
environment = {
|
||||||
USER = cfg.user;
|
USER = cfg.user;
|
||||||
|
@ -646,7 +646,7 @@ in
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
Type = "oneshot";
|
Type = "oneshot";
|
||||||
User = cfg.user;
|
User = cfg.user;
|
||||||
ExecStart = "${gitea}/bin/gitea dump --type ${cfg.dump.type}" + optionalString (cfg.dump.file != null) " --file ${cfg.dump.file}";
|
ExecStart = "${exe} dump --type ${cfg.dump.type}" + optionalString (cfg.dump.file != null) " --file ${cfg.dump.file}";
|
||||||
WorkingDirectory = cfg.dump.backupDir;
|
WorkingDirectory = cfg.dump.backupDir;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -658,5 +658,5 @@ in
|
||||||
timerConfig.OnCalendar = cfg.dump.interval;
|
timerConfig.OnCalendar = cfg.dump.interval;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
meta.maintainers = with lib.maintainers; [ srhb ma27 ];
|
meta.maintainers = with lib.maintainers; [ srhb ma27 thehedgeh0g ];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue