Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nixos/networking: add option neededForBoot #360092

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dezren39
Copy link
Contributor

Adds an option neededForBoot which is default set to true (old behavior). If set to false, the network-address-${device} service doesn't set wanted-by and will not block booting if the device is not present.

Fixes #154737
Related #155017

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 25.05 Release Notes (or backporting 24.11 and 25.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

Adds an option neededForBoot which is default set to true (old
behavior). If set to false, the network-address-${device} service
doesn't set wanted-by and will not block booting if the
device is not present.

Fixes NixOS#154737
Related to NixOS#155017

Co-authored-by: Rien Maertens <[email protected]>
Co-authored-by: rnhmjoj <[email protected]>
@github-actions github-actions bot added 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` labels Nov 29, 2024
@rnhmjoj
Copy link
Contributor

rnhmjoj commented Nov 29, 2024

I think the only test to perform here would be: what happens when an interface not-needed-for-boot eventually appears?
The goal is to have network-address-<ifname> start automatically.
If the interface is not virtual (bridge, bond, tun, tap, etc.) network-address-<ifname> should depend on sys-subsystem-net-devices-<ifname>.device, which will be triggered by udev, so theoretically it should work. Otherwise, I'm not sure...

@dezren39
Copy link
Contributor Author

dezren39 commented Nov 29, 2024

I think the only test to perform here would be: what happens when an interface not-needed-for-boot eventually appears? The goal is to have network-address-<ifname> start automatically. If the interface is not virtual (bridge, bond, tun, tap, etc.) network-address-<ifname> should depend on sys-subsystem-net-devices-<ifname>.device, which will be triggered by udev, so theoretically it should work. Otherwise, I'm not sure...

before this pr, when i would wait 90s during each boot if not plugged in, my network adapters only worked if they were already plugged-in at-boot or after a nixos-rebuild switch or if i manually executed sudo systemctl start network-address-<ifname>.

my solution to this was:

services.udev.extraRules = lib.concatMapStrings (interface: ''
  SUBSYSTEM=="net", ACTION=="add|move", NAME=="${interface}", TAG+="systemd", ENV{SYSTEMD_WANTS}="network-addresses-${interface}.service"
'') internalInterfaces;

(

  • internalInterfaces is a list of interface names within my dnsmasq module;
  • also i have networking.usePredictableInterfaceNames = true; in my config.

)
this has been working well for me since then.

i believe if i remove my udev.extraRules, then i wouldn't get a successful connection, but also, at least for me and my usb adapters from amazon, this was already the case before this pr.

i'd be interested in alternatives to test or implement.

@ofborg ofborg bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 1-10 labels Nov 30, 2024
@rnhmjoj
Copy link
Contributor

rnhmjoj commented Dec 1, 2024

@dezren39 Try running this

$ systemctl list-dependencies network-addresses-<ifname> --type device

It should print sys-subsystem-net-devices-<ifname>.device. Can you also check with

$ systemctl status sys-subsystem-net-devices-<ifname>.device

if the device is active (plugged)?

I think that with BindsTo=sys-subsystem-net-devices-<ifname>.device the network-addresses-<ifname> service should be automatically restarted when the device appears, so the udev rules shouldn't be necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 1-10
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support pluggable ethernet devices (avoid "Timed out while waiting for device")
3 participants