diff --git a/hosts/sombrero/configuration.nix b/hosts/sombrero/configuration.nix index f6d6165..741263a 100644 --- a/hosts/sombrero/configuration.nix +++ b/hosts/sombrero/configuration.nix @@ -72,33 +72,6 @@ }; }; - services = { - restic.backups = { - "sync" = { - initialize = true; - - user = "alex"; - - passwordFile = "/home/alex/backup/restic/password.file"; - environmentFile = "/home/alex/backup/restic/aws.env"; - repository = "s3:https://s3.eu-north-1.amazonaws.com/restic-sync-backup"; - - paths = ["/home/alex/backup/sync"]; - - timerConfig = { - OnCalendar = "daily"; - Persistent = true; - }; - - pruneOpts = [ - "--keep-daily 2" - "--keep-weekly 7" - "--keep-yearly 12" - ]; - }; - }; - }; - users = { mutableUsers = false; @@ -124,7 +97,6 @@ git tig unar - restic ]; config-manager = { @@ -140,6 +112,7 @@ plex.enable = true; calibre-web.enable = true; transmission.enable = true; + restic.enable = true; }; # Copy the NixOS configuration file and link it from the resulting system diff --git a/hosts/sombrero/modules/restic/default.nix b/hosts/sombrero/modules/restic/default.nix new file mode 100644 index 0000000..752992d --- /dev/null +++ b/hosts/sombrero/modules/restic/default.nix @@ -0,0 +1,43 @@ +{ pkgs, lib, config, ... }: +let + enabled = config.mod.restic.enable; +in +{ + options = { + mod.restic = { + enable = lib.mkEnableOption "enable restic module"; + }; + }; + + config = lib.mkIf enabled { + services = { + restic.backups = { + "sync" = { + initialize = true; + + user = "alex"; + + passwordFile = "/home/alex/backup/restic/password.file"; + environmentFile = "/home/alex/backup/restic/aws.env"; + repository = "s3:https://s3.eu-north-1.amazonaws.com/restic-sync-backup"; + + paths = ["/home/alex/backup/sync"]; + + timerConfig = { + OnCalendar = "daily"; + Persistent = true; + }; + + pruneOpts = [ + "--keep-daily 2" + "--keep-weekly 7" + "--keep-yearly 12" + ]; + }; + }; + }; + + environment.systemPackages = [ pkgs.restic ]; + }; +} +