summary refs log tree commit diff
diff options
context:
space:
mode:
authoreyjhb <eyjhbb@gmail.com>2021-08-28 15:17:52 +0200
committerCole Helbling <cole.e.helbling@outlook.com>2021-10-26 14:01:32 -0700
commit75d64a336b34567021c88e641ff791649cc07681 (patch)
treeeb9e331b9f0a2a58a362bd4686851416e6cbd829
parentcdb3a5613ec451150bef08a6757bae6c81784074 (diff)
downloadnixpkgs-75d64a336b34567021c88e641ff791649cc07681.tar
nixpkgs-75d64a336b34567021c88e641ff791649cc07681.tar.gz
nixpkgs-75d64a336b34567021c88e641ff791649cc07681.tar.bz2
nixpkgs-75d64a336b34567021c88e641ff791649cc07681.tar.lz
nixpkgs-75d64a336b34567021c88e641ff791649cc07681.tar.xz
nixpkgs-75d64a336b34567021c88e641ff791649cc07681.tar.zst
nixpkgs-75d64a336b34567021c88e641ff791649cc07681.zip
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 <cole.e.helbling@outlook.com>
-rw-r--r--nixos/modules/services/backup/restic.nix18
1 files 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 = ''