2019-11-17 14:45:06 +00:00
|
|
|
{ config, pkgs, lib, ... }:
|
2019-05-29 13:20:45 +00:00
|
|
|
with import <stockholm/lib>;
|
2021-10-12 13:35:52 +00:00
|
|
|
let
|
2021-10-31 11:35:16 +00:00
|
|
|
domain = "pad.lassul.us";
|
2023-08-31 09:44:53 +00:00
|
|
|
in
|
|
|
|
{
|
2021-10-31 11:35:16 +00:00
|
|
|
|
|
|
|
# redirect legacy domain to new one
|
|
|
|
services.nginx.virtualHosts."codi.lassul.us" = {
|
|
|
|
enableACME = true;
|
|
|
|
addSSL = true;
|
|
|
|
locations."/".return = "301 https://${domain}\$request_uri";
|
|
|
|
};
|
|
|
|
|
2021-10-12 13:35:52 +00:00
|
|
|
services.nginx.virtualHosts.${domain} = {
|
2019-05-29 13:20:45 +00:00
|
|
|
enableACME = true;
|
2021-10-12 13:35:52 +00:00
|
|
|
forceSSL = true;
|
|
|
|
locations."/" = {
|
|
|
|
proxyPass = "https://localhost:3091";
|
|
|
|
proxyWebsockets = true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
security.acme.certs.${domain}.group = "hedgecert";
|
2023-07-24 17:06:28 +00:00
|
|
|
users.groups.hedgecert.members = [ "hedgedoc" "nginx" ];
|
2021-10-12 13:35:52 +00:00
|
|
|
|
|
|
|
security.dhparams = {
|
|
|
|
enable = true;
|
2023-08-31 09:44:53 +00:00
|
|
|
params.hedgedoc = { };
|
2019-05-29 13:20:45 +00:00
|
|
|
};
|
|
|
|
|
2022-05-28 16:37:55 +00:00
|
|
|
systemd.services.hedgedoc.environment = {
|
|
|
|
CMD_COOKIE_POLICY = "none";
|
|
|
|
CMD_CSP_ALLOW_FRAMING = "true";
|
|
|
|
};
|
2023-08-31 09:44:53 +00:00
|
|
|
|
|
|
|
systemd.services.hedgedoc-backup = {
|
|
|
|
startAt = "daily";
|
|
|
|
serviceConfig = {
|
|
|
|
ExecStart = ''${pkgs.sqlite}/bin/sqlite3 /var/lib/hedgedoc/db.hedgedoc.sqlite ".backup /var/backup/hedgedoc/backup.sq3"'';
|
|
|
|
Type = "oneshot";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
services.postgresqlBackup.enable = true;
|
|
|
|
|
|
|
|
systemd.services.borgbackup-job-hetzner.serviceConfig.ReadWritePaths = [ "/var/log/telegraf" ];
|
|
|
|
|
|
|
|
services.borgbackup.jobs.hetzner = {
|
|
|
|
paths = [
|
|
|
|
"/home"
|
|
|
|
"/etc"
|
|
|
|
"/var"
|
|
|
|
"/root"
|
|
|
|
];
|
|
|
|
exclude = [
|
|
|
|
"*.pyc"
|
|
|
|
"/home/*/.direnv"
|
|
|
|
"/home/*/.cache"
|
|
|
|
"/home/*/.cargo"
|
|
|
|
"/home/*/.npm"
|
|
|
|
"/home/*/.m2"
|
|
|
|
"/home/*/.gradle"
|
|
|
|
"/home/*/.opam"
|
|
|
|
"/home/*/.clangd"
|
|
|
|
"/var/lib/containerd"
|
|
|
|
# already included in database backup
|
|
|
|
"/var/lib/postgresql"
|
|
|
|
# not so important
|
|
|
|
"/var/lib/docker/"
|
|
|
|
"/var/log/journal"
|
|
|
|
"/var/cache"
|
|
|
|
"/var/tmp"
|
|
|
|
"/var/log"
|
|
|
|
];
|
|
|
|
repo = "u348918@u348918.your-storagebox.de:/./hetzner";
|
|
|
|
encryption.mode = "none";
|
|
|
|
compression = "auto,zstd";
|
|
|
|
startAt = "daily";
|
|
|
|
# TODO: change backup key
|
|
|
|
environment.BORG_RSH = "ssh -oPort=23 -i ${config.sops.secrets.hetzner-borgbackup-ssh.path}";
|
|
|
|
preHook = ''
|
|
|
|
set -x
|
|
|
|
'';
|
|
|
|
|
|
|
|
postHook = ''
|
|
|
|
cat > /var/log/telegraf/borgbackup-job-hetzner.service <<EOF
|
|
|
|
task,frequency=daily last_run=$(date +%s)i,state="$([[ $exitStatus == 0 ]] && echo ok || echo fail)"
|
|
|
|
EOF
|
|
|
|
'';
|
|
|
|
|
|
|
|
prune.keep = {
|
|
|
|
within = "1d"; # Keep all archives from the last day
|
|
|
|
daily = 7;
|
|
|
|
weekly = 4;
|
|
|
|
monthly = 0;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2021-01-23 18:36:46 +00:00
|
|
|
services.hedgedoc = {
|
2019-05-29 13:20:45 +00:00
|
|
|
enable = true;
|
2021-10-12 13:35:52 +00:00
|
|
|
configuration.allowOrigin = [ domain ];
|
2023-07-24 17:06:28 +00:00
|
|
|
settings = {
|
2019-05-29 13:20:45 +00:00
|
|
|
db = {
|
|
|
|
dialect = "sqlite";
|
2023-07-24 17:06:28 +00:00
|
|
|
storage = "/var/lib/hedgedoc/db.hedgedoc.sqlite";
|
2019-05-29 13:20:45 +00:00
|
|
|
};
|
2021-10-12 13:35:52 +00:00
|
|
|
useCDN = false;
|
2019-05-29 13:20:45 +00:00
|
|
|
port = 3091;
|
2021-10-12 13:35:52 +00:00
|
|
|
domain = domain;
|
|
|
|
allowFreeURL = true;
|
|
|
|
|
|
|
|
useSSL = true;
|
|
|
|
protocolUseSSL = true;
|
|
|
|
sslCAPath = [ "/etc/ssl/certs/ca-certificates.crt" ];
|
|
|
|
sslCertPath = "/var/lib/acme/${domain}/cert.pem";
|
|
|
|
sslKeyPath = "/var/lib/acme/${domain}/key.pem";
|
|
|
|
dhParamPath = config.security.dhparams.params.hedgedoc.path;
|
2019-05-29 13:20:45 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|