home-manager icon indicating copy to clipboard operation
home-manager copied to clipboard

dconf.settings are not being applied on NixOS

Open kamadorueda opened this issue 3 years ago • 8 comments

Issue description

Some weeks ago I was using home-manager from within Ubuntu, when I ran home-manager switch then the dconf.settings were correctly applied to the system

I migrated to NixOS some days ago, now I bootstrap home-manager in my /etc/nixos/configuration.nix in config.home-manager.users as explained in the tutorial.

Most home-manager's configurations work on NixOS, like programs, xdg, and home, and it's pretty useful to me, all my system runs on NixOS/home-manager now. However dconf.settings are not reflected

I was debugging the issue and found that on NixOS the activation script is run as a systemd service:

https://github.com/nix-community/home-manager/blob/1375fd4a030c27e6c6208b31b8189ca41da01fb0/nixos/default.nix#L121:L149

Dconf also appends some activation logic so dconf loads the dconf.settings on a dbus session:

https://github.com/nix-community/home-manager/blob/1375fd4a030c27e6c6208b31b8189ca41da01fb0/modules/misc/dconf.nix#L52:L68

When run as home-manager switch (in a user shell), DBUS_SESSION_BUS_ADDRESS exists, and therefore dconf load / < settings.ini runs in the current user dbus session, and changes get reflected and are visible to the user immediately

When run as nixos switch (inside systemd), DBUS_SESSION_BUS_ADDRESS does not exist, and therefore ${pkgs.dbus}/bin/dbus-run-session dconf load / < settings.ini runs in a new ephemeral user dbus session that ultimately gets discarded, and changes are not reflected nor visible to the user immediately (nor after reboot, basically never)

In order to see dbus.settings applied on NixOS, I've to manually source the activation script from a user shell, so it loads the settings in my current dbus session

I've tried to solve the problem by learning about dbus, dconf and systemd, also tried some changes to home-manager's source code, but ultimately I couldn't solve the problem

Meta

Maintainer CC

@gnidorah @rycee

Technical details

  • system: "x86_64-linux"
  • host os: Linux 5.10.43, NixOS, 21.05pre-git (Okapi)
  • multi-user?: yes
  • sandbox: yes
  • version: nix-env (Nix) 2.3.12
  • channels(root): "home-manager, nixos-21.05.906.cedcf2565c6"
  • channels(kamadorueda): ""
  • nixpkgs: /nix/store/ym7d82dgryr0ihspnlaf6kbpqikq7fpa-nixpkgsNixos-src

example of NixOS rebuild not working:

$ nixos-rebuild switch
... dconf settings do not change in my host

example of sourcing the activation script manually:

$ cat /etc/systemd/system/home-manager-kamadorueda.service
...
ExecStart=/nix/store/v56vnir1ycr84bm3rmjiw1vb8kv62hsn-activate-kamadorueda
...
$ /nix/store/v56vnir1ycr84bm3rmjiw1vb8kv62hsn-activate-kamadorueda
... dconf settings now work!

kamadorueda avatar Jun 15 '21 00:06 kamadorueda

Hi,

Good catch, this indeed looks like a bug with the way some activation scripts depend on variables defined at the systemd's user session level.

I think one way to resolve this issue would be to rewrite some activation scripts in terms of systemd services that run in the user's session. These services would then be triggered by the user HM service.

Is this feasible @rycee?

berbiche avatar Jun 15 '21 16:06 berbiche

I observe the same problem using flakes.

feijoas avatar Aug 25 '21 19:08 feijoas

Thank you for your contribution! I marked this issue as stale due to inactivity. If this remains inactive for another 7 days, I will close this issue. Please read the relevant sections below before commenting.

If you are the original author of the issue

  • If this is resolved, please consider closing it so that the maintainers know not to focus on this.
  • If this might still be an issue, but you are not interested in promoting its resolution, please consider closing it while encouraging others to take over and reopen an issue if they care enough.
  • If you know how to solve the issue, please consider submitting a Pull Request that addresses this issue.
If you are not the original author of the issue

  • If you are also experiencing this issue, please add details of your situation to help with the debugging process.
  • If you know how to solve the issue, please consider submitting a Pull Request that addresses this issue.
Memorandum on closing issues

If you have nothing of substance to add, please refrain from commenting and allow the bot close the issue. Also, don't be afraid to manually close an issue, even if it holds valuable information.

Closed issues stay in the system for people to search, read, cross-reference, or even reopen--nothing is lost! Closing obsolete issues is an important way to help maintainers focus their time and effort.

stale[bot] avatar Nov 23 '21 21:11 stale[bot]

I'm having the same issue, trying to set icons. That said, I'm also not sure I'm doing this 100% correctly.

Krutonium avatar Nov 29 '21 22:11 Krutonium

Thank you for your contribution! I marked this issue as stale due to inactivity. If this remains inactive for another 7 days, I will close this issue. Please read the relevant sections below before commenting.

If you are the original author of the issue

  • If this is resolved, please consider closing it so that the maintainers know not to focus on this.
  • If this might still be an issue, but you are not interested in promoting its resolution, please consider closing it while encouraging others to take over and reopen an issue if they care enough.
  • If you know how to solve the issue, please consider submitting a Pull Request that addresses this issue.
If you are not the original author of the issue

  • If you are also experiencing this issue, please add details of your situation to help with the debugging process.
  • If you know how to solve the issue, please consider submitting a Pull Request that addresses this issue.
Memorandum on closing issues

If you have nothing of substance to add, please refrain from commenting and allow the bot to close the issue. Also, don't be afraid to manually close an issue, even if it holds valuable information.

Closed issues stay in the system for people to search, read, cross-reference, or even reopen – nothing is lost! Closing obsolete issues is an important way to help maintainers focus their time and effort.

stale[bot] avatar Feb 28 '22 00:02 stale[bot]

Still an issue for me.

malob avatar Feb 28 '22 17:02 malob

I can reproduce this issue when running the activation script from a PTY shell where there is no DBUS session running. Otherwise I am unable to reproduce this issue.

berbiche avatar Apr 17 '22 22:04 berbiche

Thank you for your contribution! I marked this issue as stale due to inactivity. Please be considerate of people watching this issue and receiving notifications before commenting 'I have this issue too'. We welcome additional information that will help resolve this issue. Please read the relevant sections below before commenting.

If you are the original author of the issue

  • If this is resolved, please consider closing it so that the maintainers know not to focus on this.
  • If this might still be an issue, but you are not interested in promoting its resolution, please consider closing it while encouraging others to take over and reopen an issue if they care enough.
  • If you know how to solve the issue, please consider submitting a Pull Request that addresses this issue.
If you are not the original author of the issue

  • If you are also experiencing this issue, please add details of your situation to help with the debugging process.
  • If you know how to solve the issue, please consider submitting a Pull Request that addresses this issue.
Memorandum on closing issues

Don't be afraid to manually close an issue, even if it holds valuable information. Closed issues stay in the system for people to search, read, cross-reference, or even reopen – nothing is lost! Closing obsolete issues is an important way to help maintainers focus their time and effort.

stale[bot] avatar Jul 17 '22 01:07 stale[bot]

It would be nice to have a note in the docs for dconf.settings mentioning that this option is known to not work -- I just spent a while trying to figure out what I was doing wrong before I found this issue.

chris-martin avatar Mar 22 '23 08:03 chris-martin

This option has been working for me since late 2022 (too lazy to bisect). FYI, I use home-manager via the NixOS module and start Sway from a tty.

1sixth avatar Mar 22 '23 10:03 1sixth

Thank you for your contribution! I marked this issue as stale due to inactivity. Please be considerate of people watching this issue and receiving notifications before commenting 'I have this issue too'. We welcome additional information that will help resolve this issue. Please read the relevant sections below before commenting.

If you are the original author of the issue

  • If this is resolved, please consider closing it so that the maintainers know not to focus on this.
  • If this might still be an issue, but you are not interested in promoting its resolution, please consider closing it while encouraging others to take over and reopen an issue if they care enough.
  • If you know how to solve the issue, please consider submitting a Pull Request that addresses this issue.
If you are not the original author of the issue

  • If you are also experiencing this issue, please add details of your situation to help with the debugging process.
  • If you know how to solve the issue, please consider submitting a Pull Request that addresses this issue.
Memorandum on closing issues

Don't be afraid to manually close an issue, even if it holds valuable information. Closed issues stay in the system for people to search, read, cross-reference, or even reopen – nothing is lost! Closing obsolete issues is an important way to help maintainers focus their time and effort.

stale[bot] avatar Jun 21 '23 11:06 stale[bot]