about summary refs log tree commit diff
path: root/nixos/modules/services
diff options
context:
space:
mode:
authorTimothy DeHerrera <tim@nrdxp.dev>2023-09-06 16:23:31 -0600
committerYt <happysalada@tuta.io>2023-09-09 12:20:14 +0000
commit69bfaafc9d41bb4e36920c0d96ceb489c21fd129 (patch)
tree091d2dc053b86b29bf7a2212f9c41ed95564d38c /nixos/modules/services
parent06e95daf89e764a2c3980749c2cce996d703e737 (diff)
downloadnixlib-69bfaafc9d41bb4e36920c0d96ceb489c21fd129.tar
nixlib-69bfaafc9d41bb4e36920c0d96ceb489c21fd129.tar.gz
nixlib-69bfaafc9d41bb4e36920c0d96ceb489c21fd129.tar.bz2
nixlib-69bfaafc9d41bb4e36920c0d96ceb489c21fd129.tar.lz
nixlib-69bfaafc9d41bb4e36920c0d96ceb489c21fd129.tar.xz
nixlib-69bfaafc9d41bb4e36920c0d96ceb489c21fd129.tar.zst
nixlib-69bfaafc9d41bb4e36920c0d96ceb489c21fd129.zip
nixos/cfdyndns: add option to use CF token
Diffstat (limited to 'nixos/modules/services')
-rw-r--r--nixos/modules/services/misc/cfdyndns.nix14
1 files changed, 13 insertions, 1 deletions
diff --git a/nixos/modules/services/misc/cfdyndns.nix b/nixos/modules/services/misc/cfdyndns.nix
index 9cd8b188ffae..5a02de2aad21 100644
--- a/nixos/modules/services/misc/cfdyndns.nix
+++ b/nixos/modules/services/misc/cfdyndns.nix
@@ -23,6 +23,15 @@ in
         '';
       };
 
+      apiTokenFile = mkOption {
+        default = null;
+        type = types.nullOr types.str;
+        description = lib.mdDoc ''
+          The path to a file containing the API Token
+          used to authenticate with CloudFlare.
+        '';
+      };
+
       apikeyFile = mkOption {
         default = null;
         type = types.nullOr types.str;
@@ -55,12 +64,15 @@ in
         Group = config.ids.gids.cfdyndns;
       };
       environment = {
-        CLOUDFLARE_EMAIL="${cfg.email}";
         CLOUDFLARE_RECORDS="${concatStringsSep "," cfg.records}";
       };
       script = ''
         ${optionalString (cfg.apikeyFile != null) ''
           export CLOUDFLARE_APIKEY="$(cat ${escapeShellArg cfg.apikeyFile})"
+          export CLOUDFLARE_EMAIL="${cfg.email}"
+        ''}
+        ${optionalString (cfg.apiTokenFile != null) ''
+          export CLOUDFLARE_APITOKEN="$(cat ${escapeShellArg cfg.apiTokenFile})"
         ''}
         ${pkgs.cfdyndns}/bin/cfdyndns
       '';