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
Conversation
if test -x ~/.xsession; then | ||
exec ~/.xsession | ||
fi | ||
test -x ~/.nix-profile/bin/xsession && exec ~/.nix-profile/bin/xsession |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
nixpkgs/nixos/modules/services/x11/display-managers/default.nix
Lines 115 to 121 in 4889643
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
Motivation for this change
This allows more declarative config of the user environment independent of the system config.
Things done
sandbox
innix.conf
on non-NixOS)nix-shell -p nox --run "nox-review wip"
./result/bin/
)nix path-info -S
before and after)