Using X without a Display Manager: Difference between revisions

imported>Samueldr
m Adds a note/warning about how this isn't best practices
Klinger (talk | contribs)
mNo edit summary
 
(6 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{note|This page is a WIP, it doesn't describe best-practices with nix and NixOS and should be updated to use a nix derivation generating the necessary files instead of manipulating the contents of the store.}}
{{note|This page is a WIP, it doesn't describe best-practices with nix and NixOS and should be updated to use a nix derivation generating the necessary files instead of manipulating the contents of the store.}}
== Setting up Xorg without system wide modifications ==


To run X11 as a regular user, ''without'' <code>services.xserver.enable = true;</code> in configuration.nix, do the following:
To run X11 as a regular user, ''without'' <code>services.xserver.enable = true;</code> in configuration.nix, do the following:
Line 19: Line 21:
Then, it's just necessary to '''gather X configuration files''' into one directory and create a config file that also points X at the correct module paths, by running the following script (which should be re-run each time you run <code>nixos-rebuild switch</code>), but you will need to add or remove to the <code>pkgs</code> and <code>fontpkgs</code> arrays according to your preferences:
Then, it's just necessary to '''gather X configuration files''' into one directory and create a config file that also points X at the correct module paths, by running the following script (which should be re-run each time you run <code>nixos-rebuild switch</code>), but you will need to add or remove to the <code>pkgs</code> and <code>fontpkgs</code> arrays according to your preferences:
<syntaxhighlight lang="sh">
<syntaxhighlight lang="sh">
generateXorgConf.sh
------------------------------------------------
#!/bin/sh
#!/bin/sh
#generate unprivileged user xorg.conf for nixOS
#generate unprivileged user xorg.conf for nixOS
Line 83: Line 87:
startx -- :0 -configdir ~/.config/xorg.conf.d
startx -- :0 -configdir ~/.config/xorg.conf.d
</syntaxhighlight>
</syntaxhighlight>
== Setting up Xorg system-wide but without a Display Manager ==
If you don't mind having <code>services.xserver.enable = true;</code> but you don't want a display manager, and you want only a TTY login prompt, use the following in your <code>configuration.nix</code>:
<syntaxhighlight lang="nix">
services.xserver.displayManager.startx.enable = true;
</syntaxhighlight>
<code>startx</code> is treated as a displayManager and therefore it is used instead of the default (<code>lightdm</code>).
== Setting up the user's D-Bus Daemon ==
Both of the methods above, don't start the user's dbus-daemon properly on startup. Unfortunately, it is unclear exactly why this is missing, but here's a fix for startx users:
Put the following in your <code>~/.xinitrc</code>:
<syntaxhighlight lang="sh">
if test -z "$DBUS_SESSION_BUS_ADDRESS"; then
eval $(dbus-launch --exit-with-session --sh-syntax)
fi
systemctl --user import-environment DISPLAY XAUTHORITY
if command -v dbus-update-activation-environment >/dev/null 2>&1; then
        dbus-update-activation-environment DISPLAY XAUTHORITY
fi
</syntaxhighlight>
[[Category: Desktop environment]]