add forgejo-cli to forgejo.nix module

This commit is contained in:
Douze Bé 2024-12-20 23:57:38 +01:00
parent 81fda64f42
commit 327c1990d0

View file

@ -55,6 +55,28 @@ in
secrets.mailer.PASSWD = "${config.nixin.forge.smtp-pwd-file}";
};
environment.systemPackages = let
cfg = config.services.forgejo;
forgejo-cli = pkgs.writeScriptBin "forgejo" ''
#!${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
];
networking.hosts = {
"127.0.0.1" = ["${config.nixin.forge.domain}"];
};
systemd.services.forgejo.preStart = let
adminCmd = "${lib.getExe config.services.forgejo.package} admin user";
in ''