2021-01-31 17:46:46 +01:00
|
|
|
# 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
|
|
|
|
{
|
2021-02-03 12:09:54 +01:00
|
|
|
options.my.services.gitea = with lib; {
|
|
|
|
enable = mkEnableOption "Gitea";
|
|
|
|
port = mkOption {
|
|
|
|
type = types.port;
|
|
|
|
default = 3000;
|
|
|
|
example = 8080;
|
|
|
|
description = "Internal port";
|
|
|
|
};
|
2021-01-31 17:46:46 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
|
|
services.gitea = {
|
|
|
|
enable = true;
|
2021-02-03 12:09:54 +01:00
|
|
|
|
|
|
|
appName = "Ambroisie's forge";
|
|
|
|
httpPort = cfg.port;
|
2021-01-31 17:46:46 +01:00
|
|
|
domain = "${giteaDomain}";
|
|
|
|
rootUrl = "https://${giteaDomain}";
|
2021-02-03 12:09:54 +01:00
|
|
|
|
|
|
|
user = "git";
|
|
|
|
lfs.enable = true;
|
|
|
|
|
2021-01-31 17:46:46 +01:00
|
|
|
useWizard = true;
|
|
|
|
disableRegistration = true;
|
2021-02-03 12:09:54 +01:00
|
|
|
|
|
|
|
# only send cookies via HTTPS
|
|
|
|
cookieSecure = true;
|
|
|
|
|
|
|
|
database = {
|
|
|
|
type = "postgres"; # Automatic setup
|
|
|
|
user = "git"; # User needs to be the same as gitea user
|
|
|
|
};
|
2021-01-31 17:46:46 +01:00
|
|
|
};
|
|
|
|
|
2021-02-03 12:09:54 +01:00
|
|
|
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;
|
2021-01-31 17:46:46 +01:00
|
|
|
};
|
2021-02-03 12:09:54 +01:00
|
|
|
users.groups.git = { };
|
2021-01-31 17:46:46 +01:00
|
|
|
|
|
|
|
# Proxy to Gitea
|
|
|
|
services.nginx.virtualHosts."${giteaDomain}" = {
|
|
|
|
forceSSL = true;
|
|
|
|
useACMEHost = "${domain}";
|
|
|
|
|
2021-02-03 12:09:54 +01:00
|
|
|
locations."/".proxyPass = "http://localhost:${toString cfg.port}/";
|
2021-01-31 17:46:46 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|