From 77240b46f1ba95abee2903195c0465a030b35a50 Mon Sep 17 00:00:00 2001 From: Mathijs Kwik Date: Sun, 4 Mar 2012 12:58:11 +0000 Subject: [PATCH] all-interfaces event many services depend on other services that bring up network interfaces. Examples are ipv6 tunneling clients or VPNs. As there are multiple choices for these network-interface-providing services, it's not nice to hardcore these deps in every service. This change sets up a generic config option for this purpose. providers (gw6c/gogoclient/openvpn) can plug into this to signal they bring up an important interface. Daemons that need these interfaces, can then depend on the 'all-interfaces' event, instead of the individual services. By default, the event fires when network-interfaces completes. svn path=/nixos/trunk/; revision=32764 --- modules/tasks/network-interfaces.nix | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/modules/tasks/network-interfaces.nix b/modules/tasks/network-interfaces.nix index b9c5d897295..ef8e486ebcf 100644 --- a/modules/tasks/network-interfaces.nix +++ b/modules/tasks/network-interfaces.nix @@ -173,6 +173,16 @@ in ''; }; + networking.interfaceJobs = mkOption { + default = [config.jobs.networkInterfaces]; + type = types.list types.attrs; + merge = mergeListOption; + description = '' + List of jobs that bring up additional interfaces. + For example vpn / ipv6 / ppp tasks. + This gets used by certain services as dependency for their upstart job. + ''; + }; }; @@ -273,6 +283,19 @@ in ''; }; + jobs.allInterfaces = { + name = "all-interfaces"; + description = "all required interfaces are up"; + startOn = concatStringsSep " and " (map (job: "started ${job.name}") cfg.interfaceJobs); + stopOn = concatStringsSep " and " (map (job: "stopping ${job.name}") cfg.interfaceJobs); + task = true; + exec = "true"; + }; + + + networking.interfaceJobs = [config.jobs.networkInterfaces]; + + # Set the host name in the activation script. Don't clear it if # it's not configured in the NixOS configuration, since it may # have been set by dhclient in the meantime.