From 7161a83931630356b4740fcf313dcfd5ce84c842 Mon Sep 17 00:00:00 2001 From: Jeremy Fleischman Date: Thu, 24 Apr 2025 18:20:58 -0700 Subject: [PATCH] services(cloudflare-dyndns): use new `CLOUDFLARE_API_TOKEN_FILE` setting We recently upgraded to cloudflare-dyndns 5.3: https://github.com/NixOS/nixpkgs/commit/24f9910708d0d38c0e0cd9cc863bde4149b48fb6, so we can now use this new `CLOUDFLARE_API_TOKEN_FILE` feature that landed in v5.2: https://github.com/kissgyorgy/cloudflare-dyndns/commit/1d563d27529e5c5373d1b747536ea09fa8366d88 --- nixos/modules/services/networking/cloudflare-dyndns.nix | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/nixos/modules/services/networking/cloudflare-dyndns.nix b/nixos/modules/services/networking/cloudflare-dyndns.nix index f99935210b06..c8597d28c209 100644 --- a/nixos/modules/services/networking/cloudflare-dyndns.nix +++ b/nixos/modules/services/networking/cloudflare-dyndns.nix @@ -108,13 +108,14 @@ in ++ lib.optional cfg.proxied "--proxied"; in '' - export CLOUDFLARE_API_TOKEN=$(< "''${CREDENTIALS_DIRECTORY}/apiToken") + export CLOUDFLARE_API_TOKEN_FILE=''${CREDENTIALS_DIRECTORY}/apiToken # Added 2025-03-10: `cfg.apiTokenFile` used to be passed as an # `EnvironmentFile` to the service, which required it to be of # the form "CLOUDFLARE_API_TOKEN=" rather than just the secret. # If we detect this legacy usage, error out. - if [[ $CLOUDFLARE_API_TOKEN == CLOUDFLARE_API_TOKEN* ]]; then + token=$(< "''${CLOUDFLARE_API_TOKEN_FILE}") + if [[ $token == CLOUDFLARE_API_TOKEN* ]]; then echo "Error: your api token starts with 'CLOUDFLARE_API_TOKEN='. Remove that, and instead specify just the token." >&2 exit 1 fi