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

nixos/dbus: support dbus-broker #122547

Merged
merged 1 commit into from
Nov 22, 2022
Merged

nixos/dbus: support dbus-broker #122547

merged 1 commit into from
Nov 22, 2022

Conversation

xaverdh
Copy link
Contributor

@xaverdh xaverdh commented May 11, 2021

Motivation for this change

picking up #112879

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • 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 nixpkgs-review --run "nixpkgs-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)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

@github-actions github-actions bot added 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` labels May 11, 2021
@ofborg ofborg bot requested a review from peterhoeg May 11, 2021 08:17
@ofborg ofborg bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 1-10 labels May 11, 2021
@xaverdh xaverdh mentioned this pull request May 11, 2021
10 tasks
@xaverdh
Copy link
Contributor Author

xaverdh commented May 12, 2021

So I am running this on my system now. If people want to try it out, feel free :)

@ilya-fedin since you have written your own module, is something important missing from this pr / do you have suggestions?

@ilya-fedin
Copy link
Contributor

since you have written your own module, is something important missing from this pr / do you have suggestions?

I don't think so, my module feels like a hack comparing to that one :)
https://github.com/ilya-fedin/nur-repository/blob/master/modules/dbus-broker/default.nix

@xaverdh
Copy link
Contributor Author

xaverdh commented May 12, 2021

Ok, so I ran a few tests on branch which defaults to the broker imp. (on top of this).
Xfce and Gnome seem to pass, Plasma currently hangs so probably needs some work.

@etircopyh
Copy link

@xaverdh how's it going?

@stale
Copy link

stale bot commented Apr 19, 2022

I marked this as stale due to inactivity. → More info

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Apr 19, 2022
@06kellyjac
Copy link
Member

I think this is still important

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Apr 19, 2022
@06kellyjac
Copy link
Member

is there a reason this is draft? After conflicts are resolved would this be good to go?

@xaverdh
Copy link
Contributor Author

xaverdh commented May 13, 2022

The plasma5-systemd-start test now succeeds on this branch on top of #172845. Maybe we can make this available as an experimental option soon.

@ashkitten
Copy link
Contributor

this module doesn't add pkgs.dbus to environment.systemPackages like services.dbus.enable does, which makes dunstctl not work since it uses dbus-send

@ilya-fedin
Copy link
Contributor

Maybe dunstctl should be fixed then? Personally I don't use dbus-send and I absolutely don't need anything other than libdbus for applications.

@ashkitten
Copy link
Contributor

you're right, it should be added to dunst's dependencies. my intention was to bring awareness to the fact that this is a breaking change in behavior between services.dbus and services.dbus-broker.

@ashkitten
Copy link
Contributor

while updating my system with this, it stopped dbus-broker.service which broke a whole bunch of things. i think even though dbus.service is set to be reloaded instead of restarted, dbus-broker.service is not (even though it's aliased to dbus.service)

@xaverdh
Copy link
Contributor Author

xaverdh commented May 15, 2022

while updating my system with this, it stopped dbus-broker.service which broke a whole bunch of things. i think even though dbus.service is set to be reloaded instead of restarted, dbus-broker.service is not (even though it's aliased to dbus.service)

Indeed. Not sure why reloadIfChanged is not respected here..

@xaverdh
Copy link
Contributor Author

xaverdh commented May 15, 2022

Even if I explicitly add X-ReloadIfChanged to the service config of both (dbus and dbus-broker service files) it is still restartet..

cc @flokli might know what is happening here?

@xaverdh
Copy link
Contributor Author

xaverdh commented May 15, 2022

Maybe we should just use reloadTriggers instead of restartTriggers + reloadIfChanged? seems like the proper thing to do..
But I do wonder why it works on master and what makes it no longer work here.

@peterhoeg peterhoeg mentioned this pull request Aug 8, 2022
13 tasks
@xaverdh
Copy link
Contributor Author

xaverdh commented Sep 19, 2022

while updating my system with this, it stopped dbus-broker.service which broke a whole bunch of things. i think even though dbus.service is set to be reloaded instead of restarted, dbus-broker.service is not (even though it's aliased to dbus.service)

Can you check, if this is still the case?
I came back to this after a while and it worked on my system now..

@xaverdh xaverdh force-pushed the dbus-broker branch 2 times, most recently from b1303ae to 00952f4 Compare September 19, 2022 14:17
@xaverdh
Copy link
Contributor Author

xaverdh commented Nov 5, 2022

But its not systemd that handles restarting / reloading in this case, but switch-to-configuration.pl. As I understand it, it looks for X-ReloadIfChanged and if that is set on the unit reloads it instead of restarting. Now if that is set on the alias unit instead of the unit proper, it will erroneously restart it.

@xaverdh
Copy link
Contributor Author

xaverdh commented Nov 5, 2022

Ok, maybe I misstated it above. Its not so much about X-Restart-Triggers, but rather about what happens when the switch-to-configuration logic decides that dbus-broker should be restarted.

@xaverdh
Copy link
Contributor Author

xaverdh commented Nov 5, 2022

This makes me think, we probably should set reloadIfChanged on the dbus unit, even when using the broker implementation..

@m-bdf
Copy link
Contributor

m-bdf commented Nov 5, 2022

Ok, maybe I misstated it above. Its not so much about X-Restart-Triggers, but rather about what happens when the switch-to-configuration logic decides that dbus-broker should be restarted.

ahh gotcha!

This makes me think, we probably should set reloadIfChanged on the dbus unit, even when using the broker implementation..

Agreed then, that sounds reasonable

@xaverdh
Copy link
Contributor Author

xaverdh commented Nov 8, 2022

Ok, so I set reloadIfChanged on the dbus alias as well, just to be sure.

@PedroHLC PedroHLC requested a review from m-bdf November 8, 2022 14:44
Copy link
Contributor

@m-bdf m-bdf left a comment

Choose a reason for hiding this comment

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

After a bit of testing, LGTM

Copy link
Member

@lilyinstarlight lilyinstarlight left a comment

Choose a reason for hiding this comment

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

I've been running this full-time on my laptop for a while now and after the reloadIfChanged issue was fixed, I've had no problems since

@AndersonTorres
Copy link
Member

Anyone disagree about merging this?

@@ -520,7 +520,7 @@ in
"systemd/system-shutdown" = { source = hooks "shutdown" cfg.shutdown; };
});

services.dbus.enable = true;
services.dbus.enable = mkDefault true;
Copy link
Member

Choose a reason for hiding this comment

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

I do not feel very good about mkDefault for a critical dependency like this. But I am not sure how else to implement this other than with services.dbus.implementation = lib.mkOption { type = lib.mkEnum [ "dbus" "dbus-broker" ]; } which is not particularly nice either. So do not take this as NAK.

Copy link
Contributor

Choose a reason for hiding this comment

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

Good remark
An alternative would be services.dbus.broker = true, or maybe even services.dbus.broker.enable = true to allow for potential broker-specific options under services.dbus.broker (which I'm not sure will ever be needed).
However these look like they enable something in the existing dbus daemon rather than replace it entirely, so services.dbus.implementation = "dbus-broker" as you suggested makes more sense to me.

Copy link
Member

Choose a reason for hiding this comment

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

The mkDefaults should be removed as well, then.

Copy link
Contributor

Choose a reason for hiding this comment

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

And mkIf cfg.enable can now be moved to wrap the entire config:

  config = mkIf cfg.enable (mkMerge [
    {}

    (mkIf (cfg.implementation == "dbus") {})

    (mkIf (cfg.implementation == "dbus-broker") {})
  ]);

@m-bdf
Copy link
Contributor

m-bdf commented Nov 17, 2022

Looking at the D-Bus derivation's source code, it seems pkgs.dbus, pkgs.dbus.out and pkgs.dbus.daemon all refer to the exact same output:

Should we choose one and stick to it?

@jtojnar
Copy link
Member

jtojnar commented Nov 17, 2022

@m-bdf That is probably best done separately, as not to widen the scope of this PR and delay it even more.

Edit: opened #201647.

@jtojnar jtojnar mentioned this pull request Nov 18, 2022
9 tasks
@SuperSandro2000
Copy link
Member

Please rebase on master

@xaverdh
Copy link
Contributor Author

xaverdh commented Nov 21, 2022

Please rebase on master

done.

@peterhoeg
Copy link
Member

I just tried this out. And not only is my laptop fine, but I also noticed a 10% increase in CPU power, 2 hours additional battery time, the sun shining significantly sharper and my long lost dog has finally returned.

Very nice work all. Merging this and if we need to clean anything else up and possibly change the default, we can always do that.

@peterhoeg peterhoeg merged commit de6f2b0 into NixOS:master Nov 22, 2022
@xaverdh xaverdh deleted the dbus-broker branch November 22, 2022 07:46
@lilyinstarlight
Copy link
Member

Per @mweinelt in #dev:nixos.org (Matrix), this can be backported for inclusion in 22.11 if it does not change default behavior

If you are both comfortable with that @xaverdh and @peterhoeg, I would like for it to be backported for the upcoming release

@Mic92
Copy link
Member

Mic92 commented Nov 22, 2022

would be good to get this tested before so we can evaluate if we want this by default.

@github-actions
Copy link
Contributor

Successfully created backport PR #202365 for release-22.11.

@xaverdh
Copy link
Contributor Author

xaverdh commented Nov 23, 2022

would be good to get this tested before so we can evaluate if we want this by default.

agreed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 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: 1-10
Projects
None yet
Development

Successfully merging this pull request may close these issues.