dotfiles/modules/nixos/services/forgejo/default.nix

85 lines
3.5 KiB
Nix
Raw Normal View History

2023-11-20 16:09:13 +00:00
{
config,
lib,
2024-08-17 05:34:35 +00:00
pkgs,
namespace,
2023-11-20 16:09:13 +00:00
...
}: let
inherit (lib) mkIf mkEnableOption mkOption types;
2024-10-26 23:22:03 +00:00
cfg = config.${namespace}.services.forgejo;
forgejo_cfg = config.services.forgejo;
2023-11-20 16:09:13 +00:00
in {
2024-10-26 23:22:03 +00:00
options.${namespace}.services.forgejo = {
enable = mkEnableOption "forgejo";
2024-10-31 02:30:16 +00:00
domain = mkOption {
type = types.str;
description = ''
The domain name to use for this instance
'';
};
2023-11-20 16:09:13 +00:00
acmeCertName = mkOption {
type = types.str;
2023-11-20 16:09:13 +00:00
default = "";
description = ''
If set to a non-empty string, forces SSL with the supplied acme
certificate.
'';
};
};
config = mkIf cfg.enable {
2024-10-26 23:22:03 +00:00
services.forgejo = {
2023-11-20 16:09:13 +00:00
enable = true;
database = {
2024-10-26 23:22:03 +00:00
type = "sqlite3";
2023-11-20 16:09:13 +00:00
};
useWizard = false;
settings = {
server = {
2024-10-31 02:30:16 +00:00
DOMAIN = cfg.domain;
ROOT_URL = "https://${cfg.domain}";
2023-11-20 16:09:13 +00:00
HTTP_PORT = 3001;
};
session.COOKIE_SECURE = true;
service.DISABLE_REGISTRATION = true;
2024-08-06 02:27:51 +00:00
2024-10-31 02:30:16 +00:00
# webhook.ALLOWED_HOST_LIST = "hydra.kilonull.com";
2024-08-17 05:34:35 +00:00
ui.THEMES = ''
catppuccin-latte-rosewater,catppuccin-latte-flamingo,catppuccin-latte-pink,catppuccin-latte-mauve,catppuccin-latte-red,catppuccin-latte-maroon,catppuccin-latte-peach,catppuccin-latte-yellow,catppuccin-latte-green,catppuccin-latte-teal,catppuccin-latte-sky,catppuccin-latte-sapphire,catppuccin-latte-blue,catppuccin-latte-lavender,catppuccin-frappe-rosewater,catppuccin-frappe-flamingo,catppuccin-frappe-pink,catppuccin-frappe-mauve,catppuccin-frappe-red,catppuccin-frappe-maroon,catppuccin-frappe-peach,catppuccin-frappe-yellow,catppuccin-frappe-green,catppuccin-frappe-teal,catppuccin-frappe-sky,catppuccin-frappe-sapphire,catppuccin-frappe-blue,catppuccin-frappe-lavender,catppuccin-macchiato-rosewater,catppuccin-macchiato-flamingo,catppuccin-macchiato-pink,catppuccin-macchiato-mauve,catppuccin-macchiato-red,catppuccin-macchiato-maroon,catppuccin-macchiato-peach,catppuccin-macchiato-yellow,catppuccin-macchiato-green,catppuccin-macchiato-teal,catppuccin-macchiato-sky,catppuccin-macchiato-sapphire,catppuccin-macchiato-blue,catppuccin-macchiato-lavender,catppuccin-mocha-rosewater,catppuccin-mocha-flamingo,catppuccin-mocha-pink,catppuccin-mocha-mauve,catppuccin-mocha-red,catppuccin-mocha-maroon,catppuccin-mocha-peach,catppuccin-mocha-yellow,catppuccin-mocha-green,catppuccin-mocha-teal,catppuccin-mocha-sky,catppuccin-mocha-sapphire,catppuccin-mocha-blue,catppuccin-mocha-lavender
'';
2024-10-26 23:22:03 +00:00
ui.DEFAULT_THEME = "catppuccin-mocha-green";
2023-11-20 16:09:13 +00:00
};
};
2024-08-17 05:34:35 +00:00
systemd.tmpfiles.rules = [
2024-10-26 23:22:03 +00:00
"d '${forgejo_cfg.customDir}/public' 0750 ${forgejo_cfg.user} ${forgejo_cfg.group} - -"
"z '${forgejo_cfg.customDir}/public' 0750 ${forgejo_cfg.user} ${forgejo_cfg.group} - -"
"d '${forgejo_cfg.customDir}/public/assets' 0750 ${forgejo_cfg.user} ${forgejo_cfg.group} - -"
"z '${forgejo_cfg.customDir}/public/assets' 0750 ${forgejo_cfg.user} ${forgejo_cfg.group} - -"
"L+ '${forgejo_cfg.customDir}/public/assets/css' - - - - ${pkgs.aa.catppuccin-gitea}/share/gitea-themes"
2024-08-17 05:34:35 +00:00
];
2023-11-20 16:09:13 +00:00
services.nginx = {
enable = true;
2024-10-31 02:30:16 +00:00
virtualHosts."${cfg.domain}" =
2023-11-20 16:09:13 +00:00
{
locations."/" = {
2024-10-26 23:22:03 +00:00
proxyPass = "http://127.0.0.1:${toString forgejo_cfg.settings.server.HTTP_PORT}";
};
locations."= /" = {
return = "301 /explore/repos";
2023-11-20 16:09:13 +00:00
};
}
// lib.optionalAttrs (cfg.acmeCertName != "") {
forceSSL = true;
useACMEHost = cfg.acmeCertName;
};
};
};
}