From d028bf0af4e6f793add72a13fd80feaf3b7b8521 Mon Sep 17 00:00:00 2001 From: Alejandro Angulo Date: Mon, 20 Nov 2023 08:09:13 -0800 Subject: [PATCH] Added gitea module --- modules/nixos/services/gitea/default.nix | 61 ++++++++++++++++++++++++ systems/x86_64-linux/node/default.nix | 5 ++ 2 files changed, 66 insertions(+) create mode 100644 modules/nixos/services/gitea/default.nix diff --git a/modules/nixos/services/gitea/default.nix b/modules/nixos/services/gitea/default.nix new file mode 100644 index 0000000..986f73a --- /dev/null +++ b/modules/nixos/services/gitea/default.nix @@ -0,0 +1,61 @@ +{ + options, + config, + lib, + pkgs, + format, + ... +}: +with lib; let + cfg = config.aa.services.gitea; + gitea_cfg = config.services.gitea; +in { + options.aa.services.gitea = with types; { + enable = mkEnableOption "gitea"; + acmeCertName = mkOption { + type = str; + default = ""; + description = '' + If set to a non-empty string, forces SSL with the supplied acme + certificate. + ''; + }; + }; + + config = mkIf cfg.enable { + services.gitea = { + enable = true; + appName = "Internal Gitea server"; + database = { + type = "postgres"; + }; + + useWizard = false; + + settings = { + server = { + DOMAIN = "gitea.kilonull.com"; + ROOT_URL = "https://gitea.kilonull.com"; + HTTP_PORT = 3001; + }; + + session.COOKIE_SECURE = true; + service.DISABLE_REGISTRATION = true; + }; + }; + + services.nginx = { + enable = true; + virtualHosts."gitea.kilonull.com" = + { + locations."/" = { + proxyPass = "http://127.0.0.1:${toString gitea_cfg.settings.server.HTTP_PORT}"; + }; + } + // lib.optionalAttrs (cfg.acmeCertName != "") { + forceSSL = true; + useACMEHost = cfg.acmeCertName; + }; + }; + }; +} diff --git a/systems/x86_64-linux/node/default.nix b/systems/x86_64-linux/node/default.nix index 0fb6c50..c9acd12 100644 --- a/systems/x86_64-linux/node/default.nix +++ b/systems/x86_64-linux/node/default.nix @@ -47,6 +47,11 @@ remoteTargetDatasets = ["tank/backups"]; remoteTargetPublicKeys = ["ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIAhA+9O2OBMDH1Xnj6isu36df5TOdZG8aEA4JpN2K60e syncoid@gospel"]; }; + services.gitea = { + enable = true; + acmeCertName = "kilonull.com"; + }; + services.homeassistant = { enable = true; acmeCertName = "kilonull.com";