blob: 1a137db10e8a95aa04113a18469d4f4fc7a1bbfa (
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
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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
|
{
config,
pkgs,
inputModules,
...
}: {
imports = [inputModules.vpsadminos];
config = {
nixpkgs.hostPlatform.system = "x86_64-linux";
deploy = {
enable = true;
ssh.host = "cynerd.cz";
};
cynerd = {
monitoring = {
hw = false;
drives = false;
};
syncthing = {
enable = false;
baseDir = "/nas";
};
wireguard = true;
openvpn.oldpersonal = true;
};
boot.loader.systemd-boot.enable = false;
fileSystems = {
"/nas" = {
device = "172.16.128.63:/nas/2682";
fsType = "nfs";
options = [
"_netdev"
"x-systemd.automount"
];
};
"/nas/nextcloud-sync" = {
device = "/nas/sync";
fsType = "fuse.bindfs";
options = ["map=syncthing/nextcloud:@syncthing/@nextcloud"];
};
"/nas/spt" = {
device = "nas@omnia.spt:/data/nas";
fsType = "fuse.sshfs";
options = [
"allow_other"
"_netdev"
"x-systemd.automount"
"reconnect"
"identityfile=/run/secrets/nas.ssh.priv"
"idmap=user"
"uid=nextcloud"
"gid=nextcloud"
];
};
};
networking = {
useNetworkd = true;
useDHCP = false;
firewall = {
allowedTCPPorts = [80 443];
allowedUDPPorts = [1194];
filterForward = true;
extraForwardRules = ''
iifname {"wg", "personalvpn"} oifname {"wg", "personalvpn"} accept
'';
};
};
systemd.network.wait-online.enable = false;
systemd.services.networking-setup.wantedBy = ["network-online.target"];
environment.systemPackages = with pkgs; [
# fileSystems
bindfs
# Nextcloud
exiftool
ffmpeg-headless
nodejs
];
# Web ######################################################################
services.nginx = {
enable = true;
virtualHosts = {
"cynerd.cz" = {
forceSSL = true;
enableACME = true;
locations = {
"/".root = ../../web;
"/radicale/" = {
proxyPass = "http://127.0.0.1:5232/";
extraConfig = ''
proxy_set_header X-Script-Name /radicale;
proxy_pass_header Authorization;
'';
};
};
};
"git.cynerd.cz" = {
forceSSL = true;
useACMEHost = "cynerd.cz";
root = "${pkgs.cgit}/cgit";
locations."/".tryFiles = "$uri @cgit";
locations."@cgit".extraConfig = ''
fastcgi_pass unix:${config.services.fcgiwrap.instances.cgit.socket.address};
fastcgi_param SCRIPT_FILENAME ${pkgs.cgit}/cgit/cgit.cgi;
fastcgi_param PATH_INFO $uri;
fastcgi_param QUERY_STRING $args;
fastcgi_param HTTP_HOST $server_name;
'';
};
"cloud.cynerd.cz" = {
forceSSL = true;
useACMEHost = "cynerd.cz";
};
"grafana.cynerd.cz" = {
forceSSL = true;
useACMEHost = "cynerd.cz";
locations."/" = {
proxyPass = "http://127.0.0.1:${toString config.services.grafana.settings.server.http_port}/";
extraConfig = "proxy_set_header Host $host;";
proxyWebsockets = true;
};
};
"searx.cynerd.cz" = {
forceSSL = true;
useACMEHost = "cynerd.cz";
locations."/".extraConfig = ''
uwsgi_pass "unix:///run/searx/searx.sock";
include ${config.services.nginx.package}/conf/uwsgi_params;
'';
};
};
};
services.fcgiwrap.instances.cgit = {
process.user = "git";
socket = {inherit (config.services.nginx) user group;};
};
security.acme = {
acceptTerms = true;
defaults.email = "cynerd+acme@email.cz";
certs."cynerd.cz".extraDomainNames = [
"cloud.cynerd.cz"
"git.cynerd.cz"
"grafana.cynerd.cz"
"searx.cynerd.cz"
];
};
# Git ######################################################################
services.gitolite = {
enable = true;
user = "git";
group = "git";
dataDir = "/var/lib/git";
adminPubkey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIaMmBV0wPvG5JQIWxi20IDlLokhRBumTEbUUD9TNWoY Bootstrap gitolite key";
};
services.gitDaemon = {
enable = false;
user = "gitdemon";
group = "gitdaemon";
basePath = "/var/lib/git/repositories";
};
environment.etc."cgitrc".text = ''
root-title=Cynerd's git repository
root-desc=All my projects (at least those released to public)
#logo=cynerd.cz/wolf.svg
virtual-root=/
# Allow download of tar.gz, tar.bz2 and zip-files
snapshots=tar.gz tar.bz2 zip
## List of common mimetypes
mimetype.gif=image/gif
mimetype.html=text/html
mimetype.jpg=image/jpeg
mimetype.jpeg=image/jpeg
mimetype.pdf=application/pdf
mimetype.png=image/png
mimetype.svg=image/svg+xml
source-filter=${pkgs.cgit}/lib/cgit/filters/syntax-highlighting.py
about-filter=${pkgs.cgit}/lib/cgit/filters/about-formatting.sh
readme=:README.md
readme=:README.adoc
enable-index-owner=0
enable-index-links=1
enable-http-clone=1
clone-url=https://git.cynerd.cz/$CGIT_REPO_URL git://cynerd.cz/$CGIT_REPO_URL.git git@cynerd.cz:$CGIT_REPO_URL
enable-commit-graph=1
branch-sort=age
remove-suffix=1
enable-git-config=1
project-list=/var/lib/git/projects.list
scan-path=/var/lib/git/repositories/
'';
# Nextcloud ################################################################
services.nextcloud = {
enable = true;
package = pkgs.nextcloud28;
https = true;
hostName = "cloud.cynerd.cz";
datadir = "/nas/nextcloud";
config = {
adminuser = "cynerd";
adminpassFile = "/run/secrets/nextcloud.admin.pass";
dbtype = "pgsql";
dbhost = "/run/postgresql";
dbtableprefix = "oc_";
};
settings = {
#log_type = "systemd";
default_phone_region = "CZ";
};
phpExtraExtensions = php: [php.pgsql php.pdo_pgsql];
phpOptions = {
"opcache.interned_strings_buffer" = "16";
};
maxUploadSize = "1G";
appstoreEnable = false;
extraApps = {
inherit
(config.services.nextcloud.package.packages.apps)
bookmarks
calendar
contacts
cookbook
deck
forms
groupfolders
impersonate
maps
memories
notes
phonetrack
previewgenerator
spreed
tasks
twofactor_nextcloud_notification
twofactor_webauthn
;
# Additional modules can be fetched with:
# NEXTCLOUD_VERSIONS=28 nix run nixpkgs#nc4nix -- -apps "passwords,integration_homeassistant,integration_github,integration_gitlab"
passwords = pkgs.fetchNextcloudApp {
url = "https://git.mdns.eu/api/v4/projects/45/packages/generic/passwords/2024.7.0/passwords.tar.gz";
sha256 = "1RwLOE2aUwISMF/WcYmL8sKs+KXBlYv0OHw8PizrGCY=";
license = "agpl3Plus";
};
integration_github = pkgs.fetchNextcloudApp {
url = "https://github.com/nextcloud-releases/integration_github/releases/download/v2.0.7/integration_github-v2.0.7.tar.gz";
sha256 = "x4BrBdrvmbdwZcZL6FLAY27B5OpkXIsw92XsD076Aqg=";
license = "agpl3Plus";
};
integration_gitlab = pkgs.fetchNextcloudApp {
url = "https://github.com/nextcloud-releases/integration_gitlab/releases/download/v3.0.1/integration_gitlab-v3.0.1.tar.gz";
sha256 = "FAF5CHwAVm55QS9NO8B5zsvJ0BWa7Mwfw6kYr2js0Es=";
license = "agpl3Plus";
};
};
};
# Postgresql ###############################################################
services.postgresql = {
enable = true;
ensureUsers = [
{name = "cynerd";}
{
name = "nextcloud";
ensureDBOwnership = true;
}
];
ensureDatabases = ["nextcloud"];
extraPlugins = ps: with ps; [timescaledb];
};
# SearX ####################################################################
services.searx = {
enable = true;
environmentFile = "/run/secrets/searx.env";
settings = {
server.secret_key = "@SEARX_SECRET_KEY@";
search = {
autocomplete = "google";
autocomplete_min = 2;
};
ui = {
query_in_title = true;
infinite_scroll = true;
center_alignment = true;
hotkeys = "vim";
};
engines = [
{
name = "seznam";
disabled = false;
}
{
name = "material icons";
disabled = false;
}
{
name = "svgrepo";
disabled = false;
}
{
name = "peertube";
disabled = false;
}
{
name = "lib.rs";
disabled = false;
}
{
name = "gitlab";
disabled = false;
}
{
name = "sourcehut";
disabled = false;
}
{
name = "free software directory";
disabled = false;
}
{
name = "cppreference";
disabled = false;
}
{
name = "searchcode code";
disabled = false;
}
{
name = "imdb";
disabled = false;
}
{
name = "tmdb";
disabled = false;
}
];
};
runInUwsgi = true;
uwsgiConfig = {
socket = "/run/searx/searx.sock";
chmod-socket = "660";
};
redisCreateLocally = true;
};
users.groups.searx.members = ["nginx"];
# Old Syncthing ############################################################
services.syncthing = {
enable = true;
openDefaultPorts = true;
overrideDevices = false;
overrideFolders = false;
dataDir = "/nas/sync";
configDir = "/nas/sync/.syncthing";
};
};
}
|