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: rename service to match upstream #51382

Merged
merged 3 commits into from
Mar 19, 2019

Conversation

Mic92
Copy link
Member

@Mic92 Mic92 commented Dec 2, 2018

Motivation for this change

Compatibility with other distributions/software and expectation
of users coming from other systems should have higher priority over consistency.
In particular this fixes #51375, where the NetworkManager-wait-online.service
broke as a result of this.

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.

@Mic92 Mic92 requested a review from infinisil as a code owner December 2, 2018 12:24
@Mic92 Mic92 requested a review from jtojnar December 2, 2018 12:24
@GrahamcOfBorg GrahamcOfBorg added 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: changelog 8.has: documentation This PR adds or changes documentation 8.has: module (update) This PR changes an existing module in `nixos/` labels Dec 2, 2018
@Mic92 Mic92 changed the title Networkmanager: rename service to match upstream [WIP] Networkmanager: rename service to match upstream Dec 2, 2018
@Mic92
Copy link
Member Author

Mic92 commented Dec 2, 2018

There is one blocker though. When doing the upgrade it did not start NetworkManager again for automatically. Does anybody know why?

@GrahamcOfBorg GrahamcOfBorg added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 501+ labels Dec 2, 2018
@jtojnar
Copy link
Member

jtojnar commented Dec 2, 2018

Try

--- a/pkgs/tools/networking/modem-manager/default.nix
+++ b/pkgs/tools/networking/modem-manager/default.nix
@@ -27,30 +27,16 @@
     "--with-polkit"
     "--with-udev-base-dir=$(out)/lib/udev"
     "--with-systemdsystemunitdir=$(out)/etc/systemd/system"
+    "--with-dbus-sys-dir=$(out)/etc/dbus-1/system.d"
     "--sysconfdir=/etc"
     "--localstatedir=/var"
     "--with-suspend-resume=systemd"
   ];
 
-  installFlags = [ "DESTDIR=\${out}" ];
-
-  preInstall = ''
-    mkdir -p $out/etc/systemd/system
-  '';
-
   postInstall = ''
-    # rename to modem-manager to be in style
-    mv $out/$out/etc/systemd/system/ModemManager.service $out/etc/systemd/system/modem-manager.service
-    rm -rf $out/$out/etc
-    mv $out/$out/* $out
-    DIR=$out/$out
-    while rmdir $DIR 2>/dev/null; do
-      DIR="$(dirname "$DIR")"
-    done
-
     # systemd in NixOS doesn't use `systemctl enable`, so we need to establish
     # aliases ourselves.
-    ln -s $out/etc/systemd/system/modem-manager.service \
+    ln -s $out/etc/systemd/system/ModemManager.service \
       $out/etc/systemd/system/dbus-org.freedesktop.ModemManager1.service
   '';
 

@Mic92
Copy link
Member Author

Mic92 commented Dec 2, 2018

Applied. This probably fixes also some references in modemmanager.

@jtojnar
Copy link
Member

jtojnar commented Jan 3, 2019

Would keeping the legacy service name fix the transition issue? ln -s $out/etc/systemd/system/NetworkManager.service $out/etc/systemd/system/network-manager.service

Anyway, even if this does not work, I would just merge this. It is not that bad.

@Legogris
Copy link

Legogris commented Jan 8, 2019

@jtojnar

Would keeping the legacy service name fix the transition issue? ln -s $out/etc/systemd/system/NetworkManager.service $out/etc/systemd/system/network-manager.service

That sounds prudent to me, considering people might have started depending on the naming we are now reverting.

@jtojnar
Copy link
Member

jtojnar commented Mar 18, 2019

There is one blocker though. When doing the upgrade it did not start NetworkManager again for automatically. Does anybody know why?

I would say this is reasonable price to pay. User can always restart the service manually.

@flokli
Copy link
Contributor

flokli commented Mar 19, 2019

I gave @jtojnar's suggestion a try - adding the following patch:

From a201d69a825668570fbe0dc1837c229c6e70319a Mon Sep 17 00:00:00 2001
From: Florian Klink <flokli@flokli.de>
Date: Tue, 19 Mar 2019 01:54:27 +0100
Subject: [PATCH] network-manager: add legacy service name to prevent
 NetworkManager from not starting back up

This can be removed once 19.10 is released.
---
 pkgs/tools/networking/network-manager/default.nix | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/pkgs/tools/networking/network-manager/default.nix b/pkgs/tools/networking/network-manager/default.nix
index 3df029310fe..9d1ff4bb8c9 100644
--- a/pkgs/tools/networking/network-manager/default.nix
+++ b/pkgs/tools/networking/network-manager/default.nix
@@ -92,6 +92,11 @@ in stdenv.mkDerivation rec {
     # aliases ourselves.
     ln -s $out/etc/systemd/system/NetworkManager-dispatcher.service $out/etc/systemd/system/dbus-org.freedesktop.nm-dispatcher.service
     ln -s $out/etc/systemd/system/NetworkManager.service $out/etc/systemd/system/dbus-org.freedesktop.NetworkManager.service
+
+    # Add the legacy service name from before #51382 to prevent NetworkManager
+    # from not starting back up:
+    # TODO: remove this once 19.10 is released
+    ln -s $out/etc/systemd/system/NetworkManager.service $out/etc/systemd/system/network-manager.service
   '';
 
   passthru = {
-- 
2.19.2

And I was able to switch to the new configuration with NetworkManager restarting properly:

stopping the following units: accounts-daemon.service, bolt.service, fwupd.service, home-manager-flokli.service, network-manager.service, systemd-udevd-control.socket, systemd-udevd-kernel.socket, systemd-udevd.service, tlp.service
NOT restarting the following changed units: systemd-fsck@dev-disk-by\x2duuid-XXXX\x2dXXXX.service
activating the configuration...
setting up /etc...
reloading user units for flokli...
setting up tmpfiles
reloading the following units: dbus.service
restarting the following units: polkit.service
starting the following units: accounts-daemon.service, bolt.service, fwupd.service, home-manager-flokli.service, network-manager.service, systemd-udevd-control.socket, systemd-udevd-kernel.socket, tlp.service
the following new units were started: NetworkManager-dispatcher.service, NetworkManager.service, systemd-hostnamed.service

@jtojnar jtojnar changed the base branch from master to staging March 19, 2019 22:32
@GrahamcOfBorg GrahamcOfBorg added the 2.status: merge conflict This PR has merge conflicts with the target branch label Mar 19, 2019
Mic92 added 2 commits March 19, 2019 23:48
Compatibility with other distributions/software and expectation
of users coming from other systems should have higher priority over consistency.
In particular this fixes NixOS#51375, where the NetworkManager-wait-online.service
broke as a result of this.
@flokli
Copy link
Contributor

flokli commented Mar 19, 2019

rebased on staging, fixed merge commits and applied the patch from #51382 (comment) (with a slight change in the commit message)

Copy link
Member

@jtojnar jtojnar left a comment

Choose a reason for hiding this comment

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

LGTM

@worldofpeace worldofpeace changed the title [WIP] Networkmanager: rename service to match upstream Networkmanager: rename service to match upstream Mar 19, 2019
@GrahamcOfBorg GrahamcOfBorg removed the 2.status: merge conflict This PR has merge conflicts with the target branch label Mar 19, 2019
This prevents NetworkManager from not starting back up while switching
configurations.

This can be removed once 19.10 is released.
Copy link
Contributor

@worldofpeace worldofpeace left a comment

Choose a reason for hiding this comment

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

Looks good, we should get this in.
Think it has been sufficiently tested.

@flokli
Copy link
Contributor

flokli commented Mar 19, 2019

Well, then I'll be the one pushing the button :-)

@flokli flokli merged commit 6a8bc28 into NixOS:staging Mar 19, 2019
@Mic92 Mic92 deleted the network-manager branch March 20, 2019 10:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.status: work-in-progress This PR isn't done 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: changelog 8.has: documentation This PR adds or changes documentation 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: 501-1000 10.rebuild-linux: 501+
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants