From c0ed553c87803ac5b8d88ff4ec4137fc2eb12c99 Mon Sep 17 00:00:00 2001 From: Marc Weber Date: Fri, 6 Mar 2009 12:27:13 +0000 Subject: [PATCH] Convert "bind" svn path=/nixos/branches/fix-style/; revision=14394 --- system/options.nix | 37 +------------------ upstart-jobs/bind.nix | 79 ++++++++++++++++++++++++++++++++++------ upstart-jobs/default.nix | 6 --- 3 files changed, 69 insertions(+), 53 deletions(-) diff --git a/system/options.nix b/system/options.nix index 99904c7b7a0d..6b9e58824a79 100644 --- a/system/options.nix +++ b/system/options.nix @@ -479,42 +479,6 @@ in }; - bind = { - enable = mkOption { - default = false; - description = " - Whether to enable BIND domain name server. - "; - }; - cacheNetworks = mkOption { - default = ["127.0.0.0/24"]; - description = " - What networks are allowed to use us as a resolver. - "; - }; - blockedNetworks = mkOption { - default = []; - description = " - What networks are just blocked. - "; - }; - zones = mkOption { - default = []; - description = " - List of zones we claim authority over. - master=false means slave server; slaves means addresses - who may request zone transfer. - "; - example = [{ - name = "example.com"; - master = false; - file = "/var/dns/example.com"; - masters = ["192.168.0.1"]; - slaves = []; - }]; - }; - }; - }; nesting = { @@ -619,6 +583,7 @@ in (import ../upstart-jobs/openfire.nix) (import ../upstart-jobs/postfix.nix) (import ../upstart-jobs/dovecot.nix) + (import ../upstart-jobs/bind.nix) # nix (import ../upstart-jobs/nix.nix) # nix options and daemon diff --git a/upstart-jobs/bind.nix b/upstart-jobs/bind.nix index f645abc9340e..d216987e573d 100644 --- a/upstart-jobs/bind.nix +++ b/upstart-jobs/bind.nix @@ -1,4 +1,52 @@ -{config, pkgs}: +{pkgs, config, ...}: + +###### interface +let + inherit (pkgs.lib) mkOption mkIf; + + options = { + services = { + bind = { + enable = mkOption { + default = false; + description = " + Whether to enable BIND domain name server. + "; + }; + cacheNetworks = mkOption { + default = ["127.0.0.0/24"]; + description = " + What networks are allowed to use us as a resolver. + "; + }; + blockedNetworks = mkOption { + default = []; + description = " + What networks are just blocked. + "; + }; + zones = mkOption { + default = []; + description = " + List of zones we claim authority over. + master=false means slave server; slaves means addresses + who may request zone transfer. + "; + example = [{ + name = "example.com"; + master = false; + file = "/var/dns/example.com"; + masters = ["192.168.0.1"]; + slaves = []; + }]; + }; + }; + }; + }; +in + +###### implementation + let startingDependency = if config.services.gw6c.enable then "gw6c" else "network-interfaces"; cfg = config.services.bind; @@ -52,15 +100,24 @@ let confFile = pkgs.writeText "named.conf" namedConf; in -{ - name = "bind"; - job = '' - description "BIND name server job" - start script - ${pkgs.coreutils}/bin/mkdir -p /var/run/named - end script +mkIf config.services.bind.enable { + require = [ + options + ]; - respawn ${pkgs.bind}/sbin/named -c ${confFile} -f - ''; -} + services = { + extraJobs = [{ + name = "bind"; + job = '' + description "BIND name server job" + + start script + ${pkgs.coreutils}/bin/mkdir -p /var/run/named + end script + + respawn ${pkgs.bind}/sbin/named -c ${confFile} -f + ''; + }]; + }; +} diff --git a/upstart-jobs/default.nix b/upstart-jobs/default.nix index a11ec89acb89..3999f8c4e9dd 100644 --- a/upstart-jobs/default.nix +++ b/upstart-jobs/default.nix @@ -131,12 +131,6 @@ let inherit config; }) - # ISC BIND domain name server. - ++ optional config.services.bind.enable - (import ../upstart-jobs/bind.nix { - inherit config pkgs; - }) - # Handles the reboot/halt events. ++ (map (event: makeJob (import ../upstart-jobs/halt.nix {