This repository has no description
5.6 kB
203 lines
1{ self, config, lib, pkgs, ... }:
2
3let
4 git = self.inputs.stockholm.lib.git;
5 out = {
6 imports = [
7 self.inputs.stockholm.nixosModules.git
8 ];
9 services.nginx.enable = true;
10 krebs.git = {
11 enable = true;
12 cgit = {
13 settings = {
14 root-title = "public repositories at ${config.krebs.build.host.name}";
15 root-desc = "keep calm and engage";
16 };
17 };
18 repos = repos;
19 rules = rules;
20 };
21
22 krebs.iptables.tables.filter.INPUT.rules = [
23 { predicate = "-i retiolum -p tcp --dport 80"; target = "ACCEPT"; }
24 ];
25
26 system.activationScripts.spool-chmod = ''
27 ${pkgs.coreutils}/bin/chmod +x /var/spool
28 '';
29 };
30
31 cgit-clear-cache = pkgs.cgit-clear-cache.override {
32 inherit (config.krebs.git.cgit.settings) cache-root;
33 };
34
35 repos =
36 public-repos //
37 lib.optionalAttrs config.krebs.build.host.secure restricted-repos;
38
39 rules = lib.concatMap make-rules (lib.attrValues repos);
40
41 public-repos = lib.mapAttrs make-public-repo {
42 Reaktor = {
43 cgit.desc = "Reaktor IRC bot";
44 cgit.section = "software";
45 };
46 buildbot-classic = {
47 cgit.desc = "fork of buildbot";
48 cgit.section = "software";
49 };
50 cholerab = {
51 cgit.desc = "krebs thesauron & enterprise-patterns";
52 cgit.section = "documentation";
53 };
54 disko = {
55 cgit.desc = "take a description of your disk layout and produce a format script";
56 cgit.section = "software";
57 };
58 go = {
59 cgit.desc = "url shortener";
60 cgit.section = "software";
61 };
62 grib2json-bin = {
63 cgit.desc = "build jar of grib2json";
64 cgit.section = "deployment";
65 };
66 krebspage = {
67 cgit.desc = "homepage of krebs";
68 cgit.section = "configuration";
69 };
70 krops = {
71 cgit.desc = "krebs deployment";
72 cgit.section = "software";
73 };
74 news = {
75 cgit.desc = "take a rss feed and a timeout and print it to stdout";
76 cgit.section = "software";
77 };
78 newsbot-js = {
79 cgit.desc = "print rss feeds to irc channels";
80 cgit.section = "software";
81 };
82 nix-user-chroot = {
83 cgit.desc = "Fork of nix-user-chroot by lethalman";
84 cgit.section = "software";
85 };
86 nix-writers = {
87 cgit.desc = "high level writers for nix";
88 cgit.section = "software";
89 };
90 nixos-generators = {
91 cgit.desc = "custom image builders";
92 cgit.section = "software";
93 };
94 nixpkgs = {
95 cgit.desc = "nixpkgs fork";
96 cgit.section = "configuration";
97 };
98 populate = {
99 cgit.section = "software";
100 };
101 reaktor2 = {
102 cgit.desc = "irc bot";
103 cgit.section = "software";
104 };
105 stockholm = {
106 cgit.desc = "take all the computers hostage, they'll love you!";
107 cgit.section = "configuration";
108 };
109 stockholm-issues = {
110 cgit.desc = "stockholm issues";
111 cgit.section = "issues";
112 };
113 the_playlist = {
114 cgit.desc = "Good Music collection + tools";
115 cgit.section = "art";
116 };
117 workadventure-nix = {
118 cgit.desc = "Nix packaging for workadventure";
119 cgit.section = "deployment";
120 };
121 xmonad-stockholm = {
122 cgit.desc = "krebs xmonad modules";
123 cgit.section = "configuration";
124 };
125 };
126
127 restricted-repos = lib.mapAttrs make-restricted-repo {
128 brain = {
129 collaborators = with config.krebs.users; [ tv makefu ];
130 announce = true;
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 ${lib.optionalString announce (pkgs.gystem.build.etct-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 lib.singleton {
183 user = [ lass lass-green ];
184 repo = [ repo ];
185 perm = push "refs/*" [ non-fast-forward create delete merge ];
186 } ++
187 lib.optional (lib.length (repo.admins or []) > 0) {
188 user = repo.admins;
189 repo = [ repo ];
190 perm = push "refs/*" [ non-fast-forward create delete merge ];
191 } ++
192 lib.optional (lib.length (repo.collaborators or []) > 0) {
193 user = repo.collaborators;
194 repo = [ repo ];
195 perm = fetch;
196 } ++
197 lib.optional repo.public {
198 user = lib.attrValues config.krebs.users;
199 repo = [ repo ];
200 perm = fetch;
201 };
202
203in out