summary refs log tree commit diff
path: root/nixos/modules/services/networking/ddclient.nix
diff options
context:
space:
mode:
authorJörg Thalheim <joerg@thalheim.io>2022-01-09 08:38:00 +0100
committerJörg Thalheim <joerg@thalheim.io>2022-01-09 13:38:41 +0100
commit51967ca77a23215df766a4cf72a56ac219e49d2a (patch)
tree49489f06db347242e535121a4b13c1326e2cd6b9 /nixos/modules/services/networking/ddclient.nix
parent2febc7dd79653114eae54e27c9be215fe53b7ce5 (diff)
downloadnixpkgs-51967ca77a23215df766a4cf72a56ac219e49d2a.tar
nixpkgs-51967ca77a23215df766a4cf72a56ac219e49d2a.tar.gz
nixpkgs-51967ca77a23215df766a4cf72a56ac219e49d2a.tar.bz2
nixpkgs-51967ca77a23215df766a4cf72a56ac219e49d2a.tar.lz
nixpkgs-51967ca77a23215df766a4cf72a56ac219e49d2a.tar.xz
nixpkgs-51967ca77a23215df766a4cf72a56ac219e49d2a.tar.zst
nixpkgs-51967ca77a23215df766a4cf72a56ac219e49d2a.zip
nixos/ddclient: better default for nsupdate
Diffstat (limited to 'nixos/modules/services/networking/ddclient.nix')
-rw-r--r--nixos/modules/services/networking/ddclient.nix12
1 files changed, 8 insertions, 4 deletions
diff --git a/nixos/modules/services/networking/ddclient.nix b/nixos/modules/services/networking/ddclient.nix
index f5335406854..0bb8c87b38e 100644
--- a/nixos/modules/services/networking/ddclient.nix
+++ b/nixos/modules/services/networking/ddclient.nix
@@ -13,7 +13,7 @@ let
     foreground=YES
     use=${cfg.use}
     login=${cfg.username}
-    password=
+    password=${lib.optionalString (cfg.protocol == "nsupdate") "/run/${RuntimeDirectory}/ddclient.key"}
     protocol=${cfg.protocol}
     ${lib.optionalString (cfg.script != "") "script=${cfg.script}"}
     ${lib.optionalString (cfg.server != "") "server=${cfg.server}"}
@@ -30,7 +30,9 @@ let
 
   preStart = ''
     install --owner ddclient -m600 ${configFile} /run/${RuntimeDirectory}/ddclient.conf
-    ${lib.optionalString (cfg.configFile == null) (if (cfg.passwordFile != null) then ''
+    ${lib.optionalString (cfg.configFile == null) (if (cfg.protocol == "nsupdate") then ''
+      install --owner ddclient -m600 ${cfg.passwordFile} /run/${RuntimeDirectory}/ddclient.key
+    '' else if (cfg.passwordFile != null) then ''
       password=$(printf "%q" "$(head -n 1 "${cfg.passwordFile}")")
       sed -i "s|^password=$|password=$password|" /run/${RuntimeDirectory}/ddclient.conf
     '' else ''
@@ -85,7 +87,9 @@ with lib;
       };
 
       username = mkOption {
-        default = "";
+        # For `nsupdate` username contains the path to the nsupdate executable
+        default = lib.optionalString (config.services.ddclient.protocol == "nsupdate") "${pkgs.bind.dnsutils}/bin/nsupdate";
+        defaultText = "";
         type = str;
         description = ''
           User name.
@@ -96,7 +100,7 @@ with lib;
         default = null;
         type = nullOr str;
         description = ''
-          A file containing the password.
+          A file containing the password or a TSIG key in named format when using the nsupdate protocol.
         '';
       };