From a6da21fb9d7ddcb758b281b18df90c49a916c8fa Mon Sep 17 00:00:00 2001 From: triethyl Date: Mon, 16 Mar 2026 22:01:50 -0400 Subject: homelab: added restic for backups --- nixos/modules/homelab/core/default.nix | 1 + nixos/modules/homelab/core/restic.nix | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 nixos/modules/homelab/core/restic.nix (limited to 'nixos/modules/homelab/core') diff --git a/nixos/modules/homelab/core/default.nix b/nixos/modules/homelab/core/default.nix index 7adc169..0264ce7 100644 --- a/nixos/modules/homelab/core/default.nix +++ b/nixos/modules/homelab/core/default.nix @@ -2,5 +2,6 @@ imports = [ ./ssh.nix ./caddy.nix + ./restic.nix ]; } diff --git a/nixos/modules/homelab/core/restic.nix b/nixos/modules/homelab/core/restic.nix new file mode 100644 index 0000000..7315632 --- /dev/null +++ b/nixos/modules/homelab/core/restic.nix @@ -0,0 +1,31 @@ +{ config, lib, pkgs, ... }: let + cfg = config.homelab.core.restic; +in { + options.homelab.core.restic = { + enable = lib.mkEnableOption "restic"; + passwordFile = lib.mkOption { + description = "restic password file"; + type = lib.types.path; + }; + }; + config = lib.mkIf cfg.enable { + environment.systemPackages = [ pkgs.restic ]; + services.restic.backups = let + defaultPruneOpts = [ + "--keep-daily 7" + "--keep-weekly 4" + "--keep-monthly 6" + ]; + in { + syncthing = { + initialize = true; + paths = [ + "/home/server/Sync" + ]; + repository = "/srv/backups/syncthing"; + pruneOpts = defaultPruneOpts; + passwordFile = cfg.passwordFile; + }; + }; + }; +} -- cgit v1.2.3