From f99bdb2b615da434e0f2814a5924a2aa6a7a1f66 Mon Sep 17 00:00:00 2001 From: Will Dietz Date: Fri, 13 Sep 2019 11:11:53 -0500 Subject: [PATCH] networkmanager,modemmanager: fix service symlinks for systemd v243 Fixes problems such as: systemd[1]: Failed to put bus name to hashmap: File exists systemd[1]: dbus-org.freedesktop.nm-dispatcher.service: Two services allocated for the same bus name org.freedesktop.nm_dispatcher, refusing operation. Problem is that systemd treats symlinks to files outside the service path differently, causing our old workaround to look like two separate services. These symlinks are intended to be a means for manually emulating the behavior of the `Alias=` directive in these services. Unfortunately even making these symlinks relative isn't enough, since they don't make it to where it matters-- that only makes the links in /etc/static/systemd/system/* relative, with systemd still being shown non-relative links in /etc/systemd/system/*. To fix this, drop all of this at the package level and instead simply specify the aliases in the NixOS modules. Also handle the same for modemmanager, since the networkmanager NixOS module also handles that. --- nixos/modules/services/networking/networkmanager.nix | 5 +++++ pkgs/tools/networking/modem-manager/default.nix | 7 ------- pkgs/tools/networking/network-manager/default.nix | 5 ----- 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/nixos/modules/services/networking/networkmanager.nix b/nixos/modules/services/networking/networkmanager.nix index db4d0e328e2d..db047e6d0b89 100644 --- a/nixos/modules/services/networking/networkmanager.nix +++ b/nixos/modules/services/networking/networkmanager.nix @@ -468,12 +468,16 @@ in { mkdir -m 700 -p /etc/ipsec.d mkdir -m 755 -p ${stateDirs} ''; + + aliases = [ "dbus-org.freedesktop.NetworkManager.service" ]; }; systemd.services.NetworkManager-wait-online = { wantedBy = [ "network-online.target" ]; }; + systemd.services.ModemManager.aliases = [ "dbus-org.freedesktop.ModemManager1.service" ]; + systemd.services.nm-setup-hostsdirs = mkIf dynamicHostsEnabled { wantedBy = [ "NetworkManager.service" ]; before = [ "NetworkManager.service" ]; @@ -495,6 +499,7 @@ in { # useful binaries for user-specified hooks path = [ pkgs.iproute pkgs.utillinux pkgs.coreutils ]; + aliases = [ "dbus-org.freedesktop.nm-dispatcher.service" ]; }; # Turn off NixOS' network management when networking is managed entirely by NetworkManager diff --git a/pkgs/tools/networking/modem-manager/default.nix b/pkgs/tools/networking/modem-manager/default.nix index b2644d0c2a49..fedc8d4b71d7 100644 --- a/pkgs/tools/networking/modem-manager/default.nix +++ b/pkgs/tools/networking/modem-manager/default.nix @@ -32,13 +32,6 @@ stdenv.mkDerivation rec { doCheck = true; - postInstall = '' - # systemd in NixOS doesn't use `systemctl enable`, so we need to establish - # aliases ourselves. - ln -s $out/etc/systemd/system/ModemManager.service \ - $out/etc/systemd/system/dbus-org.freedesktop.ModemManager1.service - ''; - meta = with stdenv.lib; { description = "WWAN modem manager, part of NetworkManager"; homepage = https://www.freedesktop.org/wiki/Software/ModemManager/; diff --git a/pkgs/tools/networking/network-manager/default.nix b/pkgs/tools/networking/network-manager/default.nix index 5bc915caea65..490ebd0fa6bb 100644 --- a/pkgs/tools/networking/network-manager/default.nix +++ b/pkgs/tools/networking/network-manager/default.nix @@ -97,11 +97,6 @@ in stdenv.mkDerivation rec { ''; postInstall = '' - # systemd in NixOS doesn't use `systemctl enable`, so we need to establish - # 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