mirror of
https://github.com/foo-dogsquared/nixos-config.git
synced 2025-01-31 22:57:55 +00:00
f107560769
Based from the original but only the service fully baked in with Nix instead of importing the sample service and timer unit file into systemd.
43 lines
1.2 KiB
Nix
43 lines
1.2 KiB
Nix
# This is my external hard drive.
|
|
{ config, options, lib, pkgs, ... }:
|
|
|
|
# TODO: Make this a generic service.
|
|
# There are multiple external storage drives now.
|
|
let cfg = config.modules.hardware-setup.backup-archive;
|
|
in {
|
|
options.modules.hardware-setup.backup-archive.enable = lib.mkEnableOption
|
|
"external hard drive and automated backup service with BorgBackup";
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
assertions = [{
|
|
assertion = config.modules.agenix.enable;
|
|
message = "Agenix module is not enabled.";
|
|
}];
|
|
|
|
age.secrets.external-backup-borgmatic-settings.file =
|
|
lib.getSecret "archive/borgmatic.json";
|
|
|
|
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"
|
|
];
|
|
};
|
|
|
|
modules.services.borgmatic.jobs.external-storage = {
|
|
startAt = "04/6:00:00";
|
|
configPath = config.age.secrets.external-backup-borgmatic-settings.path;
|
|
};
|
|
};
|
|
}
|