Commit 4aad2537e76e

Vincent Demeester <vincent@sbr.pm>
2025-12-01 10:12:57
fix: Read zone file contents in DNS scripts
- Fix empty DNS record display by reading files during Nix eval - Enable Gandi DNS updates to find and process A records - Apply consistent fix to both show-dns and update-gandi scripts Signed-off-by: Vincent Demeester <vincent@sbr.pm>
1 parent 27a501a
Changed files (2)
tools/show-dns.sh
@@ -181,7 +181,7 @@ failed_zones=0
 
 for zone_name in "${ZONES[@]}"; do
     # Get the zone file content directly
-    zone_content=$(nix eval --raw ".#nixosConfigurations.${HOST}.config.services.bind.zones.\"${zone_name}\".file" 2>&1 | grep -v "^warning:" | grep -v "^Using saved setting" || true)
+    zone_content=$(nix eval --raw ".#nixosConfigurations.${HOST}.config.services.bind.zones.\"${zone_name}\".file" --apply 'path: builtins.readFile path' 2>&1 | grep -v "^warning:" | grep -v "^Using saved setting" | grep -v "^building " || true)
 
     if [[ -n "$zone_content" ]] && [[ "$zone_content" != *"error"* ]]; then
         total_zones=$((total_zones + 1))
tools/update-gandi-dns.sh
@@ -44,8 +44,8 @@ echo
 
 # Get the DNS zone file content from Nix
 echo -e "${CYAN}Extracting DNS records from Nix configuration...${RESET}"
-ZONE_FILE=$(nix eval --raw '.#nixosConfigurations.demeter.config.services.bind.zones."sbr.pm".file' 2>&1 | \
-           grep -v "^warning:" | grep -v "^Using saved setting")
+ZONE_FILE=$(nix eval --raw '.#nixosConfigurations.demeter.config.services.bind.zones."sbr.pm".file' --apply 'path: builtins.readFile path' 2>&1 | \
+           grep -v "^warning:" | grep -v "^Using saved setting" | grep -v "^building ")
 
 if [[ -z "$ZONE_FILE" ]]; then
     echo -e "${RED}Error: Could not generate zone file${RESET}"