self-hosting/profiles/backend.nix

74 lines
2.1 KiB
Nix
Raw Normal View History

2021-11-25 00:59:46 +01:00
{ config, lib, pkgs, ... }:
{
imports = [
../environment.nix
../hardware/hcloud.nix
../modules/openssh.nix
../modules/nginx.nix
../modules/murmur.nix
../modules/synapse.nix
../modules/nextcloud.nix
../modules/custom-backup-job.nix
2021-12-27 05:28:51 +01:00
../modules/custom-monit.nix
2021-12-07 08:34:21 +01:00
../modules/dokuwiki.nix
2021-12-07 14:57:13 +01:00
../modules/website-marie.nix
2021-12-27 16:39:22 +01:00
../modules/roundcube.nix
2022-09-15 21:42:58 +02:00
../modules/monitoring-exporters.nix
2021-11-25 00:59:46 +01:00
];
2021-11-29 02:04:29 +01:00
sops.secrets = {
borgSshKey = {
owner = config.services.borgbackup.jobs.data.user;
key = "borg/client_keys/backend1/private";
};
};
2021-11-25 00:59:46 +01:00
services.custom-backup-job = {
additionalPaths = [ "/var/lib/nextcloud/config" ];
2021-12-27 05:28:51 +01:00
readWritePaths = [ "/nix/var/data/murmur" "/nix/var/data/backup/" ];
preHook = ''
cp /var/lib/murmur/murmur.sqlite /nix/var/data/murmur/murmur.sqlite
'';
postHook = ''
touch /nix/var/data/backup/backup-ok
'';
2021-11-25 00:59:46 +01:00
startAt = "03:30";
2021-12-27 04:03:07 +01:00
sshKey = config.sops.secrets.borgSshKey.path;
2021-11-25 00:59:46 +01:00
};
2021-12-27 05:28:51 +01:00
services.custom-monit.additionalConfig = ''
check file nextcloud-data-mounted with path /var/lib/nextcloud/data/index.html
start = "${pkgs.systemd}/bin/systemctl start nextcloud-data-sshfs.service"
check host jellyfin with address jellyfin.banditlair.com
if failed port 443 protocol https with timeout 20 seconds then alert
check host stb with address www.societe-de-tir-bertrix.com
if failed port 443 protocol https with timeout 20 seconds then alert
check host transmission with address transmission.banditlair.com
if failed
port 443
protocol https
status = 401
with timeout 20 seconds
then alert
'';
2021-12-07 08:34:21 +01:00
networking.interfaces.enp1s0 = {
useDHCP = true;
ipv4 = {
addresses = [
{
address = "95.216.177.3";
prefixLength = 32;
}
];
};
};
2021-11-25 00:59:46 +01:00
networking.firewall.allowedTCPPorts = [ 80 443 64738 ];
networking.firewall.allowedUDPPorts = [ 64738 ];
2022-09-15 21:42:58 +02:00
networking.firewall.interfaces."enp7s0".allowedTCPPorts = [ config.services.prometheus.exporters.node.port ];
2021-11-25 00:59:46 +01:00
}