nixos/network-interfaces: Provide a networkd implementation

This commit is contained in:
William A. Kennington III
2014-11-26 11:22:02 -08:00
parent 045132a9b0
commit 59f512ef7d
7 changed files with 615 additions and 349 deletions
@@ -832,6 +832,30 @@ in rec {
'';
};
name = mkOption {
type = types.nullOr types.str;
default = null;
description = ''
The name of the network interface to match against.
'';
};
DHCP = mkOption {
type = types.nullOr types.str;
default = null;
description = ''
Whether to enable DHCP on the interfaces matched.
'';
};
domains = mkOption {
type = types.nullOr (types.listOf types.str);
default = null;
description = ''
A list of domains to pass to the network config.
'';
};
address = mkOption {
default = [ ];
type = types.listOf types.str;
+14 -1
View File
@@ -300,6 +300,19 @@ let
};
};
networkConfig = { name, config, ... }: {
config = {
matchConfig = optionalAttrs (config.name != null) {
Name = config.name;
};
networkConfig = optionalAttrs (config.DHCP != null) {
DHCP = config.DHCP;
} // optionalAttrs (config.domains != null) {
Domains = concatStringsSep " " config.domains;
};
};
};
toOption = x:
if x == true then "true"
else if x == false then "false"
@@ -693,7 +706,7 @@ in
systemd.network.networks = mkOption {
default = {};
type = types.attrsOf types.optionSet;
options = [ networkOptions ];
options = [ networkOptions networkConfig ];
description = "Definiton of systemd networks.";
};