From b4b62b5bc6d2cc1d1f73433d2d7e0e5914e6346e Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Sun, 31 Jan 2021 17:46:46 +0100 Subject: [PATCH] services: add gitea --- configuration.nix | 2 ++ services/default.nix | 1 + services/gitea.nix | 43 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 46 insertions(+) create mode 100644 services/gitea.nix diff --git a/configuration.nix b/configuration.nix index 27d1524..aa95f4d 100644 --- a/configuration.nix +++ b/configuration.nix @@ -69,6 +69,8 @@ # List services that you want to enable: my.services = { + # Gitea forge + gitea.enable = true; # Matrix backend and Element chat front-end matrix.enable = true; }; diff --git a/services/default.nix b/services/default.nix index db8d088..85bba5d 100644 --- a/services/default.nix +++ b/services/default.nix @@ -2,6 +2,7 @@ { imports = [ + ./gitea.nix ./matrix.nix ./nginx.nix ]; diff --git a/services/gitea.nix b/services/gitea.nix new file mode 100644 index 0000000..3de200e --- /dev/null +++ b/services/gitea.nix @@ -0,0 +1,43 @@ +# A low-ressource, full-featured git forge. +{ config, lib, ... }: +let + cfg = config.my.services.gitea; + domain = config.networking.domain; + giteaDomain = "gitea.${config.networking.domain}"; +in +{ + options.my.services.gitea = { + enable = lib.mkEnableOption "Gitea"; + }; + + config = lib.mkIf cfg.enable { + services.gitea = { + enable = true; + appName = "Ambroisie's Gitea"; + domain = "${giteaDomain}"; + rootUrl = "https://${giteaDomain}"; + useWizard = true; + disableRegistration = true; + lfs.enable = true; + }; + + # Enable DB + services.postgresql = { + enable = true; + authentication = '' + local gitea all ident map=gitea-users + ''; + identMap = '' # Map the gitea user to postgresql + gitea-users gitea gitea + ''; + }; + + # Proxy to Gitea + services.nginx.virtualHosts."${giteaDomain}" = { + forceSSL = true; + useACMEHost = "${domain}"; + + locations."/".proxyPass = "http://localhost:3000/"; + }; + }; +}