diff --git a/nixos/modules/services/networking/ddclient.nix b/nixos/modules/services/networking/ddclient.nix index 54e8423ebb74..282641f636df 100644 --- a/nixos/modules/services/networking/ddclient.nix +++ b/nixos/modules/services/networking/ddclient.nix @@ -19,11 +19,15 @@ let ${lib.optionalString (cfg.use == "" && cfg.usev4 != "") "usev4=${cfg.usev4}"} ${lib.optionalString (cfg.use == "" && cfg.usev6 != "") "usev6=${cfg.usev6}"} login=${cfg.username} - password=${ + ${ if cfg.protocol == "nsupdate" then "/run/${RuntimeDirectory}/ddclient.key" + else if (cfg.passwordFile != null) then + "password=@password_placeholder@" + else if (cfg.secretsFile != null) then + "@secrets_placeholder@" else - "@password_placeholder@" + "" } protocol=${cfg.protocol} ${lib.optionalString (cfg.script != "") "script=${cfg.script}"} @@ -49,6 +53,10 @@ let '' "${pkgs.replace-secret}/bin/replace-secret" "@password_placeholder@" "${cfg.passwordFile}" "/run/${RuntimeDirectory}/ddclient.conf" '' + else if (cfg.secretsFile != null) then + '' + "${pkgs.replace-secret}/bin/replace-secret" "@secrets_placeholder@" "${cfg.secretsFile}" "/run/${RuntimeDirectory}/ddclient.conf" + '' else '' sed -i '/^password=@password_placeholder@$/d' /run/${RuntimeDirectory}/ddclient.conf @@ -126,6 +134,16 @@ in ''; }; + secretsFile = lib.mkOption { + default = null; + type = nullOr str; + description = '' + A file containing the secrets for the dynamic DNS provider. + This file should contain lines of valid secrets in the format specified by the ddclient documentation. + If this option is set, it overrides the `passwordFile` option. + ''; + }; + interval = lib.mkOption { default = "10min"; type = str;