From c16874c4c0e8f0980d1000b4024239146c02028d Mon Sep 17 00:00:00 2001 From: Nathaniel Baxter Date: Fri, 5 Sep 2014 19:53:36 +1000 Subject: [PATCH] ati_unfree: Create a nixos module for the ati_unfree x11 driver and blacklist the radeon driver when ati_unfree is installed. --- nixos/modules/hardware/opengl.nix | 17 +-------- nixos/modules/hardware/video/ati.nix | 37 +++++++++++++++++++ nixos/modules/module-list.nix | 1 + nixos/modules/services/x11/xserver.nix | 6 +-- .../os-specific/linux/ati-drivers/default.nix | 2 - 5 files changed, 41 insertions(+), 22 deletions(-) create mode 100644 nixos/modules/hardware/video/ati.nix diff --git a/nixos/modules/hardware/opengl.nix b/nixos/modules/hardware/opengl.nix index f894c830eb6..f974ec01c66 100644 --- a/nixos/modules/hardware/opengl.nix +++ b/nixos/modules/hardware/opengl.nix @@ -104,22 +104,9 @@ in environment.sessionVariables.LD_LIBRARY_PATH = [ "/run/opengl-driver/lib" "/run/opengl-driver-32/lib" ]; - # FIXME: move this into card-specific modules. - hardware.opengl.package = mkDefault - (if elem "ati_unfree" videoDrivers then - kernelPackages.ati_drivers_x11 - else - makePackage pkgs); - + hardware.opengl.package = mkDefault (makePackage pkgs); hardware.opengl.package32 = mkDefault (makePackage pkgs_i686); - boot.extraModulePackages = - optional (elem "virtualbox" videoDrivers) kernelPackages.virtualboxGuestAdditions ++ - optional (elem "ati_unfree" videoDrivers) kernelPackages.ati_drivers_x11; - - environment.etc = - optionalAttrs (elem "ati_unfree" videoDrivers) { - "ati".source = "${kernelPackages.ati_drivers_x11}/etc/ati"; - }; + boot.extraModulePackages = optional (elem "virtualbox" videoDrivers) kernelPackages.virtualboxGuestAdditions; }; } diff --git a/nixos/modules/hardware/video/ati.nix b/nixos/modules/hardware/video/ati.nix new file mode 100644 index 00000000000..4ae1711318f --- /dev/null +++ b/nixos/modules/hardware/video/ati.nix @@ -0,0 +1,37 @@ +# This module provides the proprietary ATI X11 / OpenGL drivers. + +{ config, lib, pkgs, pkgs_i686, ... }: + +with lib; + +let + + drivers = config.services.xserver.videoDrivers; + + enabled = elem "ati_unfree" drivers; + + ati_x11 = config.boot.kernelPackages.ati_drivers_x11; + +in + +{ + + config = mkIf enabled { + + services.xserver.drivers = singleton + { name = "fglrx"; modules = [ ati_x11 ]; libPath = [ "${ati_x11}/lib" ]; }; + + hardware.opengl.package = ati_x11; + #hardware.opengl.package32 = pkgs_i686.linuxPackages.ati_x11.override { libsOnly = true; kernel = null; }; + + environment.systemPackages = [ ati_x11 ]; + + boot.extraModulePackages = [ ati_x11 ]; + + boot.blacklistedKernelModules = [ "radeon" ]; + + environment.etc."ati".source = "${ati_x11}/etc/ati"; + + }; + +} diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index 61a98ca12ff..a6da9b32d81 100755 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -38,6 +38,7 @@ ./hardware/pcmcia.nix ./hardware/video/bumblebee.nix ./hardware/video/nvidia.nix + ./hardware/video/ati.nix ./installer/tools/nixos-checkout.nix ./installer/tools/tools.nix ./misc/assertions.nix diff --git a/nixos/modules/services/x11/xserver.nix b/nixos/modules/services/x11/xserver.nix index 21eaf6bb6b7..c08afe2041f 100644 --- a/nixos/modules/services/x11/xserver.nix +++ b/nixos/modules/services/x11/xserver.nix @@ -13,7 +13,6 @@ let # 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 ]; }; unichrome = { modules = [ pkgs.xorgVideoUnichrome ]; }; virtualbox = { modules = [ kernelPackages.virtualboxGuestAdditions ]; driverName = "vboxvideo"; }; @@ -444,8 +443,7 @@ in pkgs.xterm pkgs.xdg_utils ] - ++ optional (elem "virtualbox" cfg.videoDrivers) xorg.xrefresh - ++ optional (elem "ati_unfree" cfg.videoDrivers) kernelPackages.ati_drivers_x11; + ++ optional (elem "virtualbox" cfg.videoDrivers) xorg.xrefresh; environment.pathsToLink = [ "/etc/xdg" "/share/xdg" "/share/applications" "/share/icons" "/share/pixmaps" ]; @@ -465,8 +463,6 @@ in XORG_DRI_DRIVER_PATH = "/run/opengl-driver/lib/dri"; # !!! Depends on the driver selected at runtime. 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; diff --git a/pkgs/os-specific/linux/ati-drivers/default.nix b/pkgs/os-specific/linux/ati-drivers/default.nix index 0da2d26c356..10aeea18ceb 100644 --- a/pkgs/os-specific/linux/ati-drivers/default.nix +++ b/pkgs/os-specific/linux/ati-drivers/default.nix @@ -21,8 +21,6 @@ # There is one issue left: # /usr/lib/dri/fglrx_dri.so must point to /run/opengl-driver/lib/fglrx_dri.so -# You eventually have to blacklist radeon module (?) - assert stdenv.system == "x86_64-linux"; stdenv.mkDerivation {