refactor(infra): migrate ddclient configuration to standalone template
- Extract hardcoded `ddclient.conf` into a dedicated file to improve readability and enable native syntax highlighting. - Refactor `dynu.nix` to use `builtins.readFile` and `builtins.replaceStrings` for dynamic secret injection. - Harden `ddclient` operational parameters: Remove `daemon=0` to force foreground execution and add `usev4=webv4` for explicit WAN IP discovery. Rationale: Eliminates fragile string-concatenation logic in Nix files and solves IP-resolution failures by ensuring the service executes in a controlled, foreground-reporting state.
This commit is contained in:
1 parent
4a9b4de27d
commit
25c9699ac4
2 files changed
+19
-13
No files matched your search
@@ -0,0 +1,11 @@
|
||||
# General configuration
|
||||
syslog=yes
|
||||
pid=/run/ddclient/ddclient.pid
|
||||
usev4=webv4
|
||||
|
||||
# Provider definition using credentials decrypted at runtime
|
||||
protocol=dyndns2
|
||||
server=api.dynu.com
|
||||
login=@dynu_user@
|
||||
password=@dynu_password@
|
||||
@dynu_domain@
|
||||
+8
-13
@@ -25,19 +25,14 @@ in
|
||||
# Assemble the ddclient config file securely at boot time in /run/secrets/
|
||||
# Defaults to owner root:root (which avoids dynamic user evaluation issues)
|
||||
sops.templates."ddclient.conf" = {
|
||||
content = ''
|
||||
# General configuration
|
||||
daemon=0
|
||||
syslog=yes
|
||||
pid=/run/ddclient/ddclient.pid
|
||||
|
||||
# Provider definition using credentials decrypted at runtime
|
||||
protocol=dyndns2
|
||||
server=api.dynu.com
|
||||
login=${config.sops.placeholder.dynu_user}
|
||||
password=${config.sops.placeholder.dynu_password}
|
||||
${config.sops.placeholder.dynu_domain}
|
||||
'';
|
||||
content = builtins.replaceStrings
|
||||
[ "@dynu_user@" "@dynu_password@" "@dynu_domain@" ]
|
||||
[
|
||||
config.sops.placeholder.dynu_user
|
||||
config.sops.placeholder.dynu_password
|
||||
config.sops.placeholder.dynu_domain
|
||||
]
|
||||
(builtins.readFile ./ddclient.conf);
|
||||
};
|
||||
|
||||
# 2. Enable ddclient and feed it the decrypted configuration template via systemd credentials
|
||||
|
||||
Reference in new issue
Block a user