mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-25 00:12:56 +00:00
Merge pull request #82941 from flokli/systemd-network-link-no-networkd-without-lib-pushdown
nixos/systemd: apply .link even when networkd is disabled (without the lib refactor this time)
This commit is contained in:
commit
7f0a2998ef
@ -767,7 +767,15 @@ auth required pam_succeed_if.so uid >= 1000 quiet
|
||||
</para></listitem>
|
||||
</itemizedlist>
|
||||
</para>
|
||||
</listitem>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
The <link linkend="opt-systemd.network.links">systemd.network.links</link> option is now respected
|
||||
even when <link linkend="opt-systemd.network.enable">systemd-networkd</command> is disabled.
|
||||
This mirrors the behaviour of systemd - It's udev that parses <literal>.link</literal> files,
|
||||
not <command>systemd-networkd</command>.
|
||||
</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</section>
|
||||
</section>
|
||||
|
@ -69,13 +69,14 @@ in
|
||||
environment.systemPackages = [ cfg.package ];
|
||||
|
||||
# Prevent systemd from potentially changing the MAC address
|
||||
environment.etc."systemd/network/50-zerotier.link".text = ''
|
||||
[Match]
|
||||
OriginalName=zt*
|
||||
|
||||
[Link]
|
||||
AutoNegotiation=false
|
||||
MACAddressPolicy=none
|
||||
'';
|
||||
systemd.network.links."50-zerotier" = {
|
||||
matchConfig = {
|
||||
OriginalName = "zt*";
|
||||
};
|
||||
linkConfig = {
|
||||
AutoNegotiation = false;
|
||||
MACAddressPolicy = "none";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
@ -355,6 +355,14 @@ let
|
||||
};
|
||||
|
||||
linkOptions = commonNetworkOptions // {
|
||||
# overwrite enable option from above
|
||||
enable = mkOption {
|
||||
default = true;
|
||||
type = types.bool;
|
||||
description = ''
|
||||
Whether to enable this .link unit. It's handled by udev no matter if <command>systemd-networkd</command> is enabled or not
|
||||
'';
|
||||
};
|
||||
|
||||
linkConfig = mkOption {
|
||||
default = {};
|
||||
@ -1045,44 +1053,49 @@ in
|
||||
|
||||
};
|
||||
|
||||
config = mkIf config.systemd.network.enable {
|
||||
config = mkMerge [
|
||||
# .link units are honored by udev, no matter if systemd-networkd is enabled or not.
|
||||
{
|
||||
systemd.network.units = mapAttrs' (n: v: nameValuePair "${n}.link" (linkToUnit n v)) cfg.links;
|
||||
environment.etc = unitFiles;
|
||||
}
|
||||
|
||||
users.users.systemd-network.group = "systemd-network";
|
||||
(mkIf config.systemd.network.enable {
|
||||
|
||||
systemd.additionalUpstreamSystemUnits = [
|
||||
"systemd-networkd.service" "systemd-networkd-wait-online.service"
|
||||
];
|
||||
users.users.systemd-network.group = "systemd-network";
|
||||
|
||||
systemd.network.units = mapAttrs' (n: v: nameValuePair "${n}.link" (linkToUnit n v)) cfg.links
|
||||
// mapAttrs' (n: v: nameValuePair "${n}.netdev" (netdevToUnit n v)) cfg.netdevs
|
||||
// mapAttrs' (n: v: nameValuePair "${n}.network" (networkToUnit n v)) cfg.networks;
|
||||
systemd.additionalUpstreamSystemUnits = [
|
||||
"systemd-networkd.service" "systemd-networkd-wait-online.service"
|
||||
];
|
||||
|
||||
environment.etc = unitFiles;
|
||||
systemd.network.units = mapAttrs' (n: v: nameValuePair "${n}.netdev" (netdevToUnit n v)) cfg.netdevs
|
||||
// mapAttrs' (n: v: nameValuePair "${n}.network" (networkToUnit n v)) cfg.networks;
|
||||
|
||||
systemd.services.systemd-networkd = {
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
restartTriggers = attrNames unitFiles;
|
||||
# prevent race condition with interface renaming (#39069)
|
||||
requires = [ "systemd-udev-settle.service" ];
|
||||
after = [ "systemd-udev-settle.service" ];
|
||||
};
|
||||
|
||||
systemd.services.systemd-networkd-wait-online = {
|
||||
wantedBy = [ "network-online.target" ];
|
||||
};
|
||||
|
||||
systemd.services."systemd-network-wait-online@" = {
|
||||
description = "Wait for Network Interface %I to be Configured";
|
||||
conflicts = [ "shutdown.target" ];
|
||||
requisite = [ "systemd-networkd.service" ];
|
||||
after = [ "systemd-networkd.service" ];
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
RemainAfterExit = true;
|
||||
ExecStart = "${config.systemd.package}/lib/systemd/systemd-networkd-wait-online -i %I";
|
||||
systemd.services.systemd-networkd = {
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
restartTriggers = attrNames unitFiles;
|
||||
# prevent race condition with interface renaming (#39069)
|
||||
requires = [ "systemd-udev-settle.service" ];
|
||||
after = [ "systemd-udev-settle.service" ];
|
||||
};
|
||||
};
|
||||
|
||||
services.resolved.enable = mkDefault true;
|
||||
};
|
||||
systemd.services.systemd-networkd-wait-online = {
|
||||
wantedBy = [ "network-online.target" ];
|
||||
};
|
||||
|
||||
systemd.services."systemd-network-wait-online@" = {
|
||||
description = "Wait for Network Interface %I to be Configured";
|
||||
conflicts = [ "shutdown.target" ];
|
||||
requisite = [ "systemd-networkd.service" ];
|
||||
after = [ "systemd-networkd.service" ];
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
RemainAfterExit = true;
|
||||
ExecStart = "${config.systemd.package}/lib/systemd/systemd-networkd-wait-online -i %I";
|
||||
};
|
||||
};
|
||||
|
||||
services.resolved.enable = mkDefault true;
|
||||
})
|
||||
];
|
||||
}
|
||||
|
@ -655,6 +655,31 @@ let
|
||||
), "The IPv6 routing table has not been properly cleaned:\n{}".format(ipv6Residue)
|
||||
'';
|
||||
};
|
||||
# even with disabled networkd, systemd.network.links should work
|
||||
# (as it's handled by udev, not networkd)
|
||||
link = {
|
||||
name = "Link";
|
||||
nodes.client = { pkgs, ... }: {
|
||||
virtualisation.vlans = [ 1 ];
|
||||
networking = {
|
||||
useNetworkd = networkd;
|
||||
useDHCP = false;
|
||||
};
|
||||
systemd.network.links."50-foo" = {
|
||||
matchConfig = {
|
||||
Name = "foo";
|
||||
Driver = "dummy";
|
||||
};
|
||||
linkConfig.MTUBytes = "1442";
|
||||
};
|
||||
};
|
||||
testScript = ''
|
||||
print(client.succeed("ip l add name foo type dummy"))
|
||||
print(client.succeed("stat /etc/systemd/network/50-foo.link"))
|
||||
client.succeed("udevadm settle")
|
||||
assert "mtu 1442" in client.succeed("ip l show dummy0")
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
in mapAttrs (const (attrs: makeTest (attrs // {
|
||||
|
Loading…
Reference in New Issue
Block a user