@ -3,24 +3,22 @@
let
inherit ( lib ) mkOption mkIf singleton ;
inherit ( pkgs ) ddclient ;
stateDir = " / v a r / s p o o l / d d c l i e n t " ;
ddclientUser = " d d c l i e n t " ;
ddclientFlags = " - f o r e g r o u n d - f i l e ${ ddclientCfg } " ;
ddclientFlags = " - f o r e g r o u n d - v e r b o s e - n o q u i e t - f i l e ${ ddclientCfg } " ;
ddclientPIDFile = " ${ stateDir } / d d c l i e n t . p i d " ;
ddclientCfg = pkgs . writeText " d d c l i e n t . c o n f " ''
daemon = 600
cache = $ { stateDir } /ddclient.cache
pid = $ { stateDir } /ddclient.pid
use = $ { config . services . ddclient . web }
pid = $ { ddclientPIDFile }
use = $ { config . services . ddclient . use }
login = $ { config . services . ddclient . username }
password = $ { config . services . ddclient . password }
protocol = $ { config . services . ddclient . protocol }
server = $ { config . services . ddclient . server }
ssl = $ { if config . services . ddclient . ssl then " y e s " else " y e s " }
wildcard = YES
$ { config . services . ddclient . domain }
$ { config . services . ddclient . extraConfig }
@ -34,10 +32,11 @@ in
options = {
services . ddclient = {
services . ddclient = with lib . types ; {
enable = mkOption {
default = false ;
type = bool ;
description = ''
Whether to synchronise your machine's IP address with a dynamic DNS provider ( e . g . dyndns . org ) .
'' ;
@ -45,6 +44,7 @@ in
domain = mkOption {
default = " " ;
type = str ;
description = ''
Domain name to synchronize .
'' ;
@ -52,76 +52,93 @@ in
username = mkOption {
default = " " ;
type = str ;
description = ''
Username .
'' ;
} ;
password = mkOption {
default = " " ;
default = " " ;
type = str ;
description = ''
Password .
'' ;
} ;
protocol = mkOption {
default = " d y n d n s 2 " ;
default = " d y n d n s 2 " ;
type = str ;
description = ''
Protocol to use with dynamic DNS provider . ( see also , http://sourceforge.net/apps/trac/ddclient/wiki/Protocols )
Protocol to use with dynamic DNS provider ( see http://sourceforge.net/apps/trac/ddclient/wiki/Protocols ) .
'' ;
} ;
server = mkOption {
default = " m e m b e r s . d y n d n s . o r g " ;
default = " " ;
type = str ;
description = ''
Server
Server address .
'' ;
} ;
ssl = mkOption {
default = true ;
type = bool ;
description = ''
Whether to use to use SSL/TLS to connect to dynamic DNS provider .
'' ;
} ;
extraConfig = mkOption {
default = " " ;
default = " " ;
type = str ;
description = ''
Extra configuration . Contents will be added verbatim to the configuration file .
'' ;
} ;
web = mkOption {
default = " w e b , w e b = c h e c k i p . d y n d n s . c o m / , w e b - s k i p = ' C u r r e n t I P A d d r e s s : ' " ;
description = " " ;
use = mkOption {
default = " w e b , w e b = c h e c k i p . d y n d n s . c o m / , w e b - s k i p = ' C u r r e n t I P A d d r e s s : ' " ;
type = str ;
description = ''
Method to determine the IP address to send to the dymanic DNS provider .
'' ;
} ;
} ;
} ;
###### implementation
config = mkIf config . services . ddclient . enable {
environment . systemPackages = [ ddclient ] ;
users . extraUsers = singleton
{ name = ddclientUser ;
uid = config . ids . uids . ddclient ;
description = " d d c l i e n t d a e m o n u s e r " ;
home = stateDir ;
} ;
jobs . ddclient =
{ name = " d d c l i e n t " ;
startOn = " s t a r t u p " ;
environment . systemPackages = [ ddclient ] ;
preStart =
''
mkdir - m 0755 - p $ { stateDir }
chown $ { ddclientUser } $ { stateDir }
'' ;
users . extraUsers = singleton {
name = ddclientUser ;
uid = config . ids . uids . ddclient ;
description = " d d c l i e n t d a e m o n u s e r " ;
home = stateDir ;
} ;
exec = " ${ ddclient } / b i n / d d c l i e n t ${ ddclientFlags } " ;
systemd . services . ddclient = {
description = " D y n a m i c D N S C l i e n t " ;
wantedBy = [ " m u l t i - u s e r . t a r g e t " ] ;
after = [ " n e t w o r k . t a r g e t " ] ;
serviceConfig = {
# This may change back to forking if too many problems occur:
type = " s i m p l e " ;
User = ddclientUser ;
Group = " n o g r o u p " ; #TODO get this to work
PermissionsStartOnly = " t r u e " ;
PIDFile = ddclientPIDFile ;
ExecStartPre = ''
$ { pkgs . stdenv . shell } - c " ${ pkgs . coreutils } / b i n / m k d i r - m 0 7 5 5 - p ${ stateDir } & & ${ pkgs . coreutils } / b i n / c h o w n ${ ddclientUser } ${ stateDir } "
'' ;
ExecStart = " ${ ddclient } / b i n / d d c l i e n t ${ ddclientFlags } " ;
#ExecStartPost = "${pkgs.coreutils}/bin/rm -r ${stateDir}"; # Should we have this?
} ;
} ;
} ;
}