From 89854548e7ca16f833b3e9fe5688267dd6d0707a Mon Sep 17 00:00:00 2001
From: Evgeny Egorochkin <phreedom@yandex.ru>
Date: Sat, 19 Oct 2013 00:40:45 +0300
Subject: [PATCH] Add services.xserver.s3tcSupport option

---
 nixos/modules/services/x11/xserver.nix | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/nixos/modules/services/x11/xserver.nix b/nixos/modules/services/x11/xserver.nix
index 6e470e65e351..02ba680255bf 100644
--- a/nixos/modules/services/x11/xserver.nix
+++ b/nixos/modules/services/x11/xserver.nix
@@ -229,6 +229,14 @@ in
         '';
       };
 
+      s3tcSupport = mkOption {
+        default = false;
+        description = ''
+          Make S2TC via libtxc_dxtn available to OpenGL drivers. Using
+          this library may require a patent license depending on your location.
+        '';
+      };
+
       startOpenSSHAgent = mkOption {
         default = true;
         description = ''
@@ -410,7 +418,9 @@ in
       optionals (elem "nvidia" driverNames) [ "nouveau" "nvidiafb" ];
 
     environment.variables.LD_LIBRARY_PATH =
-      [ "/run/opengl-driver/lib" "/run/opengl-driver-32/lib" ];
+      [ "/run/opengl-driver/lib" "/run/opengl-driver-32/lib" ]
+      ++ pkgs.lib.optional cfg.s3tcSupport "${pkgs.libtxc_dxtn}/lib"
+      ++ pkgs.lib.optional (cfg.s3tcSupport && cfg.driSupport32Bit) "${pkgs_i686.libtxc_dxtn}/lib";
 
     environment.etc =
       (optionals cfg.exportConfiguration