summaryrefslogtreecommitdiff
path: root/git.nix
blob: a63d71879d7ed8dcc1a7636c54b1c852fc0045ed (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
39
40
41
42
43
{config, pkgs, ...}: let
  domain = "git.kassouni.net";
  repoRoot = "/srv/git";
in {
  users.users.git = {
    isSystemUser = true;
    group = "git";
    home = repoRoot;
    createHome = true;
    homeMode = "755";
    shell = "${pkgs.git}/bin/git-shell";
    openssh.authorizedKeys.keys = config.my.gitKeys;
  };
  users.groups.git = { };

  environment.systemPackages = [ pkgs.git ];

  services.openssh.extraConfig = ''
    Match user git
      AllowTcpForwarding no
      AllowAgentForwarding no
      PermitTTY no
  '';

  services.cgit.${domain} = {
    enable = true;
    scanPath = repoRoot;
    gitHttpBackend.checkExportOkFiles = true;
    settings.strict-export = "git-daemon-export-ok";
  };

  services.nginx.virtualHosts.${domain} = {
    forceSSL = true;
    enableACME = true;
  };

  security.acme = {
    acceptTerms = true;
    defaults.email = "alex@kassouni.net";
  };

  networking.firewall.allowedTCPPorts = [ 80 443 ];
}