-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathradicle.nix
More file actions
173 lines (163 loc) · 4.87 KB
/
radicle.nix
File metadata and controls
173 lines (163 loc) · 4.87 KB
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
{
config,
pkgs,
lib,
inputs,
...
}:
with lib;
let
cfg = config.hosts.radicle;
nativeCiConfig = pkgs.writeText "native-ci.yaml" (
builtins.toJSON {
state = "/var/lib/radicle/native-ci/state";
log = "/var/lib/radicle/native-ci/native-ci.log";
base_url = "http://ci.thuis";
}
);
customExplorer = pkgs.radicle-explorer.withConfig {
preferredSeeds = [
{
hostname = "seed.boers.email";
port = 443;
scheme = "https";
}
];
};
in
{
options.hosts.radicle = {
enable = mkEnableOption "Radicle git node + ci";
};
config = mkIf cfg.enable {
age.secrets.radicle-server.file = "${inputs.secrets}/radicle-server.age";
age.secrets.github-token = {
file = "${inputs.secrets}/github-token.age";
owner = "radicle";
group = "radicle";
};
users.users.caddy.extraGroups = [ "radicle" ];
systemd.services.radicle-ci-broker = {
serviceConfig = {
EnvironmentFile = config.age.secrets.github-token.path;
LoadCredential = "pgp-public:${inputs.secrets}/keys/pgp.asc";
};
path = with pkgs; [
git
bash
coreutils
curl
gnupg
];
};
systemd.tmpfiles.rules = [
"d /var/lib/radicle 0750 radicle radicle -"
"d /var/lib/radicle/ci-reports 0750 radicle radicle -"
"d /var/lib/radicle/native-ci 0750 radicle radicle -"
"d /var/lib/radicle/native-ci/state 0750 radicle radicle -"
"f /var/lib/radicle/native-ci/native-ci.log 0640 radicle radicle -"
"a+ /var/lib/radicle/native-ci/state - - - - d:g:radicle:rx,g:radicle:rx"
];
services.caddy.virtualHosts = {
"seed.boers.email" = {
extraConfig = ''
reverse_proxy ${config.services.radicle.httpd.listenAddress}:${toString config.services.radicle.httpd.listenPort}
'';
};
"git.boers.email" = {
extraConfig = ''
root * ${customExplorer}
file_server
try_files {path} /index.html
'';
};
"ci.thuis" = {
extraConfig = ''
import headscale
@runs path_regexp run ^/[a-f0-9-]{36}/.*$
handle @runs {
root * /var/lib/radicle/native-ci/state
file_server
}
handle {
root * /var/lib/radicle/ci-reports
file_server browse
}
'';
};
};
services.radicle = {
enable = true;
privateKey = config.age.secrets.radicle-server.path;
publicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICpIiSK+rRAp4HPvWrjy2iUluPcInEsHAqJTN5FIOCFc radicle";
ci = {
# https://app.radicle.xyz/nodes/radicle.liw.fi/rad:zwTxygwuz5LDGBq255RA2CbNGrz8/tree/doc/userguide.md
broker = {
enable = true;
settings = {
report_dir = "/var/lib/radicle/ci-reports";
adapters.native = {
command = "${pkgs.radicle-native-ci}/bin/radicle-native-ci";
env = {
RAD_HOME = "/var/lib/radicle";
RADICLE_NATIVE_CI = "${nativeCiConfig}";
};
};
triggers = [
{
adapter = "native";
filters = [
{
And = [
{ HasFile = ".radicle/native.yaml"; }
{
Or = [
{ Node = "z6MkqW1hUP7eyCVEcNm3DyT6NPYAdJuGunkNW5EcB4fY5fEN"; } # donk
{ Node = "z6MkrST9cLyV8NmWorWfXnfeRpYmRcmbKifMe9oiKaFJpqrw"; } # nurma
{ Node = "z6MkkE5buQW9vLSqcmqUSTurMLDvjN82qwTDUoiG4T7NWnkc"; } # paddy
];
}
{
Or = [
"DefaultBranch"
"PatchCreated"
"PatchUpdated"
];
}
];
}
];
}
];
};
};
};
settings = {
web = {
avatarUrl = "https://storage.boers.email/random/icon.png";
description = "Martijn's Radicle repositories";
pinned = {
repositories = [
"rad:z2Jkf9zxGPxEhCfGLpgRAcHRj8x2n"
"rad:z3bTedCQLQRkCdAmKKZTMSBimNp4J"
"rad:z2r9euHZW161kfQNxdF4apHddD3mm"
"rad:z2AdUML1AaZmUVidUJ4vwQDJhmvKg"
"rad:z3kbRfxk6ySRqoQpv2dg8NYzRdsyQ"
"rad:zb1FuXow3wJemDDPFWGFa49rNA4z"
];
};
};
node = {
alias = config.networking.hostName;
externalAddresses = [ "seed.boers.email:8776" ];
seedingPolicy.default = "block";
};
};
node.openFirewall = true;
httpd = {
enable = true;
listenPort = 8027;
};
};
};
}