nixos/services.cloudflare-dyndns: remove with lib;
This commit is contained in:
committed by
Jörg Thalheim
parent
a3c69c111e
commit
14f2d0a94b
@@ -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;
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user