nix-config/services/gitea.nix
Bruno BELANYI 303da60e0b 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.
2021-02-08 10:49:58 +00:00

66 lines
1.5 KiB
Nix

# 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 = with lib; {
enable = mkEnableOption "Gitea";
port = mkOption {
type = types.port;
default = 3000;
example = 8080;
description = "Internal port";
};
};
config = lib.mkIf cfg.enable {
services.gitea = {
enable = true;
appName = "Ambroisie's forge";
httpPort = cfg.port;
domain = "${giteaDomain}";
rootUrl = "https://${giteaDomain}";
user = "git";
lfs.enable = true;
useWizard = true;
disableRegistration = true;
# only send cookies via HTTPS
cookieSecure = true;
database = {
type = "postgres"; # Automatic setup
user = "git"; # User needs to be the same as gitea user
};
};
users.users.git = {
description = "Gitea Service";
home = config.services.gitea.stateDir;
useDefaultShell = true;
group = "git";
# The service for gitea seems to hardcode the group as
# gitea, so, uh, just in case?
extraGroups = [ "gitea" ];
isSystemUser = true;
};
users.groups.git = { };
# Proxy to Gitea
services.nginx.virtualHosts."${giteaDomain}" = {
forceSSL = true;
useACMEHost = "${domain}";
locations."/".proxyPass = "http://localhost:${toString cfg.port}/";
};
};
}