2016-01-17 13:11:09 +01:00
|
|
|
{ config, pkgs, lib, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.services.cfdyndns;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
options = {
|
|
|
|
services.cfdyndns = {
|
|
|
|
enable = mkEnableOption "Cloudflare Dynamic DNS Client";
|
|
|
|
|
|
|
|
email = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
description = ''
|
|
|
|
The email address to use to authenticate to CloudFlare.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
apikey = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
description = ''
|
|
|
|
The API Key to use to authenticate to CloudFlare.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
records = mkOption {
|
|
|
|
default = [];
|
|
|
|
example = [ "host.tld" ];
|
|
|
|
type = types.listOf types.str;
|
|
|
|
description = ''
|
|
|
|
The records to update in CloudFlare.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
systemd.services.cfdyndns = {
|
|
|
|
description = "CloudFlare Dynamic DNS Client";
|
|
|
|
after = [ "network.target" ];
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
startAt = "5 minutes";
|
|
|
|
serviceConfig = {
|
|
|
|
Type = "simple";
|
|
|
|
User = config.ids.uids.cfdyndns;
|
|
|
|
Group = config.ids.gids.cfdyndns;
|
|
|
|
ExecStart = "/bin/sh -c '${pkgs.cfdyndns}/bin/cfdyndns'";
|
|
|
|
};
|
|
|
|
environment = {
|
|
|
|
CLOUDFLARE_EMAIL="${cfg.email}";
|
|
|
|
CLOUDFLARE_APIKEY="${cfg.apikey}";
|
|
|
|
CLOUDFLARE_RECORDS="${concatStringsSep "," cfg.records}";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2018-06-30 01:58:35 +02:00
|
|
|
users.users = {
|
2016-01-17 13:11:09 +01:00
|
|
|
cfdyndns = {
|
|
|
|
group = "cfdyndns";
|
|
|
|
uid = config.ids.uids.cfdyndns;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2018-06-30 01:58:35 +02:00
|
|
|
users.groups = {
|
2016-01-17 13:11:09 +01:00
|
|
|
cfdyndns = {
|
|
|
|
gid = config.ids.gids.cfdyndns;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|