diff options
author | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2014-04-29 14:16:34 +0200 |
---|---|---|
committer | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2014-04-29 14:42:36 +0200 |
commit | 02cef04c8187f12fd160d5fedf0ec8a928f02639 (patch) | |
tree | c5b52b19ae13347b1b025ab203115a1c53860412 /nixos/modules/services | |
parent | 3fe96bcca168b8b3ca9b9cb56f2568c338b0936d (diff) | |
download | nixlib-02cef04c8187f12fd160d5fedf0ec8a928f02639.tar nixlib-02cef04c8187f12fd160d5fedf0ec8a928f02639.tar.gz nixlib-02cef04c8187f12fd160d5fedf0ec8a928f02639.tar.bz2 nixlib-02cef04c8187f12fd160d5fedf0ec8a928f02639.tar.lz nixlib-02cef04c8187f12fd160d5fedf0ec8a928f02639.tar.xz nixlib-02cef04c8187f12fd160d5fedf0ec8a928f02639.tar.zst nixlib-02cef04c8187f12fd160d5fedf0ec8a928f02639.zip |
Move the NVIDIA support into its own module
Previously all card-specific stuff was scattered across xserver.nix and opengl.nix, which is ugly. Now it can be kept together in a single card-specific module. This required the addition of a few internal options: - services.xserver.drivers: A list of { name, driverName, modules, libPath } sets. - hardware.opengl.package: The OpenGL implementation. Note that there can be only one OpenGL implementation at a time in a system configuration (i.e. no dynamic detection). - hardware.opengl.package32: The 32-bit OpenGL implementation.
Diffstat (limited to 'nixos/modules/services')
-rw-r--r-- | nixos/modules/services/x11/xserver.nix | 80 |
1 files changed, 36 insertions, 44 deletions
diff --git a/nixos/modules/services/x11/xserver.nix b/nixos/modules/services/x11/xserver.nix index 941d08c46414..dc3aa9d15ccf 100644 --- a/nixos/modules/services/x11/xserver.nix +++ b/nixos/modules/services/x11/xserver.nix @@ -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 = "fglrx"; }; nouveau = { modules = [ pkgs.xf86_video_nouveau ]; }; - nvidia = { modules = [ kernelPackages.nvidia_x11 ]; }; - nvidiaLegacy173 = { modules = [ kernelPackages.nvidia_x11_legacy173 ]; driverName = "nvidia"; }; - nvidiaLegacy304 = { modules = [ kernelPackages.nvidia_x11_legacy304 ]; driverName = "nvidia"; }; unichrome = { modules = [ pkgs.xorgVideoUnichrome ]; }; virtualbox = { modules = [ kernelPackages.virtualboxGuestAdditions ]; driverName = "vboxvideo"; }; ati = { modules = [ pkgs.xorg.xf86videoati pkgs.xorg.glamoregl ]; }; intel-testing = { modules = with pkgs.xorg; [ xf86videointel-testing glamoregl ]; driverName = "intel"; }; }; - driverNames = cfg.videoDrivers; - - needsAcpid = - (elem "nvidia" driverNames) || - (elem "nvidiaLegacy173" driverNames) || - (elem "nvidiaLegacy304" driverNames); - - drivers = flip map driverNames - (name: { inherit name; driverName = name; } // - attrByPath [name] (if (hasAttr ("xf86video" + name) xorg) then { modules = [(getAttr ("xf86video" + name) xorg) ]; } else throw "unknown video driver `${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 "value") monitors; - configFile = pkgs.stdenv.mkDerivation { name = "xserver.conf"; @@ -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 ("xf86video" + name) xorg) + then { modules = [(getAttr ("xf86video" + 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 "nvidia" driverNames) kernelPackages.nvidia_x11 - ++ optional (elem "nvidiaLegacy173" driverNames) kernelPackages.nvidia_x11_legacy173 - ++ optional (elem "nvidiaLegacy304" driverNames) kernelPackages.nvidia_x11_legacy304 - ++ optional (elem "virtualbox" driverNames) xorg.xrefresh - ++ optional (elem "ati_unfree" driverNames) kernelPackages.ati_drivers_x11; - - services.acpid.enable = mkIf needsAcpid true; + ++ optional (elem "virtualbox" cfg.videoDrivers) xorg.xrefresh + ++ optional (elem "ati_unfree" cfg.videoDrivers) kernelPackages.ati_drivers_x11; environment.pathsToLink = [ "/etc/xdg" "/share/xdg" "/share/applications" "/share/icons" "/share/pixmaps" ]; systemd.defaultUnit = mkIf cfg.autorun "graphical.target"; - systemd.services."display-manager" = + systemd.services.display-manager = { description = "X11 Server"; - after = [ "systemd-udev-settle.service" "local-fs.target" ] - ++ optional needsAcpid "acpid.service"; + after = [ "systemd-udev-settle.service" "local-fs.target" "acpid.service" ]; restartIfChanged = false; @@ -463,15 +463,11 @@ in { FONTCONFIG_FILE = "/etc/fonts/fonts.conf"; # !!! cleanup XKB_BINDIR = "${xorg.xkbcomp}/bin"; # Needed for the Xkb extension. XORG_DRI_DRIVER_PATH = "/run/opengl-driver/lib/dri"; # !!! Depends on the driver selected at runtime. - } // optionalAttrs (elem "nvidia" driverNames) { - LD_LIBRARY_PATH = "${xorg.libX11}/lib:${xorg.libXext}/lib:${kernelPackages.nvidia_x11}/lib"; - } // optionalAttrs (elem "nvidiaLegacy173" driverNames) { - LD_LIBRARY_PATH = "${xorg.libX11}/lib:${xorg.libXext}/lib:${kernelPackages.nvidia_x11_legacy173}/lib"; - } // optionalAttrs (elem "nvidiaLegacy304" driverNames) { - LD_LIBRARY_PATH = "${xorg.libX11}/lib:${xorg.libXext}/lib:${kernelPackages.nvidia_x11_legacy304}/lib"; - } // optionalAttrs (elem "ati_unfree" driverNames) { - LD_LIBRARY_PATH = "${xorg.libX11}/lib:${xorg.libXext}/lib:${kernelPackages.ati_drivers_x11}/lib:${kernelPackages.ati_drivers_x11}/X11R6/lib64/modules/linux"; - #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}/lib" "${xorg.libXext}/lib" ] + ++ optionals (elem "ati_unfree" cfg.videoDrivers) + [ "${kernelPackages.ati_drivers_x11}/lib" "${kernelPackages.ati_drivers_x11}/X11R6/lib64/modules/linux" ] + ++ concatLists (catAttrs "libPath" cfg.drivers)); } // cfg.displayManager.job.environment; preStart = @@ -501,7 +497,7 @@ in ] ++ optional (!cfg.enableTCP) "-nolisten tcp"; services.xserver.modules = - concatLists (catAttrs "modules" drivers) ++ + concatLists (catAttrs "modules" 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 "Screen-${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 "Device" Identifier "Device-${driver.name}[0]" - Driver "${driver.driverName}" + Driver "${driver.driverName or driver.name}" ${if cfg.useGlamor then ''Option "AccelMethod" "glamor"'' else ""} ${cfg.deviceSection} ${xrandrDeviceSection} @@ -574,10 +570,6 @@ in DefaultDepth ${toString cfg.defaultDepth} ''} - ${optionalString (driver.name == "nvidia") '' - Option "RandRRotation" "on" - ''} - ${optionalString (driver.name != "virtualbox" && (cfg.resolutions != [] || |