mirror of
https://github.com/gensokyo-zone/infrastructure.git
synced 2026-02-09 04:19:19 -08:00
feat: dyndns
This commit is contained in:
parent
b85e850dd6
commit
3597edceaf
9 changed files with 197 additions and 13 deletions
54
nixos/ddclient.nix
Normal file
54
nixos/ddclient.nix
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
{
|
||||
pkgs,
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.modules) mkIf mkMerge mkDefault mkAfter mkForce;
|
||||
cfg = config.services.ddclient;
|
||||
in {
|
||||
services.ddclient = {
|
||||
enable = mkDefault true;
|
||||
quiet = mkDefault true;
|
||||
username = mkDefault "token";
|
||||
protocol = mkDefault "cloudflare";
|
||||
zone = mkDefault config.networking.domain;
|
||||
use = "no";
|
||||
domains = [ ];
|
||||
extraConfig = mkMerge [ (mkIf config.networking.enableIPv6 ''
|
||||
usev6=webv6, webv6=https://ipv6.nsupdate.info/myip
|
||||
'') ''
|
||||
usev4=webv4, webv4=https://ipv4.nsupdate.info/myip
|
||||
max-interval=1d
|
||||
'' ];
|
||||
passwordFile = config.sops.secrets.dyndns_cloudflare_token.path;
|
||||
};
|
||||
systemd.services.ddclient = mkIf cfg.enable rec {
|
||||
wants = [ "network-online.target" ];
|
||||
after = wants;
|
||||
wantedBy = mkForce [ ];
|
||||
serviceConfig = {
|
||||
ExecStartPre = let
|
||||
inherit (config.systemd.services.ddclient.serviceConfig) RuntimeDirectory;
|
||||
prestart-domains = pkgs.writeShellScript "ddclient-prestart-domains" ''
|
||||
cat ${config.sops.secrets.dyndns_ddclient_domains.path} >> /run/${RuntimeDirectory}/ddclient.conf
|
||||
'';
|
||||
in mkAfter [ "!${prestart-domains}" ];
|
||||
TimeoutStartSec = 90;
|
||||
LogFilterPatterns = [
|
||||
"~WARNING"
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
sops.secrets = let
|
||||
sopsFile = mkDefault ./secrets/dyndns.yaml;
|
||||
in {
|
||||
dyndns_cloudflare_token = {
|
||||
inherit sopsFile;
|
||||
};
|
||||
dyndns_ddclient_domains = {
|
||||
inherit sopsFile;
|
||||
};
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue