about summary refs log tree commit diff
path: root/nix/hosts/corrino/www/cs.emile.space.nix
blob: d07d9b24942d57930ee968436efe3d244a5689f4 (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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
{ config, lib, ... }:

let

  inherit (builtins) toJSON;
  inherit (lib) mergeAttrsList mapAttrsToList;

  # get's all repos configured in cgit and converts them into some JSON that is used by hound
  repos = toJSON (
    mergeAttrsList (
      map (x: {
        "${x.name}" = {
          url = "file://${x.path}";
        };
      }) (mapAttrsToList (name: value: value // { name = "${name}"; }) config.services.cgit.main.repos)
    )
  );

  cfg = config.services.hound;
in
{
  services.nginx.virtualHosts."cs.emile.space" = {
    forceSSL = true;
    enableACME = true;
    locations = {
      "/" = {
        proxyPass = "http://${cfg.listen}";
      };
    };
  };

  # add hound user to git group so the local repos can be read
  # users.users.hound.extraGroups = [ "git" ];

  users.groups."git".members = [ "hound" ];

  # The `.gitignore` of the user `hound` should contain the following:
  #
  # [safe]
  #       directory = /var/lib/git/repositories/*
  #       directory = /var/lib/git/repositories/faila.git
  #       directory = /var/lib/git/repositories/faila2.git

  services.hound = {
    enable = true;

    config = ''
      			{
      			  "dbpath": "/var/lib/hound/data",
      			  "max-concurrent-indexers" : 6,
      		    "vcs-config" : {
      	        "git" : {
                  "detect-ref" : true
      	        }
      		    },
      			  "repos" : ${repos}
      			}
      		'';

    listen = "127.0.0.1:${toString config.emile.ports.hound}";
  };
}