Rename useNetworkd to networkD.enable, add waitOnline option.

This commit is contained in:
Kevin Baensch 2023-08-26 08:02:47 +02:00
parent afbab36559
commit 09df9f171a
Signed by: derped
GPG key ID: C0F1D326C7626543
3 changed files with 49 additions and 15 deletions

View file

@ -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" = {
"" "${config.systemd.package}/lib/systemd/systemd-networkd-wait-online --any" enable = mkForce networkD.waitOnline;
]; serviceConfig.ExecStart = [
"" "${config.systemd.package}/lib/systemd/systemd-networkd-wait-online --any"
];
};
} }

View file

@ -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"

View file

@ -59,12 +59,21 @@ in {
The Machines HostName The Machines HostName
''; '';
}; };
useNetworkd = mkOption { networkD = {
type = types.bool; enable = mkOption {
default = false; type = types.bool;
description = '' default = false;
Disables dhcpcd and enables networkd. description = ''
''; 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;