1 { config, pkgs, lib, ... }:
3 cfg = config.services.cfdyndns;
7 (lib.mkRemovedOptionModule
8 [ "services" "cfdyndns" "apikey" ]
9 "Use services.cfdyndns.apikeyFile instead.")
14 enable = lib.mkEnableOption "Cloudflare Dynamic DNS Client";
16 email = lib.mkOption {
19 The email address to use to authenticate to CloudFlare.
23 apiTokenFile = lib.mkOption {
25 type = lib.types.nullOr lib.types.str;
27 The path to a file containing the API Token
28 used to authenticate with CloudFlare.
32 apikeyFile = lib.mkOption {
34 type = lib.types.nullOr lib.types.str;
36 The path to a file containing the API Key
37 used to authenticate with CloudFlare.
41 records = lib.mkOption {
43 example = [ "host.tld" ];
44 type = lib.types.listOf lib.types.str;
46 The records to update in CloudFlare.
52 config = lib.mkIf cfg.enable {
53 systemd.services.cfdyndns = {
54 description = "CloudFlare Dynamic DNS Client";
55 after = [ "network.target" ];
56 wantedBy = [ "multi-user.target" ];
60 LoadCredential = lib.optional (cfg.apiTokenFile != null) "CLOUDFLARE_APITOKEN_FILE:${cfg.apiTokenFile}";
64 CLOUDFLARE_RECORDS="${lib.concatStringsSep "," cfg.records}";
67 ${lib.optionalString (cfg.apikeyFile != null) ''
68 export CLOUDFLARE_APIKEY="$(cat ${lib.escapeShellArg cfg.apikeyFile})"
69 export CLOUDFLARE_EMAIL="${cfg.email}"
71 ${lib.optionalString (cfg.apiTokenFile != null) ''
72 export CLOUDFLARE_APITOKEN=$(${pkgs.systemd}/bin/systemd-creds cat CLOUDFLARE_APITOKEN_FILE)
74 ${pkgs.cfdyndns}/bin/cfdyndns