From 327c1990d04e1b24e675aed2bd544af1f302dd80 Mon Sep 17 00:00:00 2001 From: Fabrice Bellamy <12b@distrilab.fr> Date: Fri, 20 Dec 2024 23:57:38 +0100 Subject: [PATCH] add forgejo-cli to forgejo.nix module --- modules/forgejo.nix | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/modules/forgejo.nix b/modules/forgejo.nix index aae3e1e..314eb28 100644 --- a/modules/forgejo.nix +++ b/modules/forgejo.nix @@ -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 ''