-
-
Notifications
You must be signed in to change notification settings - Fork 17.1k
Description
Describe the bug
I would like to configure a systemd network using an upstream .network unit with a single small modification.
This can be achieved by creating a drop-in .conf file under /etc/systemd/network.
For systemd services, NixOS provides an overrideStrategy option. But there is no corresponding option for systemd.network.{networks,links,netdevs}.
Steps To Reproduce
Currently, to configure a drop-in, we must do:
{
networking.useNetworkd = true;
containers.example = {
privateNetwork = true;
hostAddress = "192.168.55.1";
localAddress = "192.168.55.2";
config = {
networking.useNetworkd = true;
environment.etc."systemd/network/80-container-host0.network.d/overrides.conf".text = ''
[Match]
Name=eth0
'';
};
}
The upstream unit can be found at /run/current-system/sw/lib/systemd/network/80-container-host0.network.
Expected behavior
It would be nicer to be able to configure the drop-in like this:
{
systemd.network.networks."80-container-host0" = {
overrideStrategy = "asDropinIfExists";
matchConfig.Name = "eth0";
};
}
Possible values for overrideStrategy would be the same as for systemd.services.<name>.overrideStrategy, plus another option "replace". This would be the default value, describing the current behaviour where a network unit defined in NixOS will mask the upstream unit from systemd.packages.
Additional context
This is relevant to configuring systemd-networkd inside NixOS containers, because the container network interface name does not match upstream systemd.
Notify maintainers
cc: @Ma27 who has been working on networkd containers (NixOS/rfcs#108).
Metadata
rodney@tethys:~ % nix-info -m
- system: `"x86_64-linux"`
- host os: `Linux 6.8.8, NixOS, 24.05 (Uakari), 24.05.20240502.63c3a29`
- multi-user?: `yes`
- sandbox: `yes`
- version: `nix-env (Nix) 2.18.2`
- nixpkgs: `/nix/store/p69bcs7ma6ijj8v9xsrg3nq3nn8ryn95-source`Add a 👍 reaction to issues you find important.