+/config
my dotfiles and nix configuration
git clone https://git.julia.blue/+/config
7238195
main
1{ config , lib , pkgs , ...} :let 2cfg = config . services . porkbun-ddns ; 3types = lib . types ; 4in { 5options . services . porkbun-ddns = { 6enable = lib . mkEnableOption '' 7Simple Dynamic DNS client for porkbun that points domains at your current ip 8'' ; 9domains = lib . mkOption { 10type = types . listOf types . str ; 11description = "A list of domain names to update the DNS entries for" ; 12}; 13api-key = lib . mkOption { 14type = types . path ; 15description = "A file containing your porkbun api key" ; 16}; 17secret-key = lib . mkOption { 18type = types . path ; 19description = "A file containing your porkbun api secret" ; 20}; 21ipv4 = lib . mkOption { 22type = types . bool ; 23description = "Set A records for your domain(s)" ; 24default = true ; 25}; 26ipv6 = lib . mkOption { 27type = types . bool ; 28description = "Set AAAA records for your domain(s)" ; 29}; 30ttl = lib . mkOption { 31default = 21600 ; 32type = types . ints . unsigned ; 33description = lib . mdDoc "The [Time to Live](https://developers.cloudflare.com/dns/manage-dns-records/reference/ttl/) for new DNS records in seconds" ; 34}; 35frequency = lib . mkOption { 36default = "00/6:00" ; 37type = types . str ; 38description = lib . mdDoc '' 39How often to run update the DNS records, specified as a [systemd calendar expression](https://www.freedesktop.org/software/systemd/man/latest/systemd.time.html#Calendar%20Events) 40'' ; 41}; 42}; 43 44config = lib . mkIf cfg . enable { 45systemd . services . porkbun-ddns = { 46description = "Update porkbun DNS entry to point to this computer" ; 47startAt = cfg . frequency ; 48script = '' 49export PORKBUN_API_KEY =` < ${ cfg . api-key } ` 50export PORKBUN_API_SECRET =` < ${ cfg . secret-key } ` 51${ lib . getExe pkgs . porkbun-ddns } \ 52${ if cfg . ipv4 then "-4" else "" } \ 53${ if cfg . ipv6 then "-6" else "" } \ 54--ttl ${ toString cfg . ttl } \ 55${ builtins . concatStringsSep " " cfg . domains } '' ; 56}; 57}; 58}