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;
{
let
networkD = config.machine.networkD;
in{
networking = {
hostName = config.machine.hostName;
useNetworkd = config.machine.useNetworkd;
useDHCP = !config.machine.useNetworkd;
dhcpcd.enable = !config.machine.useNetworkd;
useNetworkd = networkD.enable;
useDHCP = !networkD.enable;
dhcpcd.enable = !networkD.enable;
};
# Based on
# https://github.com/NixOS/nixpkgs/issues/10001#issuecomment-905532069
systemd.network = mkIf config.machine.useNetworkd {
systemd.network = mkIf networkD.enable {
enable = true;
networks = let
networkConfig = {
@ -33,10 +35,30 @@ with lib;
dhcpV4Config.RouteMetric = 1024;
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
systemd.services."systemd-networkd-wait-online".serviceConfig.ExecStart = [
"" "${config.systemd.package}/lib/systemd/systemd-networkd-wait-online --any"
];
systemd.services."systemd-networkd-wait-online" = {
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 = {
allowUnfree = true;
hostName = "Lilim";
useNetworkd = true;
networkD = {
enable = true;
waitOnline = false;
};
administrators = [ { name = "derped"; id = 1337; } ];
conffiles = [
"etcfiles"

View file

@ -59,12 +59,21 @@ in {
The Machines HostName
'';
};
useNetworkd = mkOption {
type = types.bool;
default = false;
description = ''
Disables dhcpcd and enables networkd.
'';
networkD = {
enable = mkOption {
type = types.bool;
default = false;
description = ''
Disables dhcpcd and enables networkd.
'';
};
waitOnline = mkOption {
type = types.bool;
default = true;
description = ''
Enables/disables systemd-networkd-wait-online service.
'';
};
};
binaryCaches = mkOption {
type = types.listOf types.str;