diff --git a/nixos/modules/services/misc/duckdns.nix b/nixos/modules/services/misc/duckdns.nix index ff3d411569663..a83a954197a6d 100644 --- a/nixos/modules/services/misc/duckdns.nix +++ b/nixos/modules/services/misc/duckdns.nix @@ -1,6 +1,11 @@ -{ config, pkgs, lib, ... }: +{ + config, + pkgs, + lib, + ... +}: let -cfg = config.services.duckdns; + cfg = config.services.duckdns; in { options.services.duckdns = { @@ -12,7 +17,7 @@ in description = '' The path to a file containing the token used to authenticate with DuckDNS. - ''; + ''; }; domains = lib.mkOption { @@ -22,7 +27,7 @@ in description = '' The record(s) to update in DuckDNS (without the .duckdns.org prefix) - ''; + ''; }; domainsFile = lib.mkOption { @@ -32,17 +37,17 @@ in The path to a file containing a newline-separated list of DuckDNS domain(s) to be updated - ''; + ''; }; }; config = lib.mkIf cfg.enable { assertions = [ - { - assertion = (cfg.domains != null || cfg.domainsFile != null); - message = "services.duckdns.domains or services.duckdns.domainsFile has to be defined"; - } + { + assertion = (cfg.domains != null || cfg.domainsFile != null); + message = "services.duckdns.domains or services.duckdns.domainsFile has to be defined"; + } ]; systemd.services.duckdns = { description = "DuckDNS Dynamic DNS Client"; @@ -62,15 +67,17 @@ in DynamicUser = true; }; script = '' - export DUCKDNS_TOKEN=$(systemd-creds cat DUCKDNS_TOKEN_FILE) - ${lib.optionalString (cfg.domains != null) '' - export DUCKDNS_DOMAINS='${lib.strings.concatStringsSep "," cfg.domains}' - ''} - ${lib.optionalString (cfg.domainsFile != null) '' - export DUCKDNS_DOMAINS=$(systemd-creds cat DUCKDNS_DOMAINS_FILE | sed -z 's/\n/,/g') - ''} - curl --no-progress-meter -k "https://www.duckdns.org/update?domains=$DUCKDNS_DOMAINS&token=$DUCKDNS_TOKEN&ip=" | grep -v "KO" - ''; + export DUCKDNS_TOKEN=$(systemd-creds cat DUCKDNS_TOKEN_FILE) + ${ + lib.optionalString (cfg.domains != null) '' + export DUCKDNS_DOMAINS='${lib.strings.concatStringsSep "," cfg.domains}' + '' + } + ${lib.optionalString (cfg.domainsFile != null) '' + export DUCKDNS_DOMAINS=$(systemd-creds cat DUCKDNS_DOMAINS_FILE | sed -z 's/\n/,/g') + ''} + curl --no-progress-meter -k "https://www.duckdns.org/update?domains=$DUCKDNS_DOMAINS&token=$DUCKDNS_TOKEN&ip=" | grep -v "KO" + ''; }; };