diff --git a/modules/services/networking/ntpd.nix b/modules/services/networking/ntpd.nix index c8063092a95..e4b3432abd9 100644 --- a/modules/services/networking/ntpd.nix +++ b/modules/services/networking/ntpd.nix @@ -1,42 +1,10 @@ {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; + inherit (pkgs.lib) mkOption mkIf singleton; + + inherit (pkgs) ntp; stateDir = "/var/lib/ntp"; @@ -46,7 +14,7 @@ let modprobe = config.system.sbin.modprobe; - configFile = writeText "ntp.conf" '' + configFile = pkgs.writeText "ntp.conf" '' driftfile ${stateDir}/ntp.drift # Keep the drift file in ${stateDir}/ntp.drift. However, since we # chroot to ${stateDir}, we have to specify it as /ntp.drift. @@ -59,25 +27,53 @@ let in +{ -mkIf config.services.ntp.enable { - require = [ - options - ]; + ###### interface + + options = { + + services.ntp = { - services = { - extraJobs = [{ + 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. + ''; + }; + + }; + + }; + + + ###### implementation + + config = mkIf config.services.ntp.enable { + + users.extraUsers = singleton + { name = ntpUser; + uid = config.ids.uids.ntp; + description = "NTP daemon user"; + home = stateDir; + }; + + jobs = singleton { name = "ntpd"; - users = [ - { name = ntpUser; - uid = config.ids.uids.ntp; - description = "NTP daemon user"; - home = stateDir; - } - ]; - job = '' description "NTP daemon" @@ -104,6 +100,9 @@ mkIf config.services.ntp.enable { respawn ${ntp}/bin/ntpd -g -n ${ntpFlags} ''; - }]; + + }; + }; + } diff --git a/modules/services/system/nscd.nix b/modules/services/system/nscd.nix index da1e5bec2bc..63fa36b9422 100644 --- a/modules/services/system/nscd.nix +++ b/modules/services/system/nscd.nix @@ -1,44 +1,47 @@ {pkgs, config, ...}: -###### implementation - let + nssModulesPath = config.system.nssModules.path; + + inherit (pkgs.lib) singleton; + in { - services = { - extraJobs = [{ - name = "nscd"; + config = { + + users.extraUsers = singleton + { name = "nscd"; + uid = config.ids.uids.nscd; + description = "Name service cache daemon user"; + }; + + jobs = singleton { + name = "nscd"; - users = [ - { name = "nscd"; - uid = config.ids.uids.nscd; - description = "Name service cache daemon user"; - } - ]; - - job = '' - description \"Name Service Cache Daemon\" - - start on startup - stop on shutdown - - env LD_LIBRARY_PATH=${nssModulesPath} - - start script - - mkdir -m 0755 -p /var/run/nscd - mkdir -m 0755 -p /var/db/nscd - - rm -f /var/db/nscd/* # for testing - - end script - - # !!! -d turns on debug info which probably makes nscd slower - # 2>/dev/null is to make it shut up - respawn ${pkgs.glibc}/sbin/nscd -f ${./nscd.conf} -d 2> /dev/null + job = '' + description \"Name Service Cache Daemon\" + + start on startup + stop on shutdown + + env LD_LIBRARY_PATH=${nssModulesPath} + + start script + + mkdir -m 0755 -p /var/run/nscd + mkdir -m 0755 -p /var/db/nscd + + rm -f /var/db/nscd/* # for testing + + end script + + # !!! -d turns on debug info which probably makes nscd slower + # 2>/dev/null is to make it shut up + respawn ${pkgs.glibc}/sbin/nscd -f ${./nscd.conf} -d 2> /dev/null ''; - }]; + }; + }; } diff --git a/modules/system/upstart/make-job.nix b/modules/system/upstart/make-job.nix index aabc3ad2f5d..b7ec71e999b 100644 --- a/modules/system/upstart/make-job.nix +++ b/modules/system/upstart/make-job.nix @@ -13,15 +13,3 @@ "eval \"$buildHook\"; ensureDir $out/etc/event.d; echo \"$job\" > $out/etc/event.d/$jobName" ) ) - -// - -{ - # Allow jobs to declare user accounts that should be created. - users = if job ? users then job.users else []; - - # Allow jobs to declare groups that should be created. - groups = if job ? groups then job.groups else []; - - passthru = if job ? passthru then job.passthru else {}; -} diff --git a/modules/system/upstart/upstart.nix b/modules/system/upstart/upstart.nix index 7ae1f4e206d..ea45bb498fb 100644 --- a/modules/system/upstart/upstart.nix +++ b/modules/system/upstart/upstart.nix @@ -87,12 +87,6 @@ in } ]; - users.extraUsers = - pkgs.lib.concatLists (map (job: job.users) jobs); - - users.extraGroups = - pkgs.lib.concatLists (map (job: job.groups) jobs); - services.extraJobs = [ # For the built-in logd job. { jobDrv = pkgs.upstart; }