From 99e9c130c096588653b802e8793a45f1645add5d Mon Sep 17 00:00:00 2001 From: kiskaadee Date: Sun, 15 Nov 2026 22:22:54 -0500 Subject: [PATCH] fix(nixos): resolve writePython3Bin flake8 E501 build failure in dynu-ip-monitor - Add flakeIgnore = [ "E501" ] to pkgs.writers.writePython3Bin in nixos/modules/dynu.nix - Wrap lines >79 characters in nixos/scripts/monitor.py to satisfy Nix writer flake8 checks during toplevel system derivation builds --- nixos/modules/dynu.nix | 4 +++- nixos/scripts/monitor.py | 16 ++++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/nixos/modules/dynu.nix b/nixos/modules/dynu.nix index 998884e..26c7002 100644 --- a/nixos/modules/dynu.nix +++ b/nixos/modules/dynu.nix @@ -7,7 +7,9 @@ let # Declaratively read the external Python script into the Nix store at evaluation time - ipMonitorScript = pkgs.writers.writePython3Bin "dynu-ip-monitor" { } (builtins.readFile ../scripts/monitor.py); + ipMonitorScript = pkgs.writers.writePython3Bin "dynu-ip-monitor" { + flakeIgnore = [ "E501" ]; + } (builtins.readFile ../scripts/monitor.py); in { # Define the keys to decrypt diff --git a/nixos/scripts/monitor.py b/nixos/scripts/monitor.py index f368c3e..f821a3f 100644 --- a/nixos/scripts/monitor.py +++ b/nixos/scripts/monitor.py @@ -78,7 +78,8 @@ def get_public_ip(): for provider in PROVIDERS: try: req = urllib.request.Request( - provider, headers={"User-Agent": "Mozilla/5.0 (NixOS WAN Monitor)"} + provider, + headers={"User-Agent": "Mozilla/5.0 (NixOS WAN Monitor)"}, ) # Fetch with 5s timeout to avoid hanging the systemd service with urllib.request.urlopen(req, timeout=5) as response: @@ -91,7 +92,8 @@ def get_public_ip(): errors.append(f"{provider}: {e!s}") print( - f"Error: All IP discovery providers failed. Details: {errors}", file=sys.stderr + f"Error: All IP discovery providers failed. Details: {errors}", + file=sys.stderr, ) return None @@ -128,7 +130,11 @@ def record_ip(ip, status, details=None): Appends a new event entry into the JSONLines history registry. """ os.makedirs(os.path.dirname(HISTORY_FILE), exist_ok=True) - entry = {"timestamp": datetime.now(tz=UTC).isoformat(), "ip": ip, "status": status} + entry = { + "timestamp": datetime.now(tz=UTC).isoformat(), + "ip": ip, + "status": status, + } if details: entry["details"] = details try: @@ -156,7 +162,9 @@ def trigger_ddclient(): if res.returncode == 0: return True, None else: - err_msg = f"systemctl exited with {res.returncode}: {res.stderr.strip()}" + err_msg = ( + f"systemctl exited with {res.returncode}: {res.stderr.strip()}" + ) return False, err_msg except (OSError, subprocess.SubprocessError) as e: return False, str(e)