disable random people registrating

This commit is contained in:
glenn 2024-10-23 12:19:46 +02:00
parent 9d9550a854
commit b4883aaa32

View file

@ -1,16 +1,18 @@
{ config, ... }: {
config,
let pkgs,
lib,
...
}: let
domain = "git.sondell.org"; domain = "git.sondell.org";
# derp = "hi"; # derp = "hi";
in in {
{
services.forgejo = { services.forgejo = {
enable = true; enable = true;
stateDir = "/pool/var/lib/forgejo"; stateDir = "/pool/var/lib/forgejo";
settings = { settings = {
service = { service = {
# DISABLE_REGISTRATION = true; DISABLE_REGISTRATION = true;
}; };
server = { server = {
ROOT_URL = "https://${domain}/"; ROOT_URL = "https://${domain}/";
@ -19,6 +21,24 @@ in
}; };
}; };
environment.systemPackages = let
cfg = config.services.forgejo;
forgejo-cli = pkgs.writeScriptBin "forgejo-cli" ''
#!${pkgs.runtimeShell}
cd ${cfg.stateDir}
sudo=exec
if [[ "$USER" != forgejo ]]; then
sudo='exec /run/wrappers/bin/sudo -u ${cfg.user} -g ${cfg.group} --preserve-env=GITEA_WORK_DIR --preserve-env=GITEA_CUSTOM'
fi
# Note that these variable names will change
export GITEA_WORK_DIR=${cfg.stateDir}
export GITEA_CUSTOM=${cfg.customDir}
$sudo ${lib.getExe cfg.package} "$@"
'';
in [
forgejo-cli
];
services.nginx = { services.nginx = {
appendHttpConfig = '' appendHttpConfig = ''
map $uri $forgejo_access_log { map $uri $forgejo_access_log {
@ -36,4 +56,3 @@ in
}; };
}; };
} }