blob: e23c10c295618c76be7f22df0f2a5d040d062824 (
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
|
{ self, ... }:
{
flake.machines.tharos =
let
path = "/git/infra";
in
{
nixos =
{
config,
pkgs,
lib,
...
}:
let
cgit = config.services.cgit.infra.nginx.virtualHost;
nginx = lib.head config.services.nginx.virtualHosts.${cgit}.listen;
in
{
users.groups.git = { };
users.users = lib.mapAttrs (_: _': { extraGroups = [ "git" ]; }) self.keys;
environment.systemPackages = with pkgs; [ git ];
systemd.services.init-git-repos = {
wantedBy = [ "multi-user.target" ];
before = [ "cgit.service" ];
serviceConfig = {
Type = "oneshot";
RemainAfterExit = true;
};
script = ''
if [ ! -f ${path} ]; then
${lib.getExe pkgs.git} init --shared=group --bare ${path}
fi
'';
};
systemd.tmpfiles.rules = [
"d ${path} 2775 root git -"
];
services.cgit.infra = rec {
enable = true;
nginx.virtualHost = "git.${self.domain}";
repos.infra = {
desc = "Quellcode für die technische Infrastruktur des Stadtteilbeirats Heimfeld";
inherit path;
clone-url = "https://${nginx.virtualHost}/$CGIT_REPO_URL ssh://${self.domain}${path}";
defbranch = "main";
};
settings = {
about-filter = "${pkgs.cgit}/lib/cgit/filters/about-formatting.sh";
readme = ":README.md";
enable-commit-graph = true;
};
};
services.nginx.virtualHosts.${cgit}.listen = [
{
addr = "127.0.0.1";
port = 8083;
}
];
services.caddy.virtualHosts.${cgit}.extraConfig = ''
reverse_proxy localhost:${toString nginx.port}
'';
};
vm =
{
config,
lib,
...
}:
let
httpPort = 700;
cgit = config.services.cgit.infra.nginx.virtualHost;
in
{
services.cgit.infra = {
nginx.virtualHost = lib.mkForce "git.localhost";
repos.infra.clone-url = lib.mkForce "http://${cgit}:${
with config.virtualisation; toString (portOffset + exposedPorts.http.port)
}/$CGIT_REPO_URL ssh://localhost:${
toString (config.virtualisation.portOffset + lib.head config.services.openssh.ports)
}${path}";
};
services.caddy.virtualHosts = {
"http://${cgit}:${toString config.virtualisation.exposedPorts.http.port}".extraConfig =
config.services.caddy.virtualHosts.${cgit}.extraConfig;
};
services.getty.helpLine = lib.mkBefore ''
cgit: http://${cgit}:${with config.virtualisation; toString (portOffset + exposedPorts.http.port)}
'';
};
};
}
|