Using X without a Display Manager: Difference between revisions

imported>Giraffito
remove hardcoded package names and include font path generation
imported>Giraffito
update shell script (including Intel backlight helper fix) and package references
Line 1: Line 1:
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:


First, '''install packages'''; you need X11 itself, some X11 input modules (e.g. xf86-input-evdev, xf86-input-synaptics, xf86-input-libinput), and possibly video modules as well (xf86-video-intel, xf86-video-ati, xf86-video-nouveau).
First, '''install packages''':
* X11 itself:
** <code>xorg.xorgserver</code>
* X11 input modules
** <code>xorg.xf86inputevdev</code>
** <code>xorg.xf86inputsynaptics</code>
** <code>xorg.xf86inputlibinput</code>
*X11 video modules
** <code>xorg.xf86videointel</code>
** <code>xorg.xf86videoati</code>
** <code>xorg.xf86videonouveau</code>


You probably want to use '''DRI acceleration''' for X; enable it and OpenGL in configuration.nix: <code>hardware.opengl.enable = true;</code> and <code>hardware.opengl.driSupport = true;</code>.
You probably want to use '''DRI acceleration''' for X; enable it and OpenGL in configuration.nix: <code>hardware.opengl.enable = true;</code> and <code>hardware.opengl.driSupport = true;</code>.


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.
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:
 
This script does that (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">
#!/bin/sh
#!/bin/sh
#generate unprivileged user xorg.conf for nixOS
#generate unprivileged user xorg.conf for nixOS
#before running:
#before running:
#    install any desired packages with `nix-env -iA ...`
#    install any desired packages by placing them in `/etc/nixos/configuration.nix`
#    update by running `nix-channel --update` and `nix-env --upgrade --leq`
#    update by running `nix-channel --update` and `nixos-rebuild switch`


#TODO: obey XDG guidelines rather than assuming ~/.config
config_dir=${XDG_CONFIG_HOME:-~/.config}/xorg.conf.d
mkdir -p ~/.config/xorg.conf.d
 
cd ~/.config/xorg.conf.d
mkdir -p "$config_dir"
cd "$config_dir"


#failed glob expansions become empty, not literal 'foo/*'
#failed glob expansions become empty, not literal 'foo/*'
Line 34: Line 43:
xorg.xorgserver
xorg.xorgserver
"
"
#make the intel backlight helper setuid if it isn't already
xf86videointel_path=$(get_pkg_path xorg.xf86videointel)
backlight_helper_path="${xf86_video_intel_path}/libexec/xf86-video-intel-backlight-helper"
if [ -e "$backlight_helper_path" -a ! -u "$backlight_helper_path" ]; then
sudo chmod +s ${xf86_video_intel_path}/libexec/xf86-video-intel-backlight-helper
fi


echo 'Section "Files"' > 00-nix-module-paths.conf
echo 'Section "Files"' > 00-nix-module-paths.conf
Line 39: Line 55:
pkg_path=$(get_pkg_path $pkg)
pkg_path=$(get_pkg_path $pkg)
for conf in "$pkg_path"/share/X11/xorg.conf.d/*; do  
for conf in "$pkg_path"/share/X11/xorg.conf.d/*; do  
ln -s "$conf" ./
ln -sf "$conf" ./
done
done
echo ' ModulePath "'"$pkg_path"'/lib/xorg/modules/"' >> 00-nix-module-paths.conf
echo ' ModulePath "'"$pkg_path"'/lib/xorg/modules/"' >> 00-nix-module-paths.conf