networkmanager: install parallel dbus .conf files to allow the services to be run as *either* networkmanager or root user (hopefully!)

This commit is contained in:
Colin 2024-05-31 11:41:24 +00:00
parent 9bb6a903bb
commit a1181a10ea
3 changed files with 25 additions and 8 deletions

View File

@ -4,6 +4,12 @@ let
in
{
sane.programs.modemmanager = {
packageUnwrapped = pkgs.modemmanager.overrideAttrs (upstream: {
postInstall = (upstream.postInstall or "") + ''
sed 's/"root"/"networkmanager"/g' $out/share/dbus-1/system.d/org.freedesktop.ModemManager1.conf \
> $out/share/dbus-1/system.d/networkmanager-org.freedesktop.ModemManager1.conf
'';
});
# mmcli needs /run/current-system/sw/share/dbus-1 files to function
enableFor.system = lib.mkIf (builtins.any (en: en) (builtins.attrValues cfg.enableFor.user)) true;

View File

@ -17,8 +17,15 @@ in
# substituteInPlace src/{core/org.freedesktop.NetworkManager,nm-dispatcher/nm-dispatcher}.conf --replace-fail \
# 'user="root"' 'user="networkmanager"'
# '';
# remove unused services to prevent any unexpected interactions
postInstall = (upstream.postInstall or "") + ''
# allow the bus to owned by either root or networkmanager users
for f in org.freedesktop.NetworkManager.conf nm-dispatcher.conf ; do
sed 's/"root"/"networkmanager"/g' $out/share/dbus-1/system.d/$f \
> $out/share/dbus-1/system.d/networkmanager-$f
done
'';
postFixup = (upstream.postFixup or "") + ''
# remove unused services to prevent any unexpected interactions
rm $out/etc/systemd/system/{nm-cloud-setup.service,nm-cloud-setup.timer,nm-priv-helper.service}
'';
});

View File

@ -11,15 +11,19 @@ in
# substituteInPlace wpa_supplicant/dbus/dbus-wpa_supplicant.conf --replace-fail \
# 'user="root"' 'user="networkmanager"'
# '';
# nixpkgs wpa_supplicant generates a dbus file which has a path like
# /nix/store/abc-wpa_supplicant/nix/store/abc-wpa_supplicant/sbin/...
# upstreaming status: <https://github.com/NixOS/nixpkgs/pull/315346>
postInstall = upstream.postInstall + ''
postInstall = (upstream.postInstall or "") + ''
sed 's/"root"/"networkmanager"/g' $out/share/dbus-1/system.d/dbus-wpa_supplicant.conf \
> $out/share/dbus-1/system.d/networkmanager-wpa_supplicant.conf
'';
postFixup = (upstream.postFixup or "") + ''
# nixpkgs wpa_supplicant generates a dbus file which has a path like
# /nix/store/abc-wpa_supplicant/nix/store/abc-wpa_supplicant/sbin/...
# upstreaming status: <https://github.com/NixOS/nixpkgs/pull/315346>
substituteInPlace $out/share/dbus-1/system-services/* --replace-fail \
"$out$out" "$out"
''
# remove unused services to avoid unexpected interactions
+ ''
# remove unused services to avoid unexpected interactions
rm $out/etc/systemd/system/{wpa_supplicant-nl80211@,wpa_supplicant-wired@,wpa_supplicant@}.service
'';
});