Advice on creating .xinitrc

Hi,

NixOS newbie here. I’m trying to create a minimal installation where I can start X on demand using xinit.
My configuration looks something like the following:

services.xserver = {
	enable = true;
	displayManager.startx.enable = true;
	desktopManager.xfce.enable = true;
};

This requires me to provide a ~/.xinitrc file containing the session startup commands.

Since I’m not really knowledgeable what to put there and also don’t want to maintain its content, I tried to take inspiration from what lightdm does.
I think I tracked it down to

/nix/store/y4hg51wnsahnvn87cn4gmh7xf8wxxgi7-xsession-wrapper /nix/store/49wcg3mslxmh211cxdybn9yy5fmskv1l-xsession

being called at some point. The left part seems to originate from here and the right part comes from an xfce .desktop file that is created here.

If I manually put exactly the same command in my xinitrc and call startx everything works like a charm.
The thing where I struggle is to automatically create this file in my configuration.

My first approach would be to use something like pkgs.writeScript and symlink the result. I can access the location of xsession-wrapper via config.services.xserver.displayManager.sessionData.wrapper, but I’m not sure how to get the file path of xsession. I could probably extract it from the desktop file but I feel like there must be a better way.

So I would be really grateful for some advice:

  • Is what I’m trying to do sensible?
  • Is there a nice way to access the location of xfce’s xsession?
  • What’s a good way to create .xinitrc? I don’t want to jump to something like home-manager just for it, yet, before I’m not more knowledgeable.
1 Like