Using X without a Display Manager: Difference between revisions
imported>Giraffito m fix inline code references |
imported>Giraffito remove hardcoded package names and include font path generation |
||
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'''; 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). | ||
You probably want to use '''DRI acceleration''' for X; enable it and OpenGL in | 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. | ||
This script does that ( | 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: | |||
# install any desired packages with `nix-env -iA ...` | |||
# update by running `nix-channel --update` and `nix-env --upgrade --leq` | |||
#TODO: obey XDG guidelines rather than assuming ~/.config | #TODO: obey XDG guidelines rather than assuming ~/.config | ||
mkdir -p ~/.config/xorg.conf.d | mkdir -p ~/.config/xorg.conf.d | ||
cd ~/.config/xorg.conf.d | cd ~/.config/xorg.conf.d | ||
Line 21: | Line 22: | ||
shopt -s nullglob | 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=" | pkgs=" | ||
xorg.xf86inputevdev | |||
xorg.xf86videointel | |||
xorg.xf86inputsynaptics | |||
xorg.xorgserver | |||
" | " | ||
echo 'Section "Files"' > 00-nix-module-paths.conf | echo 'Section "Files"' > 00-nix-module-paths.conf | ||
for pkg in $pkgs; do | for pkg in $pkgs; do | ||
for conf in | pkg_path=$(get_pkg_path $pkg) | ||
for conf in "$pkg_path"/share/X11/xorg.conf.d/*; do | |||
ln -s "$conf" ./ | ln -s "$conf" ./ | ||
done | done | ||
echo ' ModulePath " | echo ' ModulePath "'"$pkg_path"'/lib/xorg/modules/"' >> 00-nix-module-paths.conf | ||
done | 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 | echo 'EndSection' >> 00-nix-module-paths.conf | ||
</syntaxhighlight> | </syntaxhighlight> |
Revision as of 23:31, 15 April 2018
To run X11 as a regular user, without services.xserver.enable = true;
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).
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.
This script does that (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 with `nix-env -iA ...`
# update by running `nix-channel --update` and `nix-env --upgrade --leq`
#TODO: obey XDG guidelines rather than assuming ~/.config
mkdir -p ~/.config/xorg.conf.d
cd ~/.config/xorg.conf.d
#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
"
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 -s "$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