at 15.09-beta 3.1 kB view raw
1{ config, lib, pkgs, pkgs_i686, ... }: 2 3with lib; 4 5let 6 7 cfg = config.hardware.opengl; 8 9 kernelPackages = config.boot.kernelPackages; 10 11 videoDrivers = config.services.xserver.videoDrivers; 12 13 makePackage = p: p.buildEnv { 14 name = "mesa-drivers+txc-${p.mesa_drivers.version}"; 15 paths = 16 [ p.mesa_drivers 17 p.mesa_noglu # mainly for libGL 18 (if cfg.s3tcSupport then p.libtxc_dxtn else p.libtxc_dxtn_s2tc) 19 ]; 20 }; 21 22in 23 24{ 25 options = { 26 hardware.opengl.enable = mkOption { 27 description = "Whether this configuration requires OpenGL."; 28 type = types.bool; 29 default = false; 30 internal = true; 31 }; 32 33 hardware.opengl.driSupport = mkOption { 34 type = types.bool; 35 default = true; 36 description = '' 37 Whether to enable accelerated OpenGL rendering through the 38 Direct Rendering Interface (DRI). 39 ''; 40 }; 41 42 hardware.opengl.driSupport32Bit = mkOption { 43 type = types.bool; 44 default = false; 45 description = '' 46 On 64-bit systems, whether to support Direct Rendering for 47 32-bit applications (such as Wine). This is currently only 48 supported for the <literal>nvidia</literal> and 49 <literal>ati_unfree</literal> drivers, as well as 50 <literal>Mesa</literal>. 51 ''; 52 }; 53 54 hardware.opengl.s3tcSupport = mkOption { 55 type = types.bool; 56 default = false; 57 description = '' 58 Make S3TC(S3 Texture Compression) via libtxc_dxtn available 59 to OpenGL drivers instead of the patent-free S2TC replacement. 60 61 Using this library may require a patent license depending on your location. 62 ''; 63 }; 64 65 hardware.opengl.package = mkOption { 66 type = types.package; 67 internal = true; 68 description = '' 69 The package that provides the OpenGL implementation. 70 ''; 71 }; 72 73 hardware.opengl.package32 = mkOption { 74 type = types.package; 75 internal = true; 76 description = '' 77 The package that provides the 32-bit OpenGL implementation on 78 64-bit systems. Used when <option>driSupport32Bit</option> is 79 set. 80 ''; 81 }; 82 83 }; 84 85 config = mkIf cfg.enable { 86 87 assertions = lib.singleton { 88 assertion = cfg.driSupport32Bit -> pkgs.stdenv.isx86_64; 89 message = "Option driSupport32Bit only makes sense on a 64-bit system."; 90 }; 91 92 system.activationScripts.setup-opengl = 93 '' 94 ln -sfn ${cfg.package} /run/opengl-driver 95 ${if pkgs.stdenv.isi686 then '' 96 ln -sfn opengl-driver /run/opengl-driver-32 97 '' else if cfg.driSupport32Bit then '' 98 ln -sfn ${cfg.package32} /run/opengl-driver-32 99 '' else '' 100 rm -f /run/opengl-driver-32 101 ''} 102 ''; 103 104 environment.sessionVariables.LD_LIBRARY_PATH = 105 [ "/run/opengl-driver/lib" "/run/opengl-driver-32/lib" ]; 106 107 hardware.opengl.package = mkDefault (makePackage pkgs); 108 hardware.opengl.package32 = mkDefault (makePackage pkgs_i686); 109 110 boot.extraModulePackages = optional (elem "virtualbox" videoDrivers) kernelPackages.virtualboxGuestAdditions; 111 }; 112}