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

Make socket activated user dbus session mandatory #97801

Merged
merged 2 commits into from Sep 14, 2020

Conversation

rycee
Copy link
Member

@rycee rycee commented Sep 11, 2020

Motivation for this change

Removes non-socket activated user D-Bus session. To do this it was also necessary to add a hook that moves systemd user units to a place discoverable through XDG_DATA_DIRS. Replaces #67942.

Many CPU hours have died to bring us these two commits.

@rycee
Copy link
Member Author

rycee commented Sep 11, 2020

I'll add a note to the 21.03 release notes when the file is added.

@worldofpeace
Copy link
Contributor

I think in xserver.nix we still do startDbusSession

@xaverdh
Copy link
Contributor

xaverdh commented Sep 12, 2020

I'll add a note to the 21.03 release notes when the file is added.

https://github.com/NixOS/nixpkgs/blob/master/nixos/doc/manual/release-notes/rl-2103.xml is already there actually

@rycee
Copy link
Member Author

rycee commented Sep 12, 2020

@worldofpeace The PR also removes the services.xserver.startDbusSession option since it indeed is obsolete once dbus is socket activated.

@xaverdh Cool, I'll update the PR.

@rycee rycee force-pushed the user-session-dbus2 branch 3 times, most recently from b4e956e to a6feaa5 Compare September 12, 2020 12:31
@@ -0,0 +1,25 @@
#!/run/current-system/sw/bin/bash
Copy link
Member

Choose a reason for hiding this comment

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

Is the shebang here necessary at all? Does it work in a sandboxed build or non-sandboxed build on non-NixOS?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, the shebang is not serving any function beside helping the editor and shellcheck detect that the code is expected to be Bash compatible.

I changed to a more generic #!/usr/bin/env bash line, though, that is probably more familar.

This hook moves systemd user service file from `lib/systemd/user` to
`share/systemd/user`. This is to allow systemd to find the user
services when installed into a user profile. The `lib/systemd/user`
path does not work since `lib` is not in `XDG_DATA_DIRS`.
Copy link
Member

@Ericson2314 Ericson2314 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. Maybe change the wording to make clear dbus is socket-activated if it is enabled at all, so no one thinks you made dbus uncondititonal?

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.

LGTM yay!

@rycee
Copy link
Member Author

rycee commented Sep 12, 2020

@Ericson2314 Yes, that's a good idea. I'll make that change, just waiting for everything to rebuild (again 😉).

This removes the `services.dbus.socketActivated` and
`services.xserver.startDbusSession` options. Instead the user D-Bus
session is always socket activated.
@rycee
Copy link
Member Author

rycee commented Sep 13, 2020

@Ericson2314 Done.

@worldofpeace worldofpeace merged commit 4085eee into NixOS:staging Sep 14, 2020
@rycee rycee deleted the user-session-dbus2 branch September 15, 2020 20:36
@rycee
Copy link
Member Author

rycee commented Sep 15, 2020

Thanks for the merge @worldofpeace. It'll be very nice to be able to rely on people having a functional dbus even in non-graphical logins 😀

@bb010g
Copy link
Member

bb010g commented Sep 15, 2020

How likely is this PR landing in 20.09?

@cole-h
Copy link
Member

cole-h commented Sep 15, 2020

Unlikely, considering branch-off happened last week.

@rycee
Copy link
Member Author

rycee commented Sep 15, 2020

@bb010g I would be very much against trying to get this into 20.09. Since it involves a stdenv change I haven't been able to comprehensive test due to the amount of rebuilds necessary (https://nixbuild.net/ has helped a lot but still it is a slow process) so I imagine there might be some cases that have not been covered. It will absolutely have to stabilize in staging-next and master for some time.

@gebner
Copy link
Member

gebner commented Oct 20, 2020

This change makes it very hard to have the same configuration for unstable and stable. Could we at least make services.dbus.socketActivated = true; a warning instead of a hard error?

@worldofpeace
Copy link
Contributor

This change makes it very hard to have the same configuration for unstable and stable. Could we at least make services.dbus.socketActivated = true; a warning instead of a hard error?

This PR used mkRemovedOptionModule, which as described in modules.nix

Return a module that causes a warning to be shown if the
specified option is defined

should not throw a hard error. Can you please paste a trace etc.?

@gebner
Copy link
Member

gebner commented Oct 22, 2020

This change makes it very hard to have the same configuration for unstable and stable. Could we at least make services.dbus.socketActivated = true; a warning instead of a hard error?

This PR used mkRemovedOptionModule, which as described in modules.nix

Return a module that causes a warning to be shown if the
specified option is defined

should not throw a hard error. Can you please paste a trace etc.?

let

  configuration = { config, pkgs, ... }: {
    services.dbus.socketActivated = true;
  };

  nixos = import <nixpkgs/nixos> { configuration = configuration; };

in nixos.vm
$ nix-build foo.nix
error:
Failed assertions:
- The option definition `services.dbus.socketActivated' in `<unknown-file>' no longer has any effect; please remove it.
The user D-Bus session is now always socket activated and this option can safely be removed.

(use '--show-trace' to show detailed location information)

@gebner
Copy link
Member

gebner commented Oct 22, 2020

I've made a PR: #101408

@rycee
Copy link
Member Author

rycee commented Oct 24, 2020

And I made an alternative PR #101409 that turns this specific dbus assertion error into a warning. Please have a look.

rycee added a commit to nix-community/home-manager that referenced this pull request Nov 22, 2020
This makes the systemd module use the sd-switch application to perform
the unit switch during a generation activation.

Since the closure of sd-switch is relatively lightweight we
unconditionally pull it in as a dependency. We simultaneously remove
the `systemd.user.startServices` option and perform the switch action
automatically.

This is the second attempt at introducing this change, the first being
9c0fe39, which was quickly reverted
223e3c3 since the feature didn't work
on systems where the user is not given a functional dbus session.
Since the user session is now always socket activated, see [0], we can
(hopefully) safely reintroduce the feature.

[0] NixOS/nixpkgs#97801
rycee added a commit to nix-community/home-manager that referenced this pull request Dec 1, 2020
This makes the systemd module use the sd-switch application to perform
the unit switch during a generation activation.

Since the closure of sd-switch is relatively lightweight we
unconditionally pull it in as a dependency. We simultaneously remove
the `systemd.user.startServices` option and perform the switch action
automatically.

This is the second attempt at introducing this change, the first being
9c0fe39, which was quickly reverted
223e3c3 since the feature didn't work
on systems where the user is not given a functional dbus session.
Since the user session is now always socket activated, see [0], we can
(hopefully) safely reintroduce the feature.

[0] NixOS/nixpkgs#97801
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants