From 320a82dd7f821e3383fe63b21c7c99927913631d Mon Sep 17 00:00:00 2001 From: "William A. Kennington III" Date: Fri, 4 Jul 2014 15:11:16 -0500 Subject: nixos/dhcpcd: Add an explicit interfaces option --- nixos/modules/services/networking/dhcpcd.nix | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'nixos/modules/services/networking/dhcpcd.nix') diff --git a/nixos/modules/services/networking/dhcpcd.nix b/nixos/modules/services/networking/dhcpcd.nix index 5a353fc0942..c541d4fa604 100644 --- a/nixos/modules/services/networking/dhcpcd.nix +++ b/nixos/modules/services/networking/dhcpcd.nix @@ -6,6 +6,8 @@ let dhcpcd = if !config.boot.isContainer then pkgs.dhcpcd else pkgs.dhcpcd.override { udev = null; }; + cfg = config.networking.dhcpcd; + # Don't start dhcpcd on explicitly configured interfaces or on # interfaces that are part of a bridge. ignoredInterfaces = @@ -37,7 +39,10 @@ let # (Xen) and virbr* and vnet* (libvirt). denyinterfaces ${toString ignoredInterfaces} lo peth* vif* tap* tun* virbr* vnet* vboxnet* - ${config.networking.dhcpcd.extraConfig} + # Use the list of allowed interfaces if specified + ${optionalString (cfg.allowInterfaces != [ ]) "allowinterfaces ${toString cfg.allowInterfaces}"} + + ${cfg.extraConfig} ''; # Hook for emitting ip-up/ip-down events. @@ -80,6 +85,17 @@ in ''; }; + networking.dhcpcd.allowInterfaces = mkOption { + type = types.listOf types.str; + default = []; + description = '' + Enable the DHCP client for any interface whose name matches + any of the shell glob patterns in this list. Any interface not + explicitly matched by this pattern will be denied. This pattern only + applies when the list is non-empty. + ''; + }; + networking.dhcpcd.extraConfig = mkOption { type = types.lines; default = ""; -- cgit 1.4.1 From a269acf48026b439bce217bd5376bca01298fa07 Mon Sep 17 00:00:00 2001 From: "William A. Kennington III" Date: Sat, 12 Jul 2014 16:53:25 -0500 Subject: nixos/dhcpcd: Use null instead of empty list to disable allowInterfaces --- nixos/modules/services/networking/dhcpcd.nix | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'nixos/modules/services/networking/dhcpcd.nix') diff --git a/nixos/modules/services/networking/dhcpcd.nix b/nixos/modules/services/networking/dhcpcd.nix index c541d4fa604..198c8cb08b2 100644 --- a/nixos/modules/services/networking/dhcpcd.nix +++ b/nixos/modules/services/networking/dhcpcd.nix @@ -40,7 +40,7 @@ let denyinterfaces ${toString ignoredInterfaces} lo peth* vif* tap* tun* virbr* vnet* vboxnet* # Use the list of allowed interfaces if specified - ${optionalString (cfg.allowInterfaces != [ ]) "allowinterfaces ${toString cfg.allowInterfaces}"} + ${optionalString (cfg.allowInterfaces != null) "allowinterfaces ${toString cfg.allowInterfaces}"} ${cfg.extraConfig} ''; @@ -86,13 +86,13 @@ in }; networking.dhcpcd.allowInterfaces = mkOption { - type = types.listOf types.str; - default = []; + type = types.nullOr (types.listOf types.str); + default = null; description = '' Enable the DHCP client for any interface whose name matches any of the shell glob patterns in this list. Any interface not explicitly matched by this pattern will be denied. This pattern only - applies when the list is non-empty. + applies when non-null. ''; }; -- cgit 1.4.1