diff --git a/nixos/modules/services/networking/cloudflare-dyndns.nix b/nixos/modules/services/networking/cloudflare-dyndns.nix index 9495c8dcaf81..0f035362742e 100644 --- a/nixos/modules/services/networking/cloudflare-dyndns.nix +++ b/nixos/modules/services/networking/cloudflare-dyndns.nix @@ -1,19 +1,16 @@ { config, pkgs, lib, ... }: - -with lib; - let cfg = config.services.cloudflare-dyndns; in { options = { services.cloudflare-dyndns = { - enable = mkEnableOption "Cloudflare Dynamic DNS Client"; + enable = lib.mkEnableOption "Cloudflare Dynamic DNS Client"; - package = mkPackageOption pkgs "cloudflare-dyndns" { }; + package = lib.mkPackageOption pkgs "cloudflare-dyndns" { }; - apiTokenFile = mkOption { - type = types.nullOr types.str; + apiTokenFile = lib.mkOption { + type = lib.types.nullOr lib.types.str; default = null; description = '' The path to a file containing the CloudFlare API token. @@ -22,16 +19,16 @@ in ''; }; - domains = mkOption { - type = types.listOf types.str; + domains = lib.mkOption { + type = lib.types.listOf lib.types.str; default = [ ]; description = '' List of domain names to update records for. ''; }; - frequency = mkOption { - type = types.nullOr types.str; + frequency = lib.mkOption { + type = lib.types.nullOr lib.types.str; default = "*:0/5"; description = '' Run cloudflare-dyndns with the given frequency (see @@ -40,32 +37,32 @@ in ''; }; - proxied = mkOption { - type = types.bool; + proxied = lib.mkOption { + type = lib.types.bool; default = false; description = '' Whether this is a DNS-only record, or also being proxied through CloudFlare. ''; }; - ipv4 = mkOption { - type = types.bool; + ipv4 = lib.mkOption { + type = lib.types.bool; default = true; description = '' Whether to enable setting IPv4 A records. ''; }; - ipv6 = mkOption { - type = types.bool; + ipv6 = lib.mkOption { + type = lib.types.bool; default = false; description = '' Whether to enable setting IPv6 AAAA records. ''; }; - deleteMissing = mkOption { - type = types.bool; + deleteMissing = lib.mkOption { + type = lib.types.bool; default = false; description = '' Whether to delete the record when no IP address is found. @@ -74,7 +71,7 @@ in }; }; - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { systemd.services.cloudflare-dyndns = { description = "CloudFlare Dynamic DNS Client"; after = [ "network.target" ]; @@ -94,12 +91,12 @@ in args = [ "--cache-file /var/lib/cloudflare-dyndns/ip.cache" ] ++ (if cfg.ipv4 then [ "-4" ] else [ "-no-4" ]) ++ (if cfg.ipv6 then [ "-6" ] else [ "-no-6" ]) - ++ optional cfg.deleteMissing "--delete-missing" - ++ optional cfg.proxied "--proxied"; + ++ lib.optional cfg.deleteMissing "--delete-missing" + ++ lib.optional cfg.proxied "--proxied"; in - "${getExe cfg.package} ${toString args}"; + "${lib.getExe cfg.package} ${toString args}"; }; - } // optionalAttrs (cfg.frequency != null) { + } // lib.optionalAttrs (cfg.frequency != null) { startAt = cfg.frequency; }; };