2021-12-11 05:31:28 +00:00
|
|
|
# This is my external hard drive.
|
|
|
|
{ config, options, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
# TODO: Make this a generic service.
|
|
|
|
# There are multiple external storage drives now.
|
2022-01-09 05:38:59 +00:00
|
|
|
let cfg = config.hardware-setup.backup-archive;
|
2021-12-11 05:31:28 +00:00
|
|
|
in {
|
2022-01-09 05:38:59 +00:00
|
|
|
options.hardware-setup.backup-archive.enable = lib.mkEnableOption
|
2021-12-26 08:02:57 +00:00
|
|
|
"external hard drive and automated backup service with BorgBackup";
|
2021-12-11 05:31:28 +00:00
|
|
|
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
|
|
assertions = [{
|
2022-01-09 05:38:59 +00:00
|
|
|
assertion = config.profiles.agenix.enable;
|
2021-12-11 05:31:28 +00:00
|
|
|
message = "Agenix module is not enabled.";
|
|
|
|
}];
|
|
|
|
|
2021-12-26 08:02:57 +00:00
|
|
|
age.secrets.external-backup-borgmatic-settings.file =
|
|
|
|
lib.getSecret "archive/borgmatic.json";
|
2022-01-01 12:17:20 +00:00
|
|
|
|
2021-12-11 05:31:28 +00:00
|
|
|
fileSystems."/mnt/external-storage" = {
|
|
|
|
device = "/dev/disk/by-uuid/665A391C5A38EB07";
|
|
|
|
fsType = "ntfs";
|
|
|
|
noCheck = true;
|
|
|
|
options = [
|
|
|
|
"nofail"
|
|
|
|
"noauto"
|
|
|
|
"user"
|
|
|
|
|
|
|
|
# See systemd.mount.5 and systemd.automount.5 manual page for more
|
|
|
|
# details.
|
|
|
|
"x-systemd.automount"
|
|
|
|
"x-systemd.device-timeout=2"
|
|
|
|
"x-systemd.idle-timeout=2"
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
2022-01-09 05:38:59 +00:00
|
|
|
# This uses the custom borgmatic NixOS service.
|
|
|
|
services.borgmatic.jobs.external-storage = {
|
2022-01-01 12:17:20 +00:00
|
|
|
startAt = "04/6:00:00";
|
|
|
|
configPath = config.age.secrets.external-backup-borgmatic-settings.path;
|
2021-12-11 05:31:28 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|