refactor: use flakes with deploy-rs & nixos-hardware

This commit is contained in:
Felix Buehler 2022-06-03 17:47:16 +02:00
parent b1ef65594a
commit d17c2b69a0
81 changed files with 1179 additions and 317 deletions

75
nixos/thinkman/backup.nix Normal file
View file

@ -0,0 +1,75 @@
{ config, lib, pkgs, ... }:
let
cfg = import ./vars-backup.nix;
borgbackupMonitor = { config, pkgs, lib, ... }: with lib; {
key = "borgbackupMonitor";
_file = "borgbackupMonitor";
config.systemd.services = {
"notify-problems@" = {
enable = true;
serviceConfig.User = "felix";
environment.SERVICE = "%i";
script = ''
export $(cat /proc/$(${pkgs.procps}/bin/pgrep -x "sway" -u "$USER")/environ |grep -z '^DBUS_SESSION_BUS_ADDRESS=')
${pkgs.libnotify}/bin/notify-send -u critical "$SERVICE FAILED!" "Run journalctl -u $SERVICE for details"
'';
};
} // flip mapAttrs' config.services.borgbackup.jobs (name: value:
nameValuePair "borgbackup-job-${name}" {
unitConfig.OnFailure = "notify-problems@%i.service";
}
);
};
in
{
# notification
imports = [
borgbackupMonitor
];
services.borgbackup.jobs.hetzner = {
paths = [
"/"
];
exclude = [
"/nix"
"/sys"
"/run"
"/proc"
"/root/.cache/"
"**/.Trash"
"/tmp/*"
"/var/lock/*"
"/var/run/*"
"/var/tmp/*"
"/home/*/tmp"
"/home/*/todo"
"/home/*/.cache"
"/home/*/.gvfs"
"/home/*/.thumbnails"
"/home/*/.local/share/Trash"
"/srv/data/tmp"
"/srv/data/todo"
];
extraCreateArgs = "--exclude-caches --keep-exclude-tags --stats";
encryption = {
mode = "repokey-blake2";
passCommand = "cat /root/.borg_password";
};
environment.BORG_RSH = "ssh -o 'StrictHostKeyChecking=no' -i /root/.ssh/backup_ed25519 -p 23";
repo = "${cfg.borg.user}@${cfg.borg.host}:${cfg.borg.dir}";
compression = "auto,zstd";
doInit = false;
startAt = "daily";
persistentTimer = true;
prune.keep = {
last = 1;
within = "3d";
daily = 7;
weekly = 4;
monthly = 6;
yearly = 2;
};
};
}