@@ -11,7 +11,7 @@ in
1111 description = ''
1212 Periodic backups to create with Restic.
1313 '';
14− type = types.attrsOf (types.submodule ({ name, ... }: {
14+ type = types.attrsOf (types.submodule ({ config, name, ... }: {
1515 options = {
1616 passwordFile = mkOption {
1717 type = types.str;
@@ -21,6 +21,17 @@ in
2121 example = "/etc/nixos/restic-password";
2222 };
2323
24+ environmentFile = mkOption {
25+ type = with types; nullOr str;
26+ # added on 2021-08-28, s3CredentialsFile should
27+ # be removed in the future (+ remember the warning)
28+ default = config.s3CredentialsFile;
29+ description = ''
30+ file containing the credentials to access the repository, in the
31+ format of an EnvironmentFile as described by systemd.exec(5)
32+ '';
33+ };
34+
2435 s3CredentialsFile = mkOption {
2536 type = with types; nullOr str;
2637 default = null;
@@ -212,6 +223,7 @@ in
212223 };
213224
214225 config = {
226+ 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);
215227 systemd.services =
216228 mapAttrs' (name: backup:
217229 let
@@ -251,8 +263,8 @@ in
251263 RuntimeDirectory = "restic-backups-${name}";
252264 CacheDirectory = "restic-backups-${name}";
253265 CacheDirectoryMode = "0700";
254− } // optionalAttrs (backup.s3CredentialsFile != null) {
255− EnvironmentFile = backup.s3CredentialsFile;
266+ } // optionalAttrs (backup.environmentFile != null) {
267+ EnvironmentFile = backup.environmentFile;
256268 };
257269 } // optionalAttrs (backup.initialize || backup.dynamicFilesFrom != null) {
258270 preStart = ''