Convert "ntp" daemon
svn path=/nixos/branches/fix-style/; revision=14374
This commit is contained in:
parent
b5f963bb8b
commit
2e93c3cdb9
@ -480,29 +480,6 @@ in
|
||||
};
|
||||
|
||||
|
||||
ntp = {
|
||||
|
||||
enable = mkOption {
|
||||
default = true;
|
||||
description = "
|
||||
Whether to synchronise your machine's time using the NTP
|
||||
protocol.
|
||||
";
|
||||
};
|
||||
|
||||
servers = mkOption {
|
||||
default = [
|
||||
"0.pool.ntp.org"
|
||||
"1.pool.ntp.org"
|
||||
"2.pool.ntp.org"
|
||||
];
|
||||
description = "
|
||||
The set of NTP servers from which to synchronise.
|
||||
";
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
portmap = {
|
||||
|
||||
enable = mkOption {
|
||||
@ -1565,6 +1542,7 @@ in
|
||||
(import ../upstart-jobs/dhcpd.nix)
|
||||
(import ../upstart-jobs/sshd.nix)
|
||||
(import ../upstart-jobs/lshd.nix) # GNU lshd SSH2 deamon (TODO: does neither start nor generate seed file ?)
|
||||
(import ../upstart-jobs/ntpd.nix)
|
||||
|
||||
# nix
|
||||
(import ../upstart-jobs/nix.nix) # nix options and daemon
|
||||
|
@ -148,14 +148,6 @@ let
|
||||
gnunetConfig = config.services.gnunet;
|
||||
})
|
||||
|
||||
# NTP daemon.
|
||||
++ optional config.services.ntp.enable
|
||||
(import ../upstart-jobs/ntpd.nix {
|
||||
inherit modprobe;
|
||||
inherit (pkgs) ntp glibc writeText;
|
||||
servers = config.services.ntp.servers;
|
||||
})
|
||||
|
||||
# portmap daemon.
|
||||
++ optional config.services.portmap.enable
|
||||
(import ../upstart-jobs/portmap.nix {
|
||||
|
@ -1,22 +1,70 @@
|
||||
{ntp, modprobe, glibc, writeText, servers}:
|
||||
{pkgs, config, ...}:
|
||||
|
||||
###### interface
|
||||
let
|
||||
inherit (pkgs.lib) mkOption mkIf;
|
||||
|
||||
options = {
|
||||
services = {
|
||||
ntp = {
|
||||
|
||||
enable = mkOption {
|
||||
default = true;
|
||||
description = "
|
||||
Whether to synchronise your machine's time using the NTP
|
||||
protocol.
|
||||
";
|
||||
};
|
||||
|
||||
servers = mkOption {
|
||||
default = [
|
||||
"0.pool.ntp.org"
|
||||
"1.pool.ntp.org"
|
||||
"2.pool.ntp.org"
|
||||
];
|
||||
description = "
|
||||
The set of NTP servers from which to synchronise.
|
||||
";
|
||||
};
|
||||
|
||||
};
|
||||
};
|
||||
};
|
||||
in
|
||||
|
||||
###### implementation
|
||||
|
||||
let
|
||||
|
||||
inherit (pkgs) writeText ntp;
|
||||
|
||||
stateDir = "/var/lib/ntp";
|
||||
|
||||
ntpUser = "ntp";
|
||||
|
||||
config = writeText "ntp.conf" ''
|
||||
servers = config.services.ntp.servers;
|
||||
|
||||
modprobe = config.system.sbin.modprobe;
|
||||
|
||||
configFile = writeText "ntp.conf" ''
|
||||
driftfile ${stateDir}/ntp.drift
|
||||
|
||||
${toString (map (server: "server " + server + "\n") servers)}
|
||||
'';
|
||||
|
||||
ntpFlags = "-c ${config} -u ${ntpUser}:nogroup -i ${stateDir}";
|
||||
ntpFlags = "-c ${configFile} -u ${ntpUser}:nogroup -i ${stateDir}";
|
||||
|
||||
in
|
||||
|
||||
{
|
||||
|
||||
mkIf config.services.ntp.enable {
|
||||
require = [
|
||||
options
|
||||
];
|
||||
|
||||
services = {
|
||||
extraJobs = [{
|
||||
|
||||
name = "ntpd";
|
||||
|
||||
users = [
|
||||
@ -48,5 +96,6 @@ in
|
||||
|
||||
respawn ${ntp}/bin/ntpd -n ${ntpFlags}
|
||||
'';
|
||||
|
||||
}];
|
||||
};
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user