summaryrefslogtreecommitdiffstats
path: root/tv/2configs/git.nix
blob: 4bc971370ec0d5cbb27c9b4bb89ca3b3f11105ce (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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
{ config, lib, pkgs, ... }:

with config.krebs.lib;

let

  out = {
    krebs.git = {
      enable = true;
      cgit = {
        settings = {
          root-title = "repositories at ${config.krebs.build.host.name}";
          root-desc = "mostly krebs";
        };
      };
      repos = repos;
      rules = rules;
    };
  };

  repos =
    public-repos //
    optionalAttrs config.krebs.build.host.secure restricted-repos;

  rules = concatMap make-rules (attrValues repos);

  public-repos = mapAttrs make-public-repo ({
  } // mapAttrs (_: recursiveUpdate { cgit.section = "1. miscellaneous"; }) {
    cac-api = {
      cgit.desc = "CloudAtCost API command line interface";
    };
    get = {};
    hack = {};
    load-env = {};
    make-snapshot = {};
    much = {};
    newsbot-js = {};
    nixpkgs = {};
    populate.desc = "source code installer";
    push = {};
    regfish = {};
    soundcloud = {
      cgit.desc = "SoundCloud command line interface";
    };
    stockholm = {
      cgit.desc = "NixOS configuration";
    };
    with-tmpdir = {};
  } // mapAttrs (_: recursiveUpdate { cgit.section = "2. Haskell libraries"; }) {
    blessings = {};
    mime = {};
    quipper = {};
    scanner = {};
    wai-middleware-time = {};
    web-routes-wai-custom = {};
    xintmap = {};
    xmonad-stockholm = {};
  } // mapAttrs (_: recursiveUpdate { cgit.section = "3. museum"; }) {
    cgserver = {};
    crude-mail-setup = {};
    dot-xmonad = {};
    nixos-infest = {};
    painload = {};
  });

  restricted-repos = mapAttrs make-restricted-repo (
    {
      brain = {
        collaborators = with config.krebs.users; [ lass makefu ];
      };
    } //
    # TODO don't put secrets/repos.nix into the store
    import <secrets/repos.nix> { inherit config lib pkgs; }
  );

  make-public-repo = name: { cgit ? {}, ... }: {
    inherit cgit name;
    public = true;
    hooks = optionalAttrs (config.krebs.build.host.name == "cd") {
      post-receive = pkgs.git-hooks.irc-announce {
        # TODO make nick = config.krebs.build.host.name the default
        nick = config.krebs.build.host.name;
        channel = "#retiolum";
        server = "cd.retiolum";
        verbose = true;
      };
    };
  };

  make-restricted-repo = name: { collaborators ? [], ... }: {
    inherit collaborators name;
    public = false;
  };

  make-rules =
    with git // config.krebs.users;
    repo:
      singleton {
        user = [ tv tv-xu ];
        repo = [ repo ];
        perm = push "refs/*" [ non-fast-forward create delete merge ];
      } ++
      optional repo.public {
        user = [ lass makefu ];
        repo = [ repo ];
        perm = fetch;
      } ++
      optional (repo.collaborators or [] != []) {
        user = repo.collaborators;
        repo = [ repo ];
        perm = fetch;
      };

in out