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

display-managers: use xsession from nix-profile #54283

Closed
wants to merge 1 commit into from

Conversation

lheckemann
Copy link
Member

Motivation for this change

This allows more declarative config of the user environment independent of the system config.

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

if test -x ~/.xsession; then
exec ~/.xsession
fi
test -x ~/.nix-profile/bin/xsession && exec ~/.nix-profile/bin/xsession
Copy link
Member

Choose a reason for hiding this comment

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

This probably should be documented. In addition, it might be a good idea to reuse a name that other distros use like Debian:

https://wiki.debian.org/Xsession

which uses:

  • x-session-manager
  • x-window-manager
  • x-terminal-emulator

You can also use command -v xsession to allow any binary in PATH to be used.

Copy link
Member

@rycee rycee Jan 18, 2019

Choose a reason for hiding this comment

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

Agreed that more paths should be supported, in particular it should be possible to use users.users.<name?>.packages to install this command. Eventually I would like to move Home Manager to install packages through this option when used as a NixOS module.

Personally I don't see much need for the x-session-manager, x-window-manager, and x-terminal-emulator commands in NixOS but the Debian wiki reminded me of something that I've thought of multiple times. Namely, to change the semantics of the xsession script so that it is only used when no specific session was set in the display manager.

Right now, if you have an xsession script then you can never select an alternative session in the DM, which is quite limiting.

I guess this could be done by adding an additional services.xserver.desktopManager.xsession.enable, for example. This would also allow the system administrator to disable the possibility for users to have an xsession script at all, if they for some reason would like to do so.

Copy link
Member Author

Choose a reason for hiding this comment

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

Right now, if you have an xsession script then you can never select an alternative session in the DM, which is quite limiting.

I think it's the other way round — not using the xsession script in all cases would be more limiting! The xsession script can pass on to the desired session based on the relevant environment variable (I forget which one that is…), allowing users to set environment variables for their session for instance. EDIT: There's also .xprofile…
As for using $PATH, sure.

Copy link
Member

Choose a reason for hiding this comment

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

Hmm, @lheckemann do you have an example of how to accomplish this in the xsession script? Based on the

if test "$1"; then
# Run the supplied session command. Remove any double quotes with eval.
eval exec "$@"
else
# Fall back to the default window/desktopManager
exec ${cfg.displayManager.session.script}
fi

below I understand that the desired session is passed as an argument to the xsession-wrapper script and I don't see this argument being stored in an exported variable. It would be great if it was possible since I then could make Home Manager work with other session types without the user having to mess around with the HM xsession.scriptPath option.

Copy link
Member Author

Choose a reason for hiding this comment

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

The DESKTOP_SESSION env var contains the path to the selected session script, as far as I understand.

Copy link
Member

Choose a reason for hiding this comment

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

For me it seems to just show the name of the session, not the script path:

$ echo $DESKTOP_SESSION 
home-manager

I also did a little survey in #nixos and ottidmes and clever said their $DESKTOP_SESSION is set to xfce+bspwm and xfce, respectively.

At least on my system I don't see any environment variable pointing to the session script.

Copy link
Member Author

Choose a reason for hiding this comment

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

Maybe that's only for xterm then… I get /nix/store/qjhks5jpwwaq72pfrr5ghvb59nvm5h11-desktops/share/xsessions/xterm because I didn't set up anything else since I use .xsession.

exec ~/.xsession
fi
test -x ~/.nix-profile/bin/xsession && exec ~/.nix-profile/bin/xsession
test -x ~/.xsession && exec ~/.xsession
Copy link
Member

Choose a reason for hiding this comment

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

I'd rather have the style stay the same, so to keep the if, as it's done in the rest of the file

@lheckemann lheckemann closed this May 8, 2019
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

5 participants