anchor.diff:              LD_LIBRARY_PATH = "${xorg.libX11}/lib:${xorg.libXext}/lib:${kernelPackages.nvidia_x11}/lib";
             } // optionalAttrs (elem "nvidiaLegacy" driverNames) {
               LD_LIBRARY_PATH = "${xorg.libX11}/lib:${xorg.libXext}/lib:${kernelPackages.nvidia_x11_legacy}/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 !
             } // cfg.displayManager.job.environment;
   
           preStart =
  
positive.code:   # Map video driver names to driver packages.
    knownVideoDrivers = {
      ati          = { modules = [ xorg.xf86videoati ]; };
      cirrus       = { modules = [ xorg.xf86videocirrus ]; };
      i810         = { modules = [ xorg.xf86videoi810 ]; };
      intel        = { modules = [ xorg.xf86videointel ]; };
  
negative.code:     boot.extraModulePackages =
        optional (elem "nvidia" driverNames) kernelPackages.nvidia_x11 ++ 
        optional (elem "nvidiaLegacy" driverNames) kernelPackages.nvidia_x11_legacy ++
        optional (elem "virtualbox" driverNames) kernelPackages.virtualboxGuestAdditions ++
        optional (elem "ati_unfree" driverNames) kernelPackages.ati_drivers_x11;
  
      environment.etc = optionals cfg.exportConfiguration
        [ { source = "${configFile}";
  