From be4df58cbbe6fb1337eacbf4e898836b155002c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Motiejus=20Jak=C5=A1tys?= Date: Thu, 24 Aug 2023 23:34:48 +0300 Subject: [PATCH] move gitea to its own module --- hosts/hel1-a/configuration.nix | 73 +------------------------- modules/services/default.nix | 1 + modules/services/gitea/default.nix | 82 ++++++++++++++++++++++++++++++ 3 files changed, 85 insertions(+), 71 deletions(-) create mode 100644 modules/services/gitea/default.nix diff --git a/hosts/hel1-a/configuration.nix b/hosts/hel1-a/configuration.nix index 848423f..1575908 100644 --- a/hosts/hel1-a/configuration.nix +++ b/hosts/hel1-a/configuration.nix @@ -69,6 +69,8 @@ services = { node_exporter.enable = true; + gitea.enable = true; + deployerbot = { follower = { enable = true; @@ -96,23 +98,6 @@ }; }; - users = { - users = { - git = { - description = "Gitea Service"; - home = "/var/lib/gitea"; - useDefaultShell = true; - group = "gitea"; - isSystemUser = true; - uid = myData.uidgid.gitea; - }; - }; - - groups = { - gitea.gid = myData.uidgid.gitea; - }; - }; - environment.systemPackages = with pkgs; [ headscale nixos-option @@ -130,12 +115,6 @@ }; }; - openssh = { - extraConfig = '' - AcceptEnv GIT_PROTOCOL - ''; - }; - headscale = { enable = true; settings = { @@ -160,51 +139,6 @@ }; }; - gitea = { - enable = true; - user = "git"; - database.user = "git"; - settings = { - admin.DISABLE_REGULAR_ORG_CREATION = true; - api.ENABLE_SWAGGER = false; - mirror.ENABLED = false; - other.SHOW_FOOTER_VERSION = false; - packages.ENABLED = false; - repository = { - DEFAULT_REPO_UNITS = "repo.code,repo.releases"; - DISABLE_MIGRATIONS = true; - DISABLE_STARS = true; - ENABLE_PUSH_CREATE_USER = true; - }; - security.LOGIN_REMEMBER_DAYS = 30; - server = { - ENABLE_GZIP = true; - LANDING_PAGE = "/motiejus"; - ROOT_URL = "https://git.jakstys.lt"; - HTTP_ADDR = "127.0.0.1"; - HTTP_PORT = 3000; - DOMAIN = "git.jakstys.lt"; - }; - service = { - DISABLE_REGISTRATION = true; - ENABLE_TIMETRACKING = false; - ENABLE_USER_HEATMAP = false; - SHOW_MILESTONES_DASHBOARD_PAGE = false; - COOKIE_SECURE = true; - }; - log.LEVEL = "Error"; - # TODO: does not work with 1.7.4, getting error - # in the UI when testing the email sending workflow. - #mailer = { - # ENABLED = true; - # MAILER_TYPE = "sendmail"; - # FROM = ""; - # SENDMAIL_PATH = "${pkgs.system-sendmail}/bin/sendmail"; - #}; - "service.explore".DISABLE_USERS_PAGE = true; - }; - }; - caddy = { enable = true; email = "motiejus+acme@jakstys.lt"; @@ -214,9 +148,6 @@ virtualHosts."vpn.jakstys.lt".extraConfig = '' reverse_proxy 127.0.0.1:8080 ''; - virtualHosts."git.jakstys.lt".extraConfig = '' - reverse_proxy 127.0.0.1:3000 - ''; virtualHosts."www.jakstys.lt".extraConfig = '' redir https://jakstys.lt ''; diff --git a/modules/services/default.nix b/modules/services/default.nix index 3712ab9..9d14e99 100644 --- a/modules/services/default.nix +++ b/modules/services/default.nix @@ -7,6 +7,7 @@ imports = [ ./deployerbot ./friendlyport + ./gitea ./node_exporter ./nsd-acme ./postfix diff --git a/modules/services/gitea/default.nix b/modules/services/gitea/default.nix new file mode 100644 index 0000000..f932e36 --- /dev/null +++ b/modules/services/gitea/default.nix @@ -0,0 +1,82 @@ +{ + config, + lib, + myData, + ... +}: { + options.mj.services.gitea = with lib.types; { + enable = lib.mkEnableOption "Enable gitea"; + }; + + config = lib.mkIf config.mj.services.gitea.enable { + users = { + users.git = { + description = "Gitea Service"; + home = "/var/lib/gitea"; + useDefaultShell = true; + group = "gitea"; + isSystemUser = true; + uid = myData.uidgid.gitea; + }; + + groups.gitea.gid = myData.uidgid.gitea; + }; + + services = { + gitea = { + enable = true; + user = "git"; + database.user = "git"; + settings = { + admin.DISABLE_REGULAR_ORG_CREATION = true; + api.ENABLE_SWAGGER = false; + mirror.ENABLED = false; + other.SHOW_FOOTER_VERSION = false; + packages.ENABLED = false; + repository = { + DEFAULT_REPO_UNITS = "repo.code,repo.releases"; + DISABLE_MIGRATIONS = true; + DISABLE_STARS = true; + ENABLE_PUSH_CREATE_USER = true; + }; + security.LOGIN_REMEMBER_DAYS = 30; + server = { + ENABLE_GZIP = true; + LANDING_PAGE = "/motiejus"; + ROOT_URL = "https://git.jakstys.lt"; + HTTP_ADDR = "127.0.0.1"; + HTTP_PORT = 3000; + DOMAIN = "git.jakstys.lt"; + }; + service = { + DISABLE_REGISTRATION = true; + ENABLE_TIMETRACKING = false; + ENABLE_USER_HEATMAP = false; + SHOW_MILESTONES_DASHBOARD_PAGE = false; + COOKIE_SECURE = true; + }; + log.LEVEL = "Error"; + # TODO: does not work with 1.19.4, getting error + # in the UI when testing the email sending workflow. + #mailer = { + # ENABLED = true; + # MAILER_TYPE = "sendmail"; + # FROM = ""; + # SENDMAIL_PATH = "${pkgs.system-sendmail}/bin/sendmail"; + #}; + "service.explore".DISABLE_USERS_PAGE = true; + }; + }; + + openssh.extraConfig = '' + AcceptEnv GIT_PROTOCOL + ''; + + caddy = { + virtualHosts."git.jakstys.lt".extraConfig = '' + reverse_proxy 127.0.0.1:3000 + ''; + }; + }; + }; +}