2022-01-18 22:38:28 +01:00
|
|
|
{ pkgs, config, ... }:
|
|
|
|
|
let
|
2022-01-18 23:28:53 +01:00
|
|
|
inherit (import <niveum/lib>) restic;
|
2022-01-18 22:38:28 +01:00
|
|
|
in
|
2022-01-18 21:29:30 +01:00
|
|
|
{
|
|
|
|
|
services.restic.backups.niveum = {
|
|
|
|
|
initialize = true;
|
2022-01-18 23:28:53 +01:00
|
|
|
inherit (restic) repository;
|
2022-01-19 22:01:26 +01:00
|
|
|
timerConfig = { OnCalendar = "8:00"; RandomizedDelaySec = "1h"; };
|
2022-01-18 21:29:30 +01:00
|
|
|
passwordFile = toString <secrets/restic/password>;
|
2022-01-18 23:36:38 +01:00
|
|
|
extraBackupArgs = [
|
2022-01-19 00:48:15 +01:00
|
|
|
"--exclude=/home/kfm/projects/nixpkgs/.git"
|
2022-01-18 23:36:38 +01:00
|
|
|
"--exclude=node_modules"
|
|
|
|
|
];
|
2022-01-18 21:29:30 +01:00
|
|
|
paths = [
|
|
|
|
|
"/home/kfm/work"
|
2022-01-18 23:36:38 +01:00
|
|
|
"/home/kfm/projects"
|
2022-01-19 00:48:15 +01:00
|
|
|
"/home/kfm/cloud"
|
|
|
|
|
"/home/kfm/.gnupg"
|
|
|
|
|
"/home/kfm/.ssh"
|
2022-01-18 21:29:30 +01:00
|
|
|
];
|
|
|
|
|
};
|
2022-01-18 22:38:28 +01:00
|
|
|
|
|
|
|
|
environment.systemPackages = [
|
|
|
|
|
(pkgs.writers.writeDashBin "restic-niveum" ''
|
2022-01-18 23:28:53 +01:00
|
|
|
${pkgs.restic}/bin/restic -r ${restic.repository} -p ${<secrets/restic/password>} "$@"
|
2022-01-18 22:38:28 +01:00
|
|
|
'')
|
2022-01-19 09:38:19 +01:00
|
|
|
(pkgs.writers.writeDashBin "restic-mount" ''
|
|
|
|
|
mountdir=$(mktemp -d)
|
|
|
|
|
trap clean EXIT
|
|
|
|
|
clean() {
|
|
|
|
|
rm "$mountdir"
|
|
|
|
|
}
|
|
|
|
|
${pkgs.restic}/bin/restic -r ${restic.repository} -p ${<secrets/restic/password>} mount "$mountdir"
|
|
|
|
|
'')
|
2022-01-18 22:38:28 +01:00
|
|
|
];
|
2022-01-18 21:29:30 +01:00
|
|
|
}
|