Merge pull request #171171 from lovesegfault/cloudflare-ddns

cloudflare-dyndns: init at 4.1
This commit is contained in:
Bernardo Meurer 2022-05-01 17:22:13 -07:00 committed by GitHub
commit 43d7b5760b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 151 additions and 0 deletions

View file

@ -737,6 +737,7 @@
./services/networking/blocky.nix
./services/networking/charybdis.nix
./services/networking/cjdns.nix
./services/networking/cloudflare-dyndns.nix
./services/networking/cntlm.nix
./services/networking/connman.nix
./services/networking/consul.nix

View file

@ -0,0 +1,93 @@
{ config, pkgs, lib, ... }:
with lib;
let
cfg = config.services.cloudflare-dyndns;
in
{
options = {
services.cloudflare-dyndns = {
enable = mkEnableOption "Cloudflare Dynamic DNS Client";
apiTokenFile = mkOption {
type = types.nullOr types.str;
default = null;
description = ''
The path to a file containing the CloudFlare API token.
The file must have the form `CLOUDFLARE_API_TOKEN=...`
'';
};
domains = mkOption {
type = types.listOf types.str;
default = [ ];
description = ''
List of domain names to update records for.
'';
};
proxied = mkOption {
type = types.bool;
default = false;
description = ''
Whether this is a DNS-only record, or also being proxied through CloudFlare.
'';
};
ipv4 = mkOption {
type = types.bool;
default = true;
description = ''
Whether to enable setting IPv4 A records.
'';
};
ipv6 = mkOption {
type = types.bool;
default = false;
description = ''
Whether to enable setting IPv6 AAAA records.
'';
};
deleteMissing = mkOption {
type = types.bool;
default = false;
description = ''
Whether to delete the record when no IP address is found.
'';
};
};
};
config = mkIf cfg.enable {
systemd.services.cloudflare-dyndns = {
description = "CloudFlare Dynamic DNS Client";
after = [ "network.target" ];
wantedBy = [ "multi-user.target" ];
startAt = "*:0/5";
environment = {
CLOUDFLARE_DOMAINS = toString cfg.domains;
};
serviceConfig = {
Type = "simple";
DynamicUser = true;
StateDirectory = "cloudflare-dyndns";
EnvironmentFile = cfg.apiTokenFile;
ExecStart =
let
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";
in
"${pkgs.cloudflare-dyndns}/bin/cloudflare-dyndns ${toString args}";
};
};
};
}

View file

@ -0,0 +1,53 @@
{ buildPythonApplication
, attrs
, click
, cloudflare
, fetchFromGitHub
, lib
, poetry
, pydantic
, pytestCheckHook
, requests
}:
buildPythonApplication rec {
pname = "cloudflare-dyndns";
version = "4.1";
src = fetchFromGitHub {
owner = "kissgyorgy";
repo = pname;
rev = "v${version}";
hash = "sha256-6Q5fpJ+HuQ+hc3xTtB5tR43pn9WZ0nZZR723iLAkpis=";
};
format = "pyproject";
nativeBuildInputs = [ poetry ];
propagatedBuildInputs = [
attrs
click
cloudflare
pydantic
requests
];
postPatch = ''
substituteInPlace pyproject.toml \
--replace 'click = "^7.0"' 'click = "*"'
'';
checkInputs = [ pytestCheckHook ];
disabledTests = [
"test_get_ipv4"
];
meta = with lib; {
description = " CloudFlare Dynamic DNS client ";
homepage = "https://github.com/kissgyorgy/cloudflare-dyndns";
license = licenses.mit;
maintainers = with maintainers; [ lovesegfault ];
};
}

View file

@ -2961,6 +2961,8 @@ with pkgs;
cloudflared = callPackage ../applications/networking/cloudflared { };
cloudflare-dyndns = python3Packages.cloudflare-dyndns;
cloudmonkey = callPackage ../tools/virtualization/cloudmonkey { };
clib = callPackage ../tools/package-management/clib { };

View file

@ -1735,6 +1735,8 @@ in {
cloudflare = callPackage ../development/python-modules/cloudflare { };
cloudflare-dyndns = callPackage ../applications/networking/cloudflare-dyndns { };
cloudpickle = callPackage ../development/python-modules/cloudpickle { };
cloudscraper = callPackage ../development/python-modules/cloudscraper { };