From 96baf345212a298a04159e894d43494719851289 Mon Sep 17 00:00:00 2001 From: twoneis Date: Sat, 8 Feb 2025 01:19:49 +0100 Subject: [PATCH] init forgejo --- devices/ellaca/options.nix | 1 + modules/default.nix | 1 + modules/git/default.nix | 36 ++++++++++++++++++++++++++++++++++++ options.nix | 1 + 4 files changed, 39 insertions(+) create mode 100644 modules/git/default.nix diff --git a/devices/ellaca/options.nix b/devices/ellaca/options.nix index 873a8e4..3f3a8be 100644 --- a/devices/ellaca/options.nix +++ b/devices/ellaca/options.nix @@ -5,6 +5,7 @@ website.enable = true; fedi.enable = false; # Currently broken matrix.enable = true; + git.enable = true; stateVersion = "25.05"; hmStateVersion = "25.05"; diff --git a/modules/default.nix b/modules/default.nix index 0811725..7eed9e4 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -7,6 +7,7 @@ in { ./fedi ./fonts ./games + ./git ./home ./layout ./matrix diff --git a/modules/git/default.nix b/modules/git/default.nix new file mode 100644 index 0000000..8460993 --- /dev/null +++ b/modules/git/default.nix @@ -0,0 +1,36 @@ +{ lib, config, ... }: let + inherit (lib) mkIf; + inherit (config) conf; + cfg = config.services.forgejo.settings.server; +in mkIf conf.git.enable { + services = { + nginx = { + virtualHosts.${cfg.DOMAIN} = { + forceSSL = true; + useACMEHost = "twoneis.site"; + extraConfig = '' + client_max_body_size 512M; + ''; + locations."/".proxyPass = "http://localhost:${toString cfg.HTTP_PORT}"; + }; + }; + + forgejo = { + enable = true; + database.type = "postgres"; + lfs.enable = true; + settings = { + server = { + DOMAIN = "git.twoneis.site"; + ROOT_URL = "https://${cfg.DOMAIN}"; + HTTP_PORT = 3000; + }; + service.DISABLE_REGISTRATION = true; + actions = { + ENABLED = true; + DEFAULT_ACTIONS_URL = "github"; + }; + }; + }; + }; +} diff --git a/options.nix b/options.nix index f097679..24e0867 100644 --- a/options.nix +++ b/options.nix @@ -21,6 +21,7 @@ in { website.enable = mkEnableOption "Serve website through nginx. Nginx must be enabled to work correctly."; fedi.enable = mkEnableOption "Host a fedi server on this machine."; matrix.enable = mkEnableOption "Host a matrix server on this machine"; + git.enable = mkEnableOption "Host a git server on this machine"; # Mixed and more complex options username = mkOption {