self-hosting/profiles/backend.nix

208 lines
5.3 KiB
Nix
Raw Normal View History

2024-08-26 05:38:10 +02:00
{
config,
lib,
pkgs,
2024-09-20 03:55:11 +02:00
pkgs-unstable,
2024-08-26 05:38:10 +02:00
...
}:
{
imports = [
../environment.nix
../hardware/hcloud.nix
../modules
];
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";
};
2024-09-12 15:14:15 +02:00
dolibarrDbPassword = {
owner = config.users.users.dolibarr.name;
key = "dolibarr/db_password";
restartUnits = [ "phpfpm-dolibarr.service" ];
};
2021-11-29 02:04:29 +01:00
};
custom = {
2024-03-26 23:37:53 +01:00
services.backup-job = {
enable = true;
2023-04-22 02:46:55 +02:00
repoName = "bk1";
2024-08-26 05:38:10 +02:00
additionalPaths = [
"/var/lib/nextcloud/config"
"/var/lib/mastodon"
];
readWritePaths = [
"/nix/var/data/murmur"
"/nix/var/data/backup/"
];
preHook = ''
cp /var/lib/murmur/murmur.sqlite /nix/var/data/murmur/murmur.sqlite
'';
startAt = "03:30";
sshKey = config.sops.secrets.borgSshKey.path;
};
services.monit = {
enable = true;
additionalConfig = ''
check file nextcloud-data-mounted with path /var/lib/nextcloud/data/index.html
start = "${pkgs.systemd}/bin/systemctl start nextcloud-data-sshfs.service"
2021-11-25 00:59:46 +01:00
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
2022-10-30 01:05:16 +02:00
check host osteoview with address osteoview.app
if failed
port 443
protocol https
status = 200
request "/api/_health"
with timeout 5 seconds
2024-08-26 05:38:10 +02:00
content = "Healthy"
then alert
'';
};
2024-03-26 23:37:53 +01:00
services.nginx.enable = true;
services.dokuwiki.enable = true;
services.openssh.enable = true;
services.murmur.enable = true;
2023-12-13 18:51:56 +01:00
services.mastodon.enable = false;
2024-03-26 23:37:53 +01:00
services.synapse.enable = true;
services.nextcloud.enable = true;
services.roundcube.enable = true;
services.monitoring-exporters.enable = true;
};
2021-12-27 05:28:51 +01:00
2022-12-02 06:36:45 +01:00
services.uptime-kuma = {
enable = true;
2024-08-26 05:38:10 +02:00
settings = {
PORT = "3001";
};
2022-12-02 06:36:45 +01:00
};
2024-03-26 23:37:53 +01:00
services.nginx.virtualHosts = {
"osteopathie.froidmont.org" = {
enableACME = true;
forceSSL = true;
root = "/nix/var/data/website-marie";
};
"uptime.froidmont.org" = {
serverAliases = [ "status.${config.networking.domain}" ];
forceSSL = true;
enableACME = true;
2022-12-02 06:36:45 +01:00
2024-03-26 23:37:53 +01:00
locations."/" = {
2024-08-26 05:38:10 +02:00
proxyPass = "http://127.0.0.1:${config.services.uptime-kuma.settings.PORT}";
2024-03-26 23:37:53 +01:00
proxyWebsockets = true;
};
2022-12-02 06:36:45 +01:00
};
2024-03-26 23:37:53 +01:00
"www.fautlfer.com" = {
enableACME = true;
forceSSL = true;
2024-01-30 08:20:48 +01:00
2024-03-26 23:37:53 +01:00
locations."= /".extraConfig = ''
return 302 https://blogz.zaclys.com/faut-l-fer/;
'';
};
2024-01-30 08:20:48 +01:00
2024-03-26 23:37:53 +01:00
"fautlfer.com" = {
enableACME = true;
forceSSL = true;
2024-01-30 08:20:48 +01:00
2024-03-26 23:37:53 +01:00
locations."= /".extraConfig = ''
return 302 https://blogz.zaclys.com/faut-l-fer/;
'';
};
2024-01-30 08:20:48 +01:00
};
2024-09-12 15:14:15 +02:00
services.dolibarr = {
enable = true;
domain = "dolibarr.froidmont.solutions";
stateDir = "/nix/var/data/dolibarr";
database = {
createLocally = false;
host = "10.0.1.11";
port = 5432;
name = "dolibarr";
user = "dolibarr";
passwordFile = config.sops.secrets.dolibarrDbPassword.path;
};
settings = {
dolibarr_main_db_type = lib.mkForce "pgsql";
};
nginx = {
# https://wiki.dolibarr.org/index.php/Module_Web_Services_API_REST_(developer)#Nginx_setup
locations."~ [^/]\\.php(/|$)".extraConfig = ''
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include ${config.services.nginx.package}/conf/fastcgi_params;
# Dolibarr Rest API path support
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_script_name;
'';
};
2024-09-12 15:14:15 +02:00
};
2024-09-20 03:55:11 +02:00
nixpkgs.config.permittedInsecurePackages = [ "qtwebkit-5.212.0-alpha4" ];
services.odoo = {
enable = false;
package = pkgs-unstable.odoo.override {
python310 = pkgs.python310.override {
packageOverrides = final: prev: {
furl = prev.furl.overridePythonAttrs (old: {
doCheck = false;
});
};
};
};
domain = "odoo.froidmont.solutions";
settings = {
options = {
db_host = "10.0.1.11";
db_port = 5432;
db_name = "odoo";
db_user = "odoo";
db_password = "odoo";
data_dir = "/var/lib/private/odoo/data";
};
};
};
services.nginx.virtualHosts = {
${config.services.odoo.domain} = {
forceSSL = true;
enableACME = true;
};
};
services.postgresql.enable = lib.mkForce false;
# systemd.services.odoo = {
# after = lib.mkForce [ "network.target" ];
# requires = lib.mkForce [ ];
# };
2024-08-26 05:38:10 +02:00
networking.firewall.allowedTCPPorts = [
80
443
64738
];
2021-11-25 00:59:46 +01:00
networking.firewall.allowedUDPPorts = [ 64738 ];
2024-08-26 05:38:10 +02:00
networking.firewall.interfaces."eth1".allowedTCPPorts = [
config.services.prometheus.exporters.node.port
9000
];
2021-11-25 00:59:46 +01:00
}