From cdae0fb511851bf703a6fce3db2062b02b0e4c05 Mon Sep 17 00:00:00 2001 From: Max Audron Date: Wed, 7 Jan 2026 13:14:18 +0100 Subject: add kopia module --- modules/backup/default.nix | 50 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 modules/backup/default.nix (limited to 'modules/backup/default.nix') diff --git a/modules/backup/default.nix b/modules/backup/default.nix new file mode 100644 index 0000000..ed319f2 --- /dev/null +++ b/modules/backup/default.nix @@ -0,0 +1,50 @@ +{ + lib, + pkgs, + ... +}: +let + instanceType = lib.types.submodule { + options = { + enable = lib.mkEnableOption "Enable Kopia instance"; + user = lib.mkOption { + type = lib.types.str; + default = "root"; + description = "User under which the Kopia instance runs."; + }; + environmentFile = lib.mkOption { + type = lib.types.nullOr lib.types.path; + default = null; + description = "File containing environment variables for kopia like password."; + }; + }; + }; + mkInstanceServices = + instances: + serviceCreator: + lib.pipe instances [ + (lib.attrsets.mapAttrs' serviceCreator) + (lib.recursiveUpdate { }) + ]; +in +{ + imports = [ + { + _module.args.mkInstanceServices = mkInstanceServices; + imports = [ + ./repositories.nix + ./snapshot.nix + ./policy.nix + ./web.nix + ]; + } + ]; + + options.services.kopia = { + enable = lib.mkEnableOption "Enable Kopia backup"; + instances = lib.mkOption { + type = lib.types.attrsOf instanceType; + default = { }; + }; + }; +} -- cgit v1.2.3