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