Parameterise restic

This commit is contained in:
Simon Bruder 2020-12-05 14:19:34 +01:00
parent 6d0f3a9964
commit 8a63f8aac4
No known key found for this signature in database
GPG key ID: 6F03E0000CC5B62F
4 changed files with 51 additions and 28 deletions

View file

@ -6,7 +6,6 @@
./hardware-configuration.nix
../../modules/cpu/intel.nix
../../modules/gpu/intel.nix
../../modules/restic.nix
../../modules/ssd.nix
../../modules/libvirt.nix
../../modules
@ -16,6 +15,7 @@
sbruder = {
gui = true;
restic.enable = true;
};
boot.loader.grub.device = "/dev/disk/by-id/ata-INTEL_SSDSC2KB480G7_PHYS749202D6480BGN";

View file

@ -7,7 +7,6 @@
../../modules/cpu/intel.nix
../../modules/gpu/amd.nix
../../modules/libvirt.nix
../../modules/restic.nix
../../modules/ssd.nix
../../modules
../../profiles/dev.nix
@ -16,6 +15,7 @@
sbruder = {
gui = true;
restic.enable = true;
};
boot.loader.grub.device = "/dev/disk/by-id/ata-MTFDDAK256TBN-1AR15ABHA_UFZMQ01ZR50NMM";

View file

@ -21,6 +21,7 @@
./office.nix
./prometheus/node_exporter.nix
./pulseaudio.nix
./restic.nix
./ssh.nix
./sway.nix
./tools.nix

View file

@ -1,5 +1,7 @@
{ pkgs, config, lib, ... }:
{ pkgs, config, lib, options, ... }:
let
cfg = config.sbruder.restic;
name = "${config.networking.hostName}-system";
excludes = [
# General
@ -44,6 +46,28 @@ let
maybePath = path: (lib.optional (builtins.pathExists path) (toString path));
in
{
options.sbruder.restic = {
enable = lib.mkEnableOption "restic";
timerConfig =
lib.recursiveUpdate
(
(builtins.elemAt
(builtins.elemAt
options.services.restic.backups.type.getSubModules
0
).imports
0)
{ name = ""; }
).options.timerConfig
{
default = {
OnCalendar = "20:00";
RandomizedDelaySec = "2h";
};
};
};
config = lib.mkIf cfg.enable {
services.restic.backups."${name}" = {
passwordFile = toString (../secrets/restic_password);
s3CredentialsFile = toString ../secrets/s3_credentials;
@ -61,10 +85,7 @@ in
"--exclude-file=${excludesFile}"
"--verbose"
];
timerConfig = {
OnCalendar = "20:00";
RandomizedDelaySec = "2h";
};
timerConfig = cfg.timerConfig;
};
systemd.services."restic-backups-${name}".serviceConfig = {
@ -72,4 +93,5 @@ in
"IOSchedulingClass" = "best-effort";
"IOSchedulingPriority" = 7;
};
};
}