summary refs log tree commit diff stats
path: root/modules/nixos/vhack/git-server.nix
blob: 9e21b5cc0a4edb066dc605573316cf739acf7816 (plain) (blame)
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
44
45
46
47
48
{
  config,
  lib,
  pkgs,
  ...
}: let
  cfg = config.vhack.git-server;
in {
  options.vhack.git-server.enable = lib.mkEnableOption "a lightweight git-server,
  realised with cgit and gitolite.";
  config = lib.mkIf cfg.enable {
    services = {
      gitolite = {
        enable = true;
        adminPubkey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIAe4o1PM6VasT3KZNl5NYvgkkBrPOg36dqsywd10FztS openpgp:0x21D20D6A";
        dataDir = "/srv/gitolite";
        user = "git";
        group = "git";
        extraGitoliteRc = ''
          $RC{UMASK} = 0027; # Enable group access, important for cgit.
        '';
      };
      cgit."git.vhack.eu" = {
        enable = true;
        package = pkgs.cgit-pink;
        scanPath = "${config.services.gitolite.dataDir}/repositories";
        settings = {
          enable-http-clone = true;
          section-from-path = true;
          project-list = "${config.services.gitolite.dataDir}/projects.list";
          source-filter = "${config.services.cgit."git.vhack.eu".package}/lib/cgit/filters/syntax-highlighting.py";
        };
      };
      nginx.virtualHosts."git.vhack.eu" = {
        enableACME = true;
        forceSSL = true;
        locations."~ \"^/[0-9A-Za-z._-]+/(HEAD|info/refs|objects/info/(alternates|http-alternates|packs)|[0-9a-f]{2}/([0-9a-f]{38}|[0-9a-f]{62})|pack/pack-([0-9a-f]{40}|[0-9a-f]{64})\\.(pack|idx)|git-upload-pack|git-receive-pack)$\"".extraConfig = ''
          include ${pkgs.nginx}/conf/fastcgi_params;
          fastcgi_param GIT_HTTP_EXPORT_ALL "";
          fastcgi_param GIT_PROJECT_ROOT ${cfg.dataDir};
          fastcgi_param PATH_INFO $fastcgi_script_name;
          fastcgi_param SCRIPT_FILENAME ${pkgs.git}/bin/git-http-backend;
          fastcgi_pass unix:${config.services.fcgiwrap.socketAddress};
        '';
      };
    };
  };
}