From b950416a42165b06e9e1dfeeecb32e9a8315470b Mon Sep 17 00:00:00 2001 From: Christine Elisabeth Koppel Date: Tue, 3 Mar 2026 12:00:33 +0100 Subject: [PATCH] Make it invoke curl the Nix way. --- nix-system-configs/modules/system/traefik.nix | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/nix-system-configs/modules/system/traefik.nix b/nix-system-configs/modules/system/traefik.nix index 5657ad1..5abc9a4 100644 --- a/nix-system-configs/modules/system/traefik.nix +++ b/nix-system-configs/modules/system/traefik.nix @@ -574,7 +574,6 @@ in { reloadServices = ["traefik.service"]; }; }; - # PRG Cloudflare DDNS updater - split into a single-run upstream script and a wrapper that loops records environment.etc."cloudflare-ddns/update-single.sh" = { text = '' @@ -611,7 +610,7 @@ in { # Try all the ip services for a valid IPv4 address for service in $${IP_SERVICES[@]}; do - RAW_IP=$(curl -s $service) + RAW_IP=$(${pkgs.curl} -s $service) if [[ $RAW_IP =~ $REGEX_IPV4 ]]; then CURRENT_IP=$BASH_REMATCH logger -s "DDNS Updater: Fetched IP $CURRENT_IP" @@ -641,7 +640,7 @@ in { ########################################### logger "DDNS Updater: Check Initiated" - record=$(curl -s -X GET "https://api.cloudflare.com/client/v4/zones/$${zone_identifier}/dns_records?type=A&name=$${record_name}" \ + record=$(${pkgs.curl} -s -X GET "https://api.cloudflare.com/client/v4/zones/$${zone_identifier}/dns_records?type=A&name=$${record_name}" \ -H "X-Auth-Email: $${auth_email}" \ -H "$${auth_header} $${auth_key}" \ -H "Content-Type: application/json") @@ -672,7 +671,7 @@ in { ########################################### ## Change the IP@Cloudflare using the API ########################################### - update=$(curl -s -X PATCH "https://api.cloudflare.com/client/v4/zones/$${zone_identifier}/dns_records/$${record_identifier}" \ + update=$(${pkgs.curl} -s -X PATCH "https://api.cloudflare.com/client/v4/zones/$${zone_identifier}/dns_records/$${record_identifier}" \ -H "X-Auth-Email: $${auth_email}" \ -H "$${auth_header} $${auth_key}" \ -H "Content-Type: application/json" \ @@ -686,21 +685,21 @@ in { echo -e "DDNS Updater: $${CURRENT_IP} $${record_name} DDNS failed for $${record_identifier} ($${CURRENT_IP}). DUMPING RESULTS:\n$update" | logger -s if [[ -n "$${slackuri}" ]]; then msg="$${sitename} DDNS Update Failed: $${record_name}: $${record_identifier} ($${CURRENT_IP})." - curl -L -X POST "$${slackuri}" --data-raw "{\"channel\":\"$${slackchannel}\",\"text\":\"$${msg}\"}" + ${pkgs.curl} -L -X POST "$${slackuri}" --data-raw "{\"channel\":\"$${slackchannel}\",\"text\":\"$${msg}\"}" fi if [[ -n "$${discorduri}" ]]; then msg="$${sitename} DDNS Update Failed: $${record_name}: $${record_identifier} ($${CURRENT_IP})." - curl -i -H "Accept: application/json" -H "Content-Type:application/json" -X POST --data-raw "{\"content\":\"$${msg}\"}" "$${discorduri}" + ${pkgs.curl} -i -H "Accept: application/json" -H "Content-Type:application/json" -X POST --data-raw "{\"content\":\"$${msg}\"}" "$${discorduri}" fi exit 1;; *) msg="$${sitename} Updated: $${record_name}'s new IP Address is $${CURRENT_IP}" logger "DDNS Updater: $${CURRENT_IP} $${record_name} DDNS updated." if [[ -n "$${slackuri}" ]]; then - curl -L -X POST "$${slackuri}" --data-raw "{\"channel\":\"$${slackchannel}\",\"text\":\"$${msg}\"}" + ${pkgs.curl} -L -X POST "$${slackuri}" --data-raw "{\"channel\":\"$${slackchannel}\",\"text\":\"$${msg}\"}" fi if [[ -n "$${discorduri}" ]]; then - curl -i -H "Accept: application/json" -H "Content-Type:application/json" -X POST --data-raw "{\"content\":\"$${msg}\"}" "$${discorduri}" + ${pkgs.curl} -i -H "Accept: application/json" -H "Content-Type:application/json" -X POST --data-raw "{\"content\":\"$${msg}\"}" "$${discorduri}" fi exit 0;; esac