summaryrefslogtreecommitdiff
path: root/sys/gitea/default.nix
blob: 69dfbc2d74e5a34b0583f36b6d6ad7c3eb561764 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
{ config, lib, ... }:
with lib; let
  cfg = config.local.gitea;
in
{
  options.local.gitea = {
    enable = mkEnableOption "gitea";
  };

  config = mkIf cfg.enable {
    environment.etc."fail2ban/filter.d/gitea.local".text = ''
      [Definition]
      failregex = .*(Failed authentication attempt|invalid credentials|Attempted access of unknown user).* from <HOST>
      ignoreregex =
    '';

    services = {
      fail2ban.jails.gitea.settings = {
        filter = "gitea";
        logpath = "${config.services.gitea.stateDir}/log/gitea.log";
        maxretry = "10";
        findtime = "3600";
        bantime = "900";
        action = "iptables-allports";
      };

      gitea = {
        enable = true;
        useWizard = true;
      };
    };

    users = {
      users.gitea.uid = 962;
      groups.gitea.gid = 962;
    };
  };
}