This repository has no description
5.5 kB
203 lines
1{ config, lib, pkgs, ... }:
2
3let
4
5 out = {
6 services.nginx.enable = true;
7 krebs.git = {
8 enable = true;
9 cgit = {
10 settings = {
11 root-title = "public repositories at ${config.krebs.build.host.name}";
12 root-desc = "keep calm and engage";
13 };
14 };
15 repos = repos;
16 rules = rules;
17 };
18
19 krebs.iptables.tables.filter.INPUT.rules = [
20 { predicate = "-i retiolum -p tcp --dport 80"; target = "ACCEPT"; }
21 ];
22
23 system.activationScripts.spool-chmod = ''
24 ${pkgs.coreutils}/bin/chmod +x /var/spool
25 '';
26 };
27
28 cgit-clear-cache = pkgs.cgit-clear-cache.override {
29 inherit (config.krebs.git.cgit.settings) cache-root;
30 };
31
32 repos =
33 public-repos //
34 optionalAttrs config.krebs.build.host.secure restricted-repos;
35
36 rules = concatMap make-rules (attrValues repos);
37
38 public-repos = mapAttrs make-public-repo {
39 Reaktor = {
40 cgit.desc = "Reaktor IRC bot";
41 cgit.section = "software";
42 };
43 buildbot-classic = {
44 cgit.desc = "fork of buildbot";
45 cgit.section = "software";
46 };
47 cholerab = {
48 cgit.desc = "krebs thesauron & enterprise-patterns";
49 cgit.section = "documentation";
50 };
51 disko = {
52 cgit.desc = "take a description of your disk layout and produce a format script";
53 cgit.section = "software";
54 };
55 go = {
56 cgit.desc = "url shortener";
57 cgit.section = "software";
58 };
59 grib2json-bin = {
60 cgit.desc = "build jar of grib2json";
61 cgit.section = "deployment";
62 };
63 krebspage = {
64 cgit.desc = "homepage of krebs";
65 cgit.section = "configuration";
66 };
67 krops = {
68 cgit.desc = "krebs deployment";
69 cgit.section = "software";
70 };
71 news = {
72 cgit.desc = "take a rss feed and a timeout and print it to stdout";
73 cgit.section = "software";
74 };
75 newsbot-js = {
76 cgit.desc = "print rss feeds to irc channels";
77 cgit.section = "software";
78 };
79 nix-user-chroot = {
80 cgit.desc = "Fork of nix-user-chroot by lethalman";
81 cgit.section = "software";
82 };
83 nix-writers = {
84 cgit.desc = "high level writers for nix";
85 cgit.section = "software";
86 };
87 nixos-generators = {
88 cgit.desc = "custom image builders";
89 cgit.section = "software";
90 };
91 nixpkgs = {
92 cgit.desc = "nixpkgs fork";
93 cgit.section = "configuration";
94 };
95 populate = {
96 cgit.section = "software";
97 };
98 reaktor2 = {
99 cgit.desc = "irc bot";
100 cgit.section = "software";
101 };
102 stockholm = {
103 cgit.desc = "take all the computers hostage, they'll love you!";
104 cgit.section = "configuration";
105 };
106 stockholm-issues = {
107 cgit.desc = "stockholm issues";
108 cgit.section = "issues";
109 };
110 the_playlist = {
111 cgit.desc = "Good Music collection + tools";
112 cgit.section = "art";
113 };
114 workadventure-nix = {
115 cgit.desc = "Nix packaging for workadventure";
116 cgit.section = "deployment";
117 };
118 xmonad-stockholm = {
119 cgit.desc = "krebs xmonad modules";
120 cgit.section = "configuration";
121 };
122 } // mapAttrs make-public-repo-silent {
123 };
124
125 restricted-repos = mapAttrs make-restricted-repo (
126 {
127 brain = {
128 collaborators = with config.krebs.users; [ tv makefu ];
129 announce = true;
130 };
131 };
132 );
133
134 make-public-repo = name: { cgit ? {}, collaborators ? [], ... }: {
135 inherit cgit collaborators name;
136 public = true;
137 hooks = {
138 post-receive = ''
139 ${pkgs.git-hooks.irc-announce {
140 # TODO make nick = config.krebs.build.host.name the default
141 nick = config.krebs.build.host.name;
142 channel = "#xxx";
143 # TODO define refs in some kind of option per repo
144 server = "irc.r";
145 verbose = config.krebs.build.host.name == "orange";
146 }}
147 ${cgit-clear-cache}/bin/cgit-clear-cache
148 '';
149 };
150 };
151
152 make-public-repo-silent = name: { cgit ? {}, ... }: {
153 inherit cgit name;
154 public = true;
155 };
156
157 make-restricted-repo = name: { admins ? [], collaborators ? [], announce ? true, hooks ? {}, ... }: {
158 inherit admins collaborators name;
159 public = false;
160 hooks = {
161 post-receive = ''
162 ${optionalString announce (pkgs.git-hooks.irc-announce {
163 # TODO make nick = config.krebs.build.host.name the default
164 nick = config.krebs.build.host.name;
165 channel = "#xxx";
166 # TODO define refs in some kind of option per repo
167 refs = [
168 "refs/heads/master"
169 "refs/heads/staging*"
170 ];
171 server = "irc.r";
172 verbose = false;
173 })}
174 ${cgit-clear-cache}/bin/cgit-clear-cache
175 '';
176 } // hooks;
177 };
178
179 make-rules =
180 with git // config.krebs.users;
181 repo:
182 singleton {
183 user = [ lass lass-green ];
184 repo = [ repo ];
185 perm = push "refs/*" [ non-fast-forward create delete merge ];
186 } ++
187 optional (length (repo.admins or []) > 0) {
188 user = repo.admins;
189 repo = [ repo ];
190 perm = push "refs/*" [ non-fast-forward create delete merge ];
191 } ++
192 optional (length (repo.collaborators or []) > 0) {
193 user = repo.collaborators;
194 repo = [ repo ];
195 perm = fetch;
196 } ++
197 optional repo.public {
198 user = attrValues config.krebs.users;
199 repo = [ repo ];
200 perm = fetch;
201 };
202
203in out