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''' | 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: | ||
<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 | # install any desired packages by placing them in `/etc/nixos/configuration.nix` | ||
# update by running `nix-channel --update` and ` | # update by running `nix-channel --update` and `nixos-rebuild switch` | ||
config_dir=${XDG_CONFIG_HOME:-~/.config}/xorg.conf.d | |||
cd | 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 - | 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 |
Revision as of 23:56, 13 May 2018
To run X11 as a regular user, without services.xserver.enable = true;
in configuration.nix, do the following:
First, install packages:
- X11 itself:
xorg.xorgserver
- X11 input modules
xorg.xf86inputevdev
xorg.xf86inputsynaptics
xorg.xf86inputlibinput
- X11 video modules
xorg.xf86videointel
xorg.xf86videoati
xorg.xf86videonouveau
You probably want to use DRI acceleration for X; enable it and OpenGL in configuration.nix: hardware.opengl.enable = true;
and hardware.opengl.driSupport = true;
.
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 nixos-rebuild switch
), but you will need to add or remove to the pkgs
and fontpkgs
arrays according to your preferences:
#!/bin/sh
#generate unprivileged user xorg.conf for nixOS
#before running:
# install any desired packages by placing them in `/etc/nixos/configuration.nix`
# update by running `nix-channel --update` and `nixos-rebuild switch`
config_dir=${XDG_CONFIG_HOME:-~/.config}/xorg.conf.d
mkdir -p "$config_dir"
cd "$config_dir"
#failed glob expansions become empty, not literal 'foo/*'
shopt -s nullglob
get_pkg_path() {
attr=$1
nix show-derivation -f '<nixpkgs>' "$attr" | jq -r '.[].env.out'
}
#add to this set according to your driver needs
pkgs="
xorg.xf86inputevdev
xorg.xf86videointel
xorg.xf86inputsynaptics
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
for pkg in $pkgs; do
pkg_path=$(get_pkg_path $pkg)
for conf in "$pkg_path"/share/X11/xorg.conf.d/*; do
ln -sf "$conf" ./
done
echo ' ModulePath "'"$pkg_path"'/lib/xorg/modules/"' >> 00-nix-module-paths.conf
done
#add to this set according to your font preferences
fontpkgs="
xorg.fontmiscmisc
ucsFonts
"
for pkg in $fontpkgs; do
pkg_path=$(get_pkg_path $pkg)
path="$pkg_path"'/share/fonts/'
[ -d "$path" ] && echo ' FontPath "'"$path"'"' >> 00-nix-module-paths.conf
path="$pkg_path"'/lib/X11/fonts/misc/'
[ -d "$path" ] && echo ' FontPath "'"$path"'"' >> 00-nix-module-paths.conf
done
echo 'EndSection' >> 00-nix-module-paths.conf
You can now start X11 by running:
startx -- :0 -configdir ~/.config/xorg.conf.d