101 lines
2.7 KiB
Nix
Executable file
101 lines
2.7 KiB
Nix
Executable file
{ config, lib, pkgs, options, ... }:
|
|
|
|
with lib;
|
|
let
|
|
cfg = config.modules.services.forgejo;
|
|
|
|
theme = pkgs.fetchzip {
|
|
url = "https://github.com/catppuccin/gitea/releases/download/v0.4.1/catppuccin-gitea.tar.gz";
|
|
sha256 = "1wi4gi431b8hpmk6cr05jygplj76p6jwwlihajxz9131aqxym1fp";
|
|
stripRoot = false;
|
|
};
|
|
in {
|
|
options.modules.services.forgejo = {
|
|
enable = mkEnableOption "enable forgejo, a lightweight git server";
|
|
domain = mkOption {
|
|
type = types.str;
|
|
default = "git.reidlab.online";
|
|
};
|
|
port = mkOption {
|
|
type = types.int;
|
|
default = 3000;
|
|
};
|
|
package = mkOption {
|
|
type = types.package;
|
|
default = pkgs.forgejo;
|
|
};
|
|
};
|
|
|
|
config = mkIf cfg.enable {
|
|
services = {
|
|
gitea = {
|
|
enable = true;
|
|
package = cfg.package;
|
|
stateDir = "/var/lib/${cfg.domain}";
|
|
appName = "reidlab's git instance";
|
|
database = {
|
|
type = "postgres";
|
|
name = "gitea";
|
|
};
|
|
settings = {
|
|
"security" = {
|
|
INSTALL_LOCK = true;
|
|
PASSWORD_HASH_ALGO = "argon2";
|
|
PASSWORD_CHECK_PWN = true;
|
|
};
|
|
"ui" = {
|
|
THEMES =
|
|
builtins.concatStringsSep
|
|
","
|
|
(["auto"]
|
|
++ (map (name: removePrefix "theme-" (removeSuffix ".css" name))
|
|
(attrNames (builtins.readDir theme))));
|
|
DEFAULT_THEME = "catppuccin-mocha-red";
|
|
};
|
|
"ui.meta" = {
|
|
AUTHOR = "reidlab";
|
|
DESCRIPTION = "reidlab's git instance";
|
|
};
|
|
"server" = {
|
|
DOMAIN = cfg.domain;
|
|
HTTP_PORT = cfg.port;
|
|
ROOT_URL = "https://${cfg.domain}/";
|
|
};
|
|
"repository" = {
|
|
DEFAULT_BRANCH = "main";
|
|
};
|
|
"picture" = {
|
|
DISABLE_GRAVATAR = false;
|
|
ENABLE_FEDERATED_AVATAR = true;
|
|
};
|
|
"service" = {
|
|
ENABLE_CAPTCHA = false;
|
|
REGISTER_EMAIL_CONFIRM = false;
|
|
DEFAULT_KEEP_EMAIL_PRIVATE = true;
|
|
DEFAULT_ENABLE_TIMETRACING = true;
|
|
DISABLE_REGISTRATION = true;
|
|
};
|
|
"federation" = {
|
|
ENABLED = true;
|
|
};
|
|
};
|
|
};
|
|
|
|
nginx.virtualHosts."${cfg.domain}" = {
|
|
forceSSL = true;
|
|
enableACME = true;
|
|
locations."/".extraConfig = ''
|
|
proxy_pass http://127.0.0.1:${toString cfg.port};
|
|
'';
|
|
};
|
|
};
|
|
|
|
systemd.services.gitea = {
|
|
preStart = mkAfter ''
|
|
rm -rf ${config.services.gitea.customDir}/public/assets
|
|
mkdir -p ${config.services.gitea.customDir}/public/assets
|
|
ln -sf ${theme} ${config.services.gitea.customDir}/public/assets/css
|
|
'';
|
|
};
|
|
};
|
|
}
|