2014-05-05 19:58:51 +01:00
|
|
|
{ config, pkgs, lib, ... }:
|
2009-09-16 12:22:45 +01:00
|
|
|
|
|
|
|
let
|
|
|
|
|
2014-05-05 19:58:51 +01:00
|
|
|
inherit (lib) mkOption mkIf singleton;
|
2009-09-16 12:22:45 +01:00
|
|
|
|
|
|
|
inherit (pkgs) ddclient;
|
|
|
|
|
|
|
|
stateDir = "/var/spool/ddclient";
|
|
|
|
|
|
|
|
ddclientUser = "ddclient";
|
|
|
|
|
|
|
|
ddclientFlags = "-foreground -file ${ddclientCfg}";
|
|
|
|
|
|
|
|
ddclientCfg = pkgs.writeText "ddclient.conf" ''
|
2009-09-16 12:57:41 +01:00
|
|
|
daemon=600
|
|
|
|
cache=${stateDir}/ddclient.cache
|
|
|
|
pid=${stateDir}/ddclient.pid
|
|
|
|
use=${config.services.ddclient.web}
|
|
|
|
login=${config.services.ddclient.username}
|
|
|
|
password=${config.services.ddclient.password}
|
|
|
|
protocol=${config.services.ddclient.protocol}
|
|
|
|
server=${config.services.ddclient.server}
|
|
|
|
wildcard=YES
|
|
|
|
${config.services.ddclient.domain}
|
|
|
|
${config.services.ddclient.extraConfig}
|
|
|
|
'';
|
2009-09-16 12:22:45 +01:00
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
###### interface
|
2011-09-14 19:20:50 +01:00
|
|
|
|
2009-09-16 12:22:45 +01:00
|
|
|
options = {
|
2011-09-14 19:20:50 +01:00
|
|
|
|
2009-09-16 12:22:45 +01:00
|
|
|
services.ddclient = {
|
|
|
|
|
|
|
|
enable = mkOption {
|
|
|
|
default = false;
|
|
|
|
description = ''
|
|
|
|
Whether to synchronise your machine's IP address with a dynamic DNS provider (e.g. dyndns.org).
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
domain = mkOption {
|
|
|
|
default = "";
|
|
|
|
description = ''
|
|
|
|
Domain name to synchronize.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
username = mkOption {
|
|
|
|
default = "";
|
|
|
|
description = ''
|
|
|
|
Username.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
password = mkOption {
|
|
|
|
default = "" ;
|
|
|
|
description = ''
|
|
|
|
Password.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
protocol = mkOption {
|
|
|
|
default = "dyndns2" ;
|
|
|
|
description = ''
|
|
|
|
Protocol to use with dynamic DNS provider. (see also, http://sourceforge.net/apps/trac/ddclient/wiki/Protocols)
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
server = mkOption {
|
|
|
|
default = "members.dyndns.org" ;
|
|
|
|
description = ''
|
|
|
|
Server
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
extraConfig = mkOption {
|
|
|
|
default = "" ;
|
|
|
|
description = ''
|
|
|
|
Extra configuration. Contents will be added verbatim to the configuration file.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
web = mkOption {
|
2013-12-12 04:17:53 +00:00
|
|
|
default = "web, web=checkip.dyndns.com/, web-skip='Current IP Address: '" ;
|
2012-03-17 17:26:17 +00:00
|
|
|
description = "";
|
2009-09-16 12:22:45 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
###### implementation
|
|
|
|
|
|
|
|
config = mkIf config.services.ddclient.enable {
|
2012-03-17 17:26:17 +00:00
|
|
|
|
2009-09-16 12:22:45 +01:00
|
|
|
environment.systemPackages = [ ddclient ];
|
2011-09-14 19:20:50 +01:00
|
|
|
|
2009-09-16 12:22:45 +01:00
|
|
|
users.extraUsers = singleton
|
|
|
|
{ name = ddclientUser;
|
|
|
|
uid = config.ids.uids.ddclient;
|
|
|
|
description = "ddclient daemon user";
|
|
|
|
home = stateDir;
|
|
|
|
};
|
|
|
|
|
2009-10-12 19:09:34 +01:00
|
|
|
jobs.ddclient =
|
2009-10-12 18:27:57 +01:00
|
|
|
{ name = "ddclient";
|
2009-09-16 12:22:45 +01:00
|
|
|
|
2009-10-12 18:27:57 +01:00
|
|
|
startOn = "startup";
|
2009-09-16 12:22:45 +01:00
|
|
|
|
2009-10-12 18:27:57 +01:00
|
|
|
preStart =
|
|
|
|
''
|
|
|
|
mkdir -m 0755 -p ${stateDir}
|
|
|
|
chown ${ddclientUser} ${stateDir}
|
|
|
|
'';
|
2009-09-16 12:22:45 +01:00
|
|
|
|
2009-10-12 18:27:57 +01:00
|
|
|
exec = "${ddclient}/bin/ddclient ${ddclientFlags}";
|
|
|
|
};
|
2009-09-16 12:22:45 +01:00
|
|
|
|
|
|
|
};
|
2011-09-14 19:20:50 +01:00
|
|
|
|
2009-09-16 12:22:45 +01:00
|
|
|
}
|