refactor: networkmanager: use substitute instead of sed when patching

This commit is contained in:
2024-06-01 22:16:18 +00:00
parent 62dbad3486
commit 30d41f82f2
3 changed files with 16 additions and 11 deletions

View File

@@ -5,14 +5,15 @@ in
{ {
sane.programs.modemmanager = { sane.programs.modemmanager = {
packageUnwrapped = pkgs.modemmanager-split.daemon.overrideAttrs (upstream: { packageUnwrapped = pkgs.modemmanager-split.daemon.overrideAttrs (upstream: {
postInstall = (upstream.postInstall or "") + '' postInstall = (upstream.postInstall or "") + ''
sed 's/"root"/"networkmanager"/g' $out/share/dbus-1/system.d/org.freedesktop.ModemManager1.conf \ substitute $out/share/dbus-1/system.d/org.freedesktop.ModemManager1.conf \
> $out/share/dbus-1/system.d/networkmanager-org.freedesktop.ModemManager1.conf $out/share/dbus-1/system.d/networkmanager-org.freedesktop.ModemManager1.conf \
''; --replace-fail 'user="root"' 'group="networkmanager"'
'';
meta = upstream.meta // { meta = upstream.meta // {
mainProgram = "ModemManager"; mainProgram = "ModemManager";
}; };
}); });
# mmcli needs /run/current-system/sw/share/dbus-1 files to function # 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; enableFor.system = lib.mkIf (builtins.any (en: en) (builtins.attrValues cfg.enableFor.user)) true;

View File

@@ -19,9 +19,12 @@ in
# ''; # '';
postInstall = (upstream.postInstall or "") + '' postInstall = (upstream.postInstall or "") + ''
# allow the bus to owned by either root or networkmanager users # allow the bus to owned by either root or networkmanager users
# use the group here, that way ordinary users can be elevated to control networkmanager
# (via e.g. `nmcli`)
for f in org.freedesktop.NetworkManager.conf nm-dispatcher.conf ; do for f in org.freedesktop.NetworkManager.conf nm-dispatcher.conf ; do
sed 's/"root"/"networkmanager"/g' $out/share/dbus-1/system.d/$f \ substitute $out/share/dbus-1/system.d/$f \
> $out/share/dbus-1/system.d/networkmanager-$f $out/share/dbus-1/system.d/networkmanager-$f \
--replace-fail 'user="root"' 'group="networkmanager"'
done done
# remove unused services to prevent any unexpected interactions # remove unused services to prevent any unexpected interactions

View File

@@ -12,8 +12,9 @@ in
# 'user="root"' 'user="networkmanager"' # 'user="root"' 'user="networkmanager"'
# ''; # '';
postInstall = (upstream.postInstall or "") + '' postInstall = (upstream.postInstall or "") + ''
sed 's/"root"/"networkmanager"/g' $out/share/dbus-1/system.d/dbus-wpa_supplicant.conf \ substitute $out/share/dbus-1/system.d/dbus-wpa_supplicant.conf \
> $out/share/dbus-1/system.d/networkmanager-wpa_supplicant.conf $out/share/dbus-1/system.d/networkmanager-wpa_supplicant.conf \
--replace-fail 'user="root"' 'group="networkmanager"'
''; '';
postFixup = (upstream.postFixup or "") + '' postFixup = (upstream.postFixup or "") + ''