@ -11,30 +11,16 @@ let
xorg = pkgs . xorg ;
# Map video driver names to driver packages.
# Map video driver names to driver packages. FIXME: move into card-specific modules.
knownVideoDrivers = {
ati_unfree = { modules = [ kernelPackages . ati_drivers_x11 ] ; driverName = " f g l r x " ; } ;
nouveau = { modules = [ pkgs . xf86_video_nouveau ] ; } ;
nvidia = { modules = [ kernelPackages . nvidia_x11 ] ; } ;
nvidiaLegacy173 = { modules = [ kernelPackages . nvidia_x11_legacy173 ] ; driverName = " n v i d i a " ; } ;
nvidiaLegacy304 = { modules = [ kernelPackages . nvidia_x11_legacy304 ] ; driverName = " n v i d i a " ; } ;
unichrome = { modules = [ pkgs . xorgVideoUnichrome ] ; } ;
virtualbox = { modules = [ kernelPackages . virtualboxGuestAdditions ] ; driverName = " v b o x v i d e o " ; } ;
ati = { modules = [ pkgs . xorg . xf86videoati pkgs . xorg . glamoregl ] ; } ;
intel-testing = { modules = with pkgs . xorg ; [ xf86videointel-testing glamoregl ] ; driverName = " i n t e l " ; } ;
} ;
driverNames = cfg . videoDrivers ;
needsAcpid =
( elem " n v i d i a " driverNames ) ||
( elem " n v i d i a L e g a c y 1 7 3 " driverNames ) ||
( elem " n v i d i a L e g a c y 3 0 4 " driverNames ) ;
drivers = flip map driverNames
( name : { inherit name ; driverName = name ; } //
attrByPath [ name ] ( if ( hasAttr ( " x f 8 6 v i d e o " + name ) xorg ) then { modules = [ ( getAttr ( " x f 8 6 v i d e o " + name ) xorg ) ] ; } else throw " u n k n o w n v i d e o d r i v e r ` ${ name } ' " ) knownVideoDrivers ) ;
fontsForXServer =
config . fonts . fonts ++
# We don't want these fonts in fonts.conf, because then modern,
@ -79,7 +65,6 @@ let
monitors = foldl mkMonitor [ ] xrandrHeads ;
in concatMapStrings ( getAttr " v a l u e " ) monitors ;
configFile = pkgs . stdenv . mkDerivation {
name = " x s e r v e r . c o n f " ;
@ -204,6 +189,15 @@ in
'' ;
} ;
drivers = mkOption {
type = types . listOf types . attrs ;
internal = true ;
description = ''
A list of attribute sets specifying drivers to be loaded by
the X11 server .
'' ;
} ;
vaapiDrivers = mkOption {
type = types . listOf types . path ;
default = [ ] ;
@ -397,9 +391,21 @@ in
###### implementation
config = mkIf cfg . enable {
hardware . opengl . enable = true ;
hardware . opengl . enable = mkDefault true ;
services . xserver . videoDrivers = mkIf ( cfg . videoDriver != null ) [ cfg . videoDriver ] ;
# FIXME: somehow check for unknown driver names.
services . xserver . drivers = flip concatMap cfg . videoDrivers ( name :
let driver =
attrByPath [ name ]
( if ( hasAttr ( " x f 8 6 v i d e o " + name ) xorg )
then { modules = [ ( getAttr ( " x f 8 6 v i d e o " + name ) xorg ) ] ; }
else null )
knownVideoDrivers ;
in optional ( driver != null ) ( { inherit name ; driverName = name ; } // driver ) ) ;
assertions =
[ { assertion = ! ( config . programs . ssh . startAgent && cfg . startGnuPGAgent ) ;
message =
@ -438,24 +444,18 @@ in
pkgs . xterm
pkgs . xdg_utils
]
++ optional ( elem " n v i d i a " driverNames ) kernelPackages . nvidia_x11
++ optional ( elem " n v i d i a L e g a c y 1 7 3 " driverNames ) kernelPackages . nvidia_x11_legacy173
++ optional ( elem " n v i d i a L e g a c y 3 0 4 " driverNames ) kernelPackages . nvidia_x11_legacy304
++ optional ( elem " v i r t u a l b o x " driverNames ) xorg . xrefresh
++ optional ( elem " a t i _ u n f r e e " driverNames ) kernelPackages . ati_drivers_x11 ;
services . acpid . enable = mkIf needsAcpid true ;
++ optional ( elem " v i r t u a l b o x " cfg . videoDrivers ) xorg . xrefresh
++ optional ( elem " a t i _ u n f r e e " cfg . videoDrivers ) kernelPackages . ati_drivers_x11 ;
environment . pathsToLink =
[ " / e t c / x d g " " / s h a r e / x d g " " / s h a r e / a p p l i c a t i o n s " " / s h a r e / i c o n s " " / s h a r e / p i x m a p s " ] ;
systemd . defaultUnit = mkIf cfg . autorun " g r a p h i c a l . t a r g e t " ;
systemd . services . " d is p l a y - ma n a g e r" =
systemd . services . displa y-mana ger =
{ description = " X 1 1 S e r v e r " ;
after = [ " s y s t e m d - u d e v - s e t t l e . s e r v i c e " " l o c a l - f s . t a r g e t " ]
++ optional needsAcpid " a c p i d . s e r v i c e " ;
after = [ " s y s t e m d - u d e v - s e t t l e . s e r v i c e " " l o c a l - f s . t a r g e t " " a c p i d . s e r v i c e " ] ;
restartIfChanged = false ;
@ -463,15 +463,11 @@ in
{ FONTCONFIG_FILE = " / e t c / f o n t s / f o n t s . c o n f " ; # !!! cleanup
XKB_BINDIR = " ${ xorg . xkbcomp } / b i n " ; # Needed for the Xkb extension.
XORG_DRI_DRIVER_PATH = " / r u n / o p e n g l - d r i v e r / l i b / d r i " ; # !!! Depends on the driver selected at runtime.
} // optionalAttrs ( elem " n v i d i a " driverNames ) {
LD_LIBRARY_PATH = " ${ xorg . libX11 } / l i b : ${ xorg . libXext } / l i b : ${ kernelPackages . nvidia_x11 } / l i b " ;
} // optionalAttrs ( elem " n v i d i a L e g a c y 1 7 3 " driverNames ) {
LD_LIBRARY_PATH = " ${ xorg . libX11 } / l i b : ${ xorg . libXext } / l i b : ${ kernelPackages . nvidia_x11_legacy173 } / l i b " ;
} // optionalAttrs ( elem " n v i d i a L e g a c y 3 0 4 " driverNames ) {
LD_LIBRARY_PATH = " ${ xorg . libX11 } / l i b : ${ xorg . libXext } / l i b : ${ kernelPackages . nvidia_x11_legacy304 } / l i b " ;
} // optionalAttrs ( elem " a t i _ u n f r e e " driverNames ) {
LD_LIBRARY_PATH = " ${ xorg . libX11 } / l i b : ${ xorg . libXext } / l i b : ${ kernelPackages . ati_drivers_x11 } / l i b : ${ kernelPackages . ati_drivers_x11 } / X 1 1 R 6 / l i b 6 4 / m o d u l e s / l i n u x " ;
#XORG_DRI_DRIVER_PATH = "${kernelPackages.ati_drivers_x11}/lib/dri"; # is ignored because ati drivers ship their own unpatched libglx.so !
LD_LIBRARY_PATH = concatStringsSep " : " (
[ " ${ xorg . libX11 } / l i b " " ${ xorg . libXext } / l i b " ]
++ optionals ( elem " a t i _ u n f r e e " cfg . videoDrivers )
[ " ${ kernelPackages . ati_drivers_x11 } / l i b " " ${ kernelPackages . ati_drivers_x11 } / X 1 1 R 6 / l i b 6 4 / m o d u l e s / l i n u x " ]
++ concatLists ( catAttrs " l i b P a t h " cfg . drivers ) ) ;
} // cfg . displayManager . job . environment ;
preStart =
@ -501,7 +497,7 @@ in
] ++ optional ( ! cfg . enableTCP ) " - n o l i s t e n t c p " ;
services . xserver . modules =
concatLists ( catAttrs " m o d u l e s " drivers ) ++
concatLists ( catAttrs " m o d u l e s " cfg . drivers ) ++
[ xorg . xorgserver
xorg . xf86inputevdev
] ;
@ -537,7 +533,7 @@ in
$ { cfg . serverLayoutSection }
# Reference the Screen sections for each driver. This will
# cause the X server to try each in turn.
$ { flip concatMapStrings drivers ( d : ''
$ { flip concatMapStrings cfg . drivers ( d : ''
Screen " S c r e e n - ${ d . name } [ 0 ] "
'' ) }
EndSection
@ -551,11 +547,11 @@ in
# For each supported driver, add a "Device" and "Screen"
# section.
$ { flip concatMapStrings drivers ( driver : ''
$ { flip concatMapStrings cfg . drivers ( driver : ''
Section " D e v i c e "
Identifier " D e v i c e - ${ driver . name } [ 0 ] "
Driver " ${ driver . driverName } "
Driver " ${ driver . driverName or driver . name } "
$ { if cfg . useGlamor then '' O p t i o n " A c c e l M e t h o d " " g l a m o r " '' else " " }
$ { cfg . deviceSection }
$ { xrandrDeviceSection }
@ -574,10 +570,6 @@ in
DefaultDepth $ { toString cfg . defaultDepth }
'' }
$ { optionalString ( driver . name == " n v i d i a " ) ''
Option " R a n d R R o t a t i o n " " o n "
'' }
$ { optionalString
( driver . name != " v i r t u a l b o x " &&
( cfg . resolutions != [ ] ||