From 75d64a336b34567021c88e641ff791649cc07681 Mon Sep 17 00:00:00 2001 From: eyjhb Date: Sat, 28 Aug 2021 15:17:52 +0200 Subject: nixos/restic: rename s3CredentialsFile to environmentFile This is done as the s3CredentialsFile specifies the environmentFile for the systemd service, which can be used for more than just s3. Co-authored-by: Cole Helbling --- nixos/modules/services/backup/restic.nix | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/nixos/modules/services/backup/restic.nix b/nixos/modules/services/backup/restic.nix index ac57f271526..67fef55614b 100644 --- a/nixos/modules/services/backup/restic.nix +++ b/nixos/modules/services/backup/restic.nix @@ -11,7 +11,7 @@ in description = '' Periodic backups to create with Restic. ''; - type = types.attrsOf (types.submodule ({ name, ... }: { + type = types.attrsOf (types.submodule ({ config, name, ... }: { options = { passwordFile = mkOption { type = types.str; @@ -21,6 +21,17 @@ in example = "/etc/nixos/restic-password"; }; + environmentFile = mkOption { + type = with types; nullOr str; + # added on 2021-08-28, s3CredentialsFile should + # be removed in the future (+ remember the warning) + default = config.s3CredentialsFile; + description = '' + file containing the credentials to access the repository, in the + format of an EnvironmentFile as described by systemd.exec(5) + ''; + }; + s3CredentialsFile = mkOption { type = with types; nullOr str; default = null; @@ -212,6 +223,7 @@ in }; config = { + warnings = mapAttrsToList (n: v: "services.restic.backups.${n}.s3CredentialsFile is deprecated, please use services.restic.backups.${n}.environmentFile instead.") (filterAttrs (n: v: v.s3CredentialsFile != null) config.services.restic.backups); systemd.services = mapAttrs' (name: backup: let @@ -251,8 +263,8 @@ in RuntimeDirectory = "restic-backups-${name}"; CacheDirectory = "restic-backups-${name}"; CacheDirectoryMode = "0700"; - } // optionalAttrs (backup.s3CredentialsFile != null) { - EnvironmentFile = backup.s3CredentialsFile; + } // optionalAttrs (backup.environmentFile != null) { + EnvironmentFile = backup.environmentFile; }; } // optionalAttrs (backup.initialize || backup.dynamicFilesFrom != null) { preStart = '' -- cgit 1.4.1