0
0
Fork 0
mirror of https://github.com/NixOS/nixpkgs.git synced 2025-07-14 06:00:33 +03:00

Merge pull request #6448 from eduarrrd/ddclient

ddclient module: fix module
This commit is contained in:
lethalman 2015-03-17 12:38:12 +01:00
commit 359bc60ec8

View file

@ -3,24 +3,22 @@
let let
inherit (lib) mkOption mkIf singleton; inherit (lib) mkOption mkIf singleton;
inherit (pkgs) ddclient; inherit (pkgs) ddclient;
stateDir = "/var/spool/ddclient"; stateDir = "/var/spool/ddclient";
ddclientUser = "ddclient"; ddclientUser = "ddclient";
ddclientFlags = "-foreground -verbose -noquiet -file ${ddclientCfg}";
ddclientFlags = "-foreground -file ${ddclientCfg}"; ddclientPIDFile = "${stateDir}/ddclient.pid";
ddclientCfg = pkgs.writeText "ddclient.conf" '' ddclientCfg = pkgs.writeText "ddclient.conf" ''
daemon=600 daemon=600
cache=${stateDir}/ddclient.cache cache=${stateDir}/ddclient.cache
pid=${stateDir}/ddclient.pid pid=${ddclientPIDFile}
use=${config.services.ddclient.web} use=${config.services.ddclient.use}
login=${config.services.ddclient.username} login=${config.services.ddclient.username}
password=${config.services.ddclient.password} password=${config.services.ddclient.password}
protocol=${config.services.ddclient.protocol} protocol=${config.services.ddclient.protocol}
server=${config.services.ddclient.server} server=${config.services.ddclient.server}
ssl=${if config.services.ddclient.ssl then "yes" else "yes"}
wildcard=YES wildcard=YES
${config.services.ddclient.domain} ${config.services.ddclient.domain}
${config.services.ddclient.extraConfig} ${config.services.ddclient.extraConfig}
@ -34,10 +32,11 @@ in
options = { options = {
services.ddclient = { services.ddclient = with lib.types; {
enable = mkOption { enable = mkOption {
default = false; default = false;
type = bool;
description = '' description = ''
Whether to synchronise your machine's IP address with a dynamic DNS provider (e.g. dyndns.org). Whether to synchronise your machine's IP address with a dynamic DNS provider (e.g. dyndns.org).
''; '';
@ -45,6 +44,7 @@ in
domain = mkOption { domain = mkOption {
default = ""; default = "";
type = str;
description = '' description = ''
Domain name to synchronize. Domain name to synchronize.
''; '';
@ -52,46 +52,60 @@ in
username = mkOption { username = mkOption {
default = ""; default = "";
type = str;
description = '' description = ''
Username. Username.
''; '';
}; };
password = mkOption { password = mkOption {
default = "" ; default = "";
type = str;
description = '' description = ''
Password. Password.
''; '';
}; };
protocol = mkOption { protocol = mkOption {
default = "dyndns2" ; default = "dyndns2";
type = str;
description = '' 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 { server = mkOption {
default = "members.dyndns.org" ; default = "";
type = str;
description = '' 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 { extraConfig = mkOption {
default = "" ; default = "";
type = str;
description = '' description = ''
Extra configuration. Contents will be added verbatim to the configuration file. Extra configuration. Contents will be added verbatim to the configuration file.
''; '';
}; };
web = mkOption { use = mkOption {
default = "web, web=checkip.dyndns.com/, web-skip='Current IP Address: '" ; default = "web, web=checkip.dyndns.com/, web-skip='Current IP Address: '";
description = ""; type = str;
description = ''
Method to determine the IP address to send to the dymanic DNS provider.
'';
}; };
}; };
}; };
@ -101,27 +115,30 @@ in
environment.systemPackages = [ ddclient ]; environment.systemPackages = [ ddclient ];
users.extraUsers = singleton users.extraUsers = singleton {
{ name = ddclientUser; name = ddclientUser;
uid = config.ids.uids.ddclient; uid = config.ids.uids.ddclient;
description = "ddclient daemon user"; description = "ddclient daemon user";
home = stateDir; home = stateDir;
}; };
jobs.ddclient = systemd.services.ddclient = {
{ name = "ddclient"; description = "Dynamic DNS Client";
wantedBy = [ "multi-user.target" ];
startOn = "startup"; after = [ "network.target" ];
serviceConfig = {
preStart = # This may change back to forking if too many problems occur:
'' type = "simple";
mkdir -m 0755 -p ${stateDir} User = ddclientUser;
chown ${ddclientUser} ${stateDir} Group = "nogroup"; #TODO get this to work
PermissionsStartOnly = "true";
PIDFile = ddclientPIDFile;
ExecStartPre = ''
${pkgs.stdenv.shell} -c "${pkgs.coreutils}/bin/mkdir -m 0755 -p ${stateDir} && ${pkgs.coreutils}/bin/chown ${ddclientUser} ${stateDir}"
''; '';
ExecStart = "${ddclient}/bin/ddclient ${ddclientFlags}";
exec = "${ddclient}/bin/ddclient ${ddclientFlags}"; #ExecStartPost = "${pkgs.coreutils}/bin/rm -r ${stateDir}"; # Should we have this?
};
}; };
}; };
} }