diff --git a/system/options.nix b/system/options.nix index 5bc09612503e..789a00f58a27 100644 --- a/system/options.nix +++ b/system/options.nix @@ -413,6 +413,32 @@ */ + { + name = ["services" "dhcpd" "enable"]; + default = false; + description = " + Whether to enable the DHCP server. + "; + } + + + { + name = ["services" "dhcpd" "configFile"]; + description = " + The path of the DHCP server configuration file. + "; + } + + + { + name = ["services" "dhcpd" "interfaces"]; + default = ["eth0"]; + description = " + The interfaces on which the DHCP server should listen. + "; + } + + { name = ["services" "sshd" "enable"]; default = false; diff --git a/system/upstart.nix b/system/upstart.nix index 0a00a1ba31f1..09c82fae53fe 100644 --- a/system/upstart.nix +++ b/system/upstart.nix @@ -103,6 +103,14 @@ import ../upstart-jobs/gather.nix { interfaces = config.get ["networking" "interfaces"]; }) + # DHCP server. + ++ optional ["services" "dhcpd" "enable"] + (import ../upstart-jobs/dhcpd.nix { + inherit (pkgs) dhcp; + configFile = config.get ["services" "dhcpd" "configFile"]; + interfaces = config.get ["services" "dhcpd" "interfaces"]; + }) + # SSH daemon. ++ optional ["services" "sshd" "enable"] (import ../upstart-jobs/sshd.nix { diff --git a/upstart-jobs/dhcpd.nix b/upstart-jobs/dhcpd.nix new file mode 100644 index 000000000000..aa09c2009014 --- /dev/null +++ b/upstart-jobs/dhcpd.nix @@ -0,0 +1,17 @@ +{dhcp, configFile, interfaces}: + +{ + name = "dhcpd"; + + job = " +description \"DHCP server\" + +start on network-interfaces/started +stop on network-interfaces/stop + +script + exec ${dhcp}/sbin/dhcpd -f -cf ${configFile} ${toString interfaces} +end script + "; + +}