2020-10-01 15:46:04 -07:00
|
|
|
{ options, config, lib, pkgs, ... }:
|
|
|
|
|
2020-03-28 22:48:43 -07:00
|
|
|
with lib;
|
2020-10-01 15:46:04 -07:00
|
|
|
with lib.my;
|
|
|
|
let cfg = config.modules.services.gitea;
|
|
|
|
in {
|
2020-03-28 22:48:43 -07:00
|
|
|
options.modules.services.gitea = {
|
2020-10-01 15:46:04 -07:00
|
|
|
enable = mkBoolOpt false;
|
2019-11-18 18:41:35 -08:00
|
|
|
};
|
2019-11-17 22:25:29 -08:00
|
|
|
|
2020-10-01 15:46:04 -07:00
|
|
|
config = mkIf cfg.enable {
|
2021-01-01 21:26:00 -08:00
|
|
|
# Allows git@... clone addresses rather than gitea@...
|
2020-03-28 22:48:43 -07:00
|
|
|
users.users.git = {
|
|
|
|
useDefaultShell = true;
|
|
|
|
home = "/var/lib/gitea";
|
|
|
|
group = "gitea";
|
|
|
|
};
|
|
|
|
|
2021-01-01 21:26:00 -08:00
|
|
|
user.extraGroups = [ "gitea" ];
|
|
|
|
|
2020-03-28 22:48:43 -07:00
|
|
|
services.gitea = {
|
|
|
|
enable = true;
|
2019-11-18 18:41:35 -08:00
|
|
|
|
|
|
|
user = "git";
|
2020-12-19 20:02:46 -08:00
|
|
|
database.user = "git";
|
2019-11-18 21:22:23 -08:00
|
|
|
|
2020-12-31 16:34:11 -08:00
|
|
|
disableRegistration = true;
|
2020-03-28 22:48:43 -07:00
|
|
|
# We're assuming SSL-only connectivity
|
|
|
|
cookieSecure = true;
|
2020-12-31 16:34:11 -08:00
|
|
|
# Only log what's important
|
2021-01-01 18:19:06 -08:00
|
|
|
log.level = "Info";
|
2020-12-31 16:34:11 -08:00
|
|
|
settings.server.DISABLE_ROUTER_LOG = true;
|
2020-03-28 22:48:43 -07:00
|
|
|
};
|
2020-12-19 20:02:46 -08:00
|
|
|
|
2021-01-01 18:19:06 -08:00
|
|
|
services.fail2ban.jails.gitea = ''
|
|
|
|
enabled = true
|
|
|
|
filter = gitea
|
|
|
|
logpath = ${config.services.gitea.log.rootPath}/gitea.log
|
|
|
|
bantime = 1800
|
|
|
|
findtime = 3600
|
|
|
|
banaction = %(banaction_allports)s
|
|
|
|
'';
|
2019-11-18 18:41:35 -08:00
|
|
|
};
|
2019-11-17 22:25:29 -08:00
|
|
|
}
|