nixos-dotfiles

nixos-dotfiles

https://git.tonybtw.com/nixos-dotfiles.git git://git.tonybtw.com/nixos-dotfiles.git
1,905 bytes raw
1
{
2
  config,
3
  pkgs,
4
  ...
5
}: let
6
  domain = "git.tonybtw.com";
7
  gitRoot = "/srv/git";
8
in {
9
  services.cgit.main = {
10
    enable = true;
11
    nginx.virtualHost = domain;
12
    scanPath = gitRoot;
13
    gitHttpBackend.enable = false;
14
    settings = {
15
      root-title = "Tony's Git";
16
      root-desc = "Personal git repositories";
17
      clone-url = "https://${domain}/$CGIT_REPO_URL git://${domain}/$CGIT_REPO_URL";
18
      enable-git-config = 1;
19
      enable-index-owner = 0;
20
      enable-commit-graph = 1;
21
      enable-log-filecount = 1;
22
      enable-log-linecount = 1;
23
      source-filter = "${pkgs.cgit}/lib/cgit/filters/syntax-highlighting.py";
24
      about-filter = "${pkgs.cgit}/lib/cgit/filters/about-formatting.sh";
25
      readme = ":README.md";
26
    };
27
  };
28
29
  services.nginx.virtualHosts.${domain} = {
30
    enableACME = true;
31
    forceSSL = true;
32
    locations."~ ^/([^/]+)/(HEAD|info/refs|objects|git-upload-pack)$" = {
33
      fastcgiParams = {
34
        GIT_HTTP_EXPORT_ALL = "";
35
        GIT_PROJECT_ROOT = gitRoot;
36
        PATH_INFO = "$uri";
37
      };
38
      extraConfig = ''
39
        fastcgi_pass unix:/run/fcgiwrap.sock;
40
      '';
41
    };
42
  };
43
44
  services.fcgiwrap.instances.git = {
45
    process.user = "git";
46
    process.group = "git";
47
    socket = {inherit (config.services.nginx) user group;};
48
  };
49
50
  systemd.services.git-daemon = {
51
    description = "Git daemon";
52
    wantedBy = ["multi-user.target"];
53
    after = ["network.target"];
54
    serviceConfig = {
55
      ExecStart = "${pkgs.git}/bin/git daemon --reuseaddr --base-path=${gitRoot} --export-all --verbose ${gitRoot}";
56
      User = "git";
57
      Group = "git";
58
    };
59
  };
60
61
  users.users.git = {
62
    isSystemUser = true;
63
    group = "git";
64
    home = gitRoot;
65
    shell = "${pkgs.git}/bin/git-shell";
66
  };
67
  users.groups.git = {};
68
69
  systemd.tmpfiles.rules = [
70
    "d ${gitRoot} 0755 git git -"
71
  ];
72
73
  networking.firewall.allowedTCPPorts = [9418];
74
}