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

networkmanager: allow iwd as Wi-Fi backend #51803

Closed

Conversation

eliasp
Copy link
Member

@eliasp eliasp commented Dec 9, 2018

Motivation for this change

I wanted to make use of iwd as wireless backend for NetworkManager.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Assured whether relevant documentation is up to date
  • Fits CONTRIBUTING.md.

Couldn't fully test it locally yet due to the number of packages having to be rebuilt in my local KF5/Plasma-based environment.

@flokli
Copy link
Contributor

flokli commented Dec 10, 2018

Really excited to see iwd being used, thanks for your work!

I gave this a try, cherry-picked your commit on top of release-18.09 applied, and tried switching my system to it, Nix complains about wpa_supplicant-nl80211@.service existing twice now:

these derivations will be built:
  /nix/store/jh8hmdmb9ciqjz7675gh22i12qn4q55c-system-units.drv
  /nix/store/mr4nbpkbm1360ly4azxnvsz69qgbxjrw-etc.drv
  /nix/store/w87jzhg454glgmxvv7s8bg8hwj7gzyd1-nixos-system-tp.flokli.de-18.09.git.722868e20caM.drv
building '/nix/store/jh8hmdmb9ciqjz7675gh22i12qn4q55c-system-units.drv'...
ln: failed to create symbolic link '/nix/store/jhv1q8nznmwfyqg2ysjwnxwfy58aj52g-system-units/wpa_supplicant-nl80211@.service': File exists
builder for '/nix/store/jh8hmdmb9ciqjz7675gh22i12qn4q55c-system-units.drv' failed with exit code 1
cannot build derivation '/nix/store/mr4nbpkbm1360ly4azxnvsz69qgbxjrw-etc.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/w87jzhg454glgmxvv7s8bg8hwj7gzyd1-nixos-system-tp.flokli.de-18.09.git.722868e20caM.drv': 1 dependencies couldn't be built
error: build of '/nix/store/w87jzhg454glgmxvv7s8bg8hwj7gzyd1-nixos-system-tp.flokli.de-18.09.git.722868e20caM.drv' failed

reverting your commit gets it to build again, so this gets introduced by your commit :-/

@eliasp
Copy link
Member Author

eliasp commented Dec 10, 2018

This looks like the same collision like the one I'm trying to prevent using the assertion for making sure config.networking.wireless.iwd.enable isn't enabled, just with wpa_supplicant in this case.

Does anyone have an idea how to tackle this properly?

@jtojnar
Copy link
Contributor

jtojnar commented Dec 10, 2018

Duplicate of #48851

@jtojnar jtojnar marked this as a duplicate of #48851 Dec 10, 2018
@flokli
Copy link
Contributor

flokli commented Dec 14, 2018

@eliasp can you look at the linked PR, see if some of your changes need to be incorporated there?

@@ -400,6 +408,12 @@ in {
networking.networkmanager.dns = "dnsmasq"
'';
}
{ assertion = !config.networking.wireless.iwd.enable;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be better to combine this assertion with the first one, since they're both trying to do the same thing albeit for different packages.

Also, if I'm not wrong, using iwd as the backend still requires iwd.service to be started as well?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eadwu How can the service be started? I booted this in a VM and the daemon wasn't started.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since enabling networking.wireless.iwd.enable would trigger the assertion, you can try just manually applying the configuration [1]. I don't know whether or not NetworkManager uses the DBus implementation though.

[1] https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/services/networking/iwd.nix#L18

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not actually 100% sure the assertion should be there in the first place. I'll see if I have time to dig deeper.

@@ -34,6 +34,8 @@ let

[device]
wifi.scan-rand-mac-address=${if cfg.wifi.scanRandMacAddress then "yes" else "no"}
${optionalString (cfg.wifi.backend != null)
''wifi.backend=${cfg.wifi.backend}''}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I can see, backend is never null, so this can be simplified.

@dtzWill dtzWill mentioned this pull request Jan 17, 2019
10 tasks
@nixos-discourse
Copy link

This pull request has been mentioned on Nix community. There might be relevant details there:

https://discourse.nixos.org/t/iwd-service-not-started/2154/2

@Moredread
Copy link
Contributor

Is there a chance to get it merged for 19.03?

Cc @lheckemann @samueldr

@samueldr samueldr added this to the 19.03 milestone Feb 17, 2019
@samueldr
Copy link
Member

@eliasp assuming I'm extremely lazy, is there anything missing, unfinished or unresolved here? At a glance I see change requests are still open.

For those having tested the PR, does it work fine? Anything particular to note?

@nixos-discourse
Copy link

This pull request has been mentioned on Nix community. There might be relevant details there:

https://discourse.nixos.org/t/nixos-19-03-feature-freeze/1950/33

@leotaku
Copy link
Contributor

leotaku commented Feb 25, 2019

@samueldr I have been using this PR on a nixos-unstable-based system for the last 2 days and have found some problems with it:

  1. Networkmanager fails to scan for/connect to any acess points after boot. Restarting the network-manager.service immediately fixes this problem.
  2. Networkmanager starts the iwd.service itself via dbus, however its full name is "net.connman.iwd"
  3. Putting my laptop/machine to sleep causes the network-manager.services to spit out various errors. Reconnecting to any network after wake then also takes much longer than just using iwd without networkmanager.

(1.) should probably be fixably with some systemd trickery
(2.) might not actually be a problem (I just found it strange that networkmanager would start a service with "connman" in its name as they seem to be completly different projects)
(3.) is likely an issue with networkmanagers iwd integration itself, but maybe it is related to how the module configures/starts the service

Please query me for any additional logs/settings/etc. I'd be happy to help.

@asymmetric
Copy link
Contributor

asymmetric commented Feb 25, 2019

I just found it strange that networkmanager would start a service with "connman" in its name as they seem to be completly different projects

This is coming from upstream.

@leotaku
Copy link
Contributor

leotaku commented Feb 25, 2019

@asymmetric I knew the service file was provided by iwd but still found it notable that networkmanager would start a service specifically named "net.connman.iwd".

Are iwd and connman related projects? If so then the "default" service just being named this way would of course make sense.

@asymmetric
Copy link
Contributor

Are iwd and connman related projects? If so then the "default" service just being named this way would of course make sense.

Yes, both are built by Intel.

@lheckemann lheckemann removed this from the 19.03 milestone Feb 25, 2019
@flokli
Copy link
Contributor

flokli commented Mar 9, 2019

Commenting on the confusion about the assertion, but also on the introduced options:

From what I read, networkmanager needs, iwd service to be running when using iwd backend, and wpa_supplicant to be running when using wpa_supplicant backend.

Currently, in the NixOS module system, it's networking.wireless.enable triggering wpa_supplicant to be enabled, and networking.wireless.iwd.enable triggering iwd to be enabled.

This is a bit of a mess, as iwd and wpa_supplicant are mutually exclusive (at least per interface), but the NixOS configuration hierarchy doesn't really reflect that.

Option 1

We might want to either rename the networking.wireless module to networking.wpa_supplicant, as it has a lot of wpa_supplicant specific configuration, and then have the networkmanager module enable either networking.wpa_supplicant or networking.iwd, depending on the selected backend.

Option 2

I also thought about keeping networking.wireless as a generic way of describing wifi networks. (with networking.wireless.enable and networking.wireless.backend options).
This would imply moving most of the wpa_supplicant specific things from networking.wireless to networking.wireless.wpa_supplicant, and keeping parts of networking.wireless.networks.<name>, which will be read by either the iwd or wpa_supplicant module.

However, the iwd config file format doesn't seem to be that well documented, and there's a lot of wpa_supplicant specific code, so I don't really think we can properly add generic support for describing wifi networks.

@teto
Copy link
Member

teto commented May 9, 2019

could you rebase please ? wouldl ike to try as my wifi has gone crazy recently :s

@asymmetric
Copy link
Contributor

FWIW I'm using this without NetworkManager (nor connman), and it works great.

@teto
Copy link
Member

teto commented May 9, 2019

I tried to use iwd as a standalone (well with Network manager in background too) and it crashed.

@asymmetric
Copy link
Contributor

Maybe get rid of/stop NM and try again?

@colemickens
Copy link
Member

I'm using this PR, rebased, to much success. It is incredible how much better (read: faster) this seems to work for me than networkmanager+wpa_supplicant.

@teto
Copy link
Member

teto commented Aug 29, 2019

@colemickens where is the fork ? would like to try again, the wifi experience with networkmanager is not great as far as I am concerned.

@colemickens
Copy link
Member

@teto I'm using it on my fork with my cmpkgs branch, but I pulled off the one rebased commit onto a new branch: https://github.com/colemickens/nixpkgs/commits/nixpkgs-nm-iwd

@dtzWill
Copy link
Member

dtzWill commented Sep 5, 2019

Maybe new PR with that commit, @colemickens?

@eliasp
Copy link
Member Author

eliasp commented Sep 5, 2019

@colemickens Thanks for picking it up, rebasing it etc. - I simply didn't find any time recently to take care of the PR.
Closing this PR in favor of #68147

@eliasp eliasp closed this Sep 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet