2e751c0772
the conversion procedure is simple: - find all things that look like options, ie calls to either `mkOption` or `lib.mkOption` that take an attrset. remember the attrset as the option - for all options, find a `description` attribute who's value is not a call to `mdDoc` or `lib.mdDoc` - textually convert the entire value of the attribute to MD with a few simple regexes (the set from mdize-module.sh) - if the change produced a change in the manual output, discard - if the change kept the manual unchanged, add some text to the description to make sure we've actually found an option. if the manual changes this time, keep the converted description this procedure converts 80% of nixos options to markdown. around 2000 options remain to be inspected, but most of those fail the "does not change the manual output check": currently the MD conversion process does not faithfully convert docbook tags like <code> and <package>, so any option using such tags will not be converted at all.
94 lines
2.4 KiB
Nix
94 lines
2.4 KiB
Nix
{ 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 = lib.mdDoc ''
|
|
List of domain names to update records for.
|
|
'';
|
|
};
|
|
|
|
proxied = mkOption {
|
|
type = types.bool;
|
|
default = false;
|
|
description = lib.mdDoc ''
|
|
Whether this is a DNS-only record, or also being proxied through CloudFlare.
|
|
'';
|
|
};
|
|
|
|
ipv4 = mkOption {
|
|
type = types.bool;
|
|
default = true;
|
|
description = lib.mdDoc ''
|
|
Whether to enable setting IPv4 A records.
|
|
'';
|
|
};
|
|
|
|
ipv6 = mkOption {
|
|
type = types.bool;
|
|
default = false;
|
|
description = lib.mdDoc ''
|
|
Whether to enable setting IPv6 AAAA records.
|
|
'';
|
|
};
|
|
|
|
deleteMissing = mkOption {
|
|
type = types.bool;
|
|
default = false;
|
|
description = lib.mdDoc ''
|
|
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}";
|
|
};
|
|
};
|
|
};
|
|
}
|