Rename useNetworkd to networkD.enable, add waitOnline option.
This commit is contained in:
parent
afbab36559
commit
09df9f171a
3 changed files with 49 additions and 15 deletions
|
@ -2,16 +2,18 @@
|
||||||
|
|
||||||
with lib;
|
with lib;
|
||||||
|
|
||||||
{
|
let
|
||||||
|
networkD = config.machine.networkD;
|
||||||
|
in{
|
||||||
networking = {
|
networking = {
|
||||||
hostName = config.machine.hostName;
|
hostName = config.machine.hostName;
|
||||||
useNetworkd = config.machine.useNetworkd;
|
useNetworkd = networkD.enable;
|
||||||
useDHCP = !config.machine.useNetworkd;
|
useDHCP = !networkD.enable;
|
||||||
dhcpcd.enable = !config.machine.useNetworkd;
|
dhcpcd.enable = !networkD.enable;
|
||||||
};
|
};
|
||||||
# Based on
|
# Based on
|
||||||
# https://github.com/NixOS/nixpkgs/issues/10001#issuecomment-905532069
|
# https://github.com/NixOS/nixpkgs/issues/10001#issuecomment-905532069
|
||||||
systemd.network = mkIf config.machine.useNetworkd {
|
systemd.network = mkIf networkD.enable {
|
||||||
enable = true;
|
enable = true;
|
||||||
networks = let
|
networks = let
|
||||||
networkConfig = {
|
networkConfig = {
|
||||||
|
@ -33,10 +35,30 @@ with lib;
|
||||||
dhcpV4Config.RouteMetric = 1024;
|
dhcpV4Config.RouteMetric = 1024;
|
||||||
inherit networkConfig;
|
inherit networkConfig;
|
||||||
};
|
};
|
||||||
|
"50-vlan" = {
|
||||||
|
enable = true;
|
||||||
|
matchConfig = {
|
||||||
|
Name = "br0";
|
||||||
|
};
|
||||||
|
networkConfig = {
|
||||||
|
DNS = "10.0.0.1";
|
||||||
|
Address = "10.0.0.100/16";
|
||||||
|
# DHCPServer = true;
|
||||||
|
# IPMasquerade = true;
|
||||||
|
};
|
||||||
|
# dhcpServerConfig = {
|
||||||
|
# ServerAddress = "172.16.9.1/12";
|
||||||
|
# PoolOffset = 100;
|
||||||
|
# EmitDNS = false;
|
||||||
|
# };
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
# Wait for any interface to become available, not for all
|
# Wait for any interface to become available, not for all
|
||||||
systemd.services."systemd-networkd-wait-online".serviceConfig.ExecStart = [
|
systemd.services."systemd-networkd-wait-online" = {
|
||||||
|
enable = mkForce networkD.waitOnline;
|
||||||
|
serviceConfig.ExecStart = [
|
||||||
"" "${config.systemd.package}/lib/systemd/systemd-networkd-wait-online --any"
|
"" "${config.systemd.package}/lib/systemd/systemd-networkd-wait-online --any"
|
||||||
];
|
];
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,10 @@ with lib;
|
||||||
config.machine = {
|
config.machine = {
|
||||||
allowUnfree = true;
|
allowUnfree = true;
|
||||||
hostName = "Lilim";
|
hostName = "Lilim";
|
||||||
useNetworkd = true;
|
networkD = {
|
||||||
|
enable = true;
|
||||||
|
waitOnline = false;
|
||||||
|
};
|
||||||
administrators = [ { name = "derped"; id = 1337; } ];
|
administrators = [ { name = "derped"; id = 1337; } ];
|
||||||
conffiles = [
|
conffiles = [
|
||||||
"etcfiles"
|
"etcfiles"
|
||||||
|
|
|
@ -59,13 +59,22 @@ in {
|
||||||
The Machines HostName
|
The Machines HostName
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
useNetworkd = mkOption {
|
networkD = {
|
||||||
|
enable = mkOption {
|
||||||
type = types.bool;
|
type = types.bool;
|
||||||
default = false;
|
default = false;
|
||||||
description = ''
|
description = ''
|
||||||
Disables dhcpcd and enables networkd.
|
Disables dhcpcd and enables networkd.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
waitOnline = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
default = true;
|
||||||
|
description = ''
|
||||||
|
Enables/disables systemd-networkd-wait-online service.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
binaryCaches = mkOption {
|
binaryCaches = mkOption {
|
||||||
type = types.listOf types.str;
|
type = types.listOf types.str;
|
||||||
default = [];
|
default = [];
|
||||||
|
|
Loading…
Reference in a new issue