services: gitea: clean up configuration

I want the ssh addresses to use 'git' as a user, so the service must be
set up with this user as well.

I also want the port to be configurable in case I need to change it.
This commit is contained in:
Bruno BELANYI 2021-02-03 12:09:54 +01:00
parent 6038d0df60
commit 303da60e0b

View file

@ -6,38 +6,60 @@ let
giteaDomain = "gitea.${config.networking.domain}"; giteaDomain = "gitea.${config.networking.domain}";
in in
{ {
options.my.services.gitea = { options.my.services.gitea = with lib; {
enable = lib.mkEnableOption "Gitea"; enable = mkEnableOption "Gitea";
port = mkOption {
type = types.port;
default = 3000;
example = 8080;
description = "Internal port";
};
}; };
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
services.gitea = { services.gitea = {
enable = true; enable = true;
appName = "Ambroisie's Gitea";
appName = "Ambroisie's forge";
httpPort = cfg.port;
domain = "${giteaDomain}"; domain = "${giteaDomain}";
rootUrl = "https://${giteaDomain}"; rootUrl = "https://${giteaDomain}";
user = "git";
lfs.enable = true;
useWizard = true; useWizard = true;
disableRegistration = true; disableRegistration = true;
lfs.enable = true;
# only send cookies via HTTPS
cookieSecure = true;
database = {
type = "postgres"; # Automatic setup
user = "git"; # User needs to be the same as gitea user
};
}; };
# Enable DB users.users.git = {
services.postgresql = { description = "Gitea Service";
enable = true; home = config.services.gitea.stateDir;
authentication = '' useDefaultShell = true;
local gitea all ident map=gitea-users group = "git";
'';
identMap = '' # Map the gitea user to postgresql # The service for gitea seems to hardcode the group as
gitea-users gitea gitea # gitea, so, uh, just in case?
''; extraGroups = [ "gitea" ];
isSystemUser = true;
}; };
users.groups.git = { };
# Proxy to Gitea # Proxy to Gitea
services.nginx.virtualHosts."${giteaDomain}" = { services.nginx.virtualHosts."${giteaDomain}" = {
forceSSL = true; forceSSL = true;
useACMEHost = "${domain}"; useACMEHost = "${domain}";
locations."/".proxyPass = "http://localhost:3000/"; locations."/".proxyPass = "http://localhost:${toString cfg.port}/";
}; };
}; };
} }