@ -3,24 +3,24 @@
let
cfg = config . services . ddclient ;
boolToStr = bool : if bool then " y e s " else " n o " ;
dataDir = " / v a r / l i b / d d c l i e n t " ;
configText = ''
# This file can be used as a template for configFile or is automatically generated by Nix options.
daemon = $ { toString cfg . interval }
cache = $ { cfg . homeDir } /ddclient.cache
pid = /run/ddclient/ddclient.pid
foreground = NO
cache = $ { dataDir } /ddclient.cache
foreground = YES
use = $ { cfg . use }
login = $ { cfg . username }
password = $ { cfg . password }
protocol = $ { cfg . protocol }
$ { let server = cfg . server ; in
lib . optionalString ( server != " " ) " s e r v e r = ${ server } " }
$ { lib . optionalString ( cfg . script != " " ) " s c r i p t = ${ cfg . script } " }
$ { lib . optionalString ( cfg . server != " " ) " s e r v e r = ${ cfg . server } " }
$ { lib . optionalString ( cfg . zone != " " ) " z o n e = ${ cfg . zone } " }
ssl = $ { boolToStr cfg . ssl }
wildcard = YES
quiet = $ { boolToStr cfg . quiet }
verbose = $ { boolToStr cfg . verbose }
$ { cfg . domain }
$ { lib . concatStringsSep " , " cfg . domains }
$ { cfg . extraConfig }
'' ;
@ -44,17 +44,11 @@ with lib;
'' ;
} ;
homeDir = mkOption {
default = " / v a r / l i b / d d c l i e n t " ;
type = str ;
description = " H o m e d i r e c t o r y f o r t h e d a e m o n u s e r . " ;
} ;
domain = mkOption {
default = " " ;
type = str ;
domains = mkOption {
default = [ " " ] ;
type = listOf str ;
description = ''
Domain name to synchronize .
Domain name ( s ) to synchronize .
'' ;
} ;
@ -62,7 +56,7 @@ with lib;
default = " " ;
type = str ;
description = ''
Username .
User name .
'' ;
} ;
@ -75,9 +69,12 @@ with lib;
} ;
interval = mkOption {
default = 600 ;
type = int ;
description = " T h e i n t e r v a l a t w h i c h t o r u n t h e c h e c k a n d u p d a t e . " ;
default = " 1 0 m i n " ;
type = str ;
description = ''
The interval at which to run the check and update .
See <command> man 7 systemd . time < /command > for the format .
'' ;
} ;
configFile = mkOption {
@ -95,7 +92,7 @@ with lib;
default = " d y n d n s 2 " ;
type = str ;
description = ''
Protocol to use with dynamic DNS provider ( see http://sourceforge.net/apps/trac/ddclient/wiki/P rotocols ) .
Protocol to use with dynamic DNS provider ( see https://sourceforge.net/p/ddclient/wiki/p rotocols ) .
'' ;
} ;
@ -115,11 +112,20 @@ with lib;
'' ;
} ;
extraConfig = mkOption {
quiet = mkOption {
default = false ;
type = bool ;
description = ''
Print no messages for unnecessary updates .
'' ;
} ;
script = mkOption {
default = " " ;
type = lines ;
type = str ;
description = ''
Extra configuration . Contents will be added verbatim to the configuration file .
script as required by some providers .
'' ;
} ;
@ -139,11 +145,19 @@ with lib;
'' ;
} ;
quiet = mkOption {
default = false ;
type = bool ;
zone = mkOption {
default = " " ;
type = str ;
description = ''
Print no messages for unnecessary updates .
zone as required by some providers .
'' ;
} ;
extraConfig = mkOption {
default = " " ;
type = lines ;
description = ''
Extra configuration . Contents will be added verbatim to the configuration file .
'' ;
} ;
} ;
@ -153,23 +167,8 @@ with lib;
###### implementation
config = mkIf config . services . ddclient . enable {
users = {
extraGroups . ddclient . gid = config . ids . gids . ddclient ;
extraUsers . ddclient = {
uid = config . ids . uids . ddclient ;
description = " d d c l i e n t d a e m o n u s e r " ;
group = " d d c l i e n t " ;
home = cfg . homeDir ;
createHome = true ;
} ;
} ;
environment . etc . " d d c l i e n t . c o n f " = {
enable = cfg . configFile == " / e t c / d d c l i e n t . c o n f " ;
uid = config . ids . uids . ddclient ;
gid = config . ids . gids . ddclient ;
mode = " 0 6 0 0 " ;
text = configText ;
} ;
@ -180,15 +179,22 @@ with lib;
after = [ " n e t w o r k . t a r g e t " ] ;
restartTriggers = [ config . environment . etc . " d d c l i e n t . c o n f " . source ] ;
serviceConfig = {
RuntimeDirectory = " d d c l i e n t " ;
# we cannot run in forking mode as it swallows all the program output
Type = " s i m p l e " ;
User = " d d c l i e n t " ;
Group = " d d c l i e n t " ;
ExecStart = " ${ lib . getBin pkgs . ddclient } / b i n / d d c l i e n t - f o r e g r o u n d - f i l e ${ cfg . configFile } " ;
ProtectSystem = " f u l l " ;
PrivateTmp = true ;
serviceConfig = rec {
DynamicUser = true ;
RuntimeDirectory = StateDirectory ;
StateDirectory = builtins . baseNameOf dataDir ;
Type = " o n e s h o t " ;
ExecStartPre = " ! ${ lib . getBin pkgs . coreutils } / b i n / i n s t a l l - m 6 6 6 ${ cfg . configFile } / r u n / ${ RuntimeDirectory } / d d c l i e n t . c o n f " ;
ExecStart = " ${ lib . getBin pkgs . ddclient } / b i n / d d c l i e n t - f i l e / r u n / ${ RuntimeDirectory } / d d c l i e n t . c o n f " ;
} ;
} ;
systemd . timers . ddclient = {
description = " R u n d d c l i e n t " ;
wantedBy = [ " t i m e r s . t a r g e t " ] ;
timerConfig = {
OnBootSec = cfg . interval ;
OnUnitInactiveSec = cfg . interval ;
} ;
} ;
} ;