www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

README.md (5387B)


      1 # NixGL
      2 
      3 NixGL solve the "OpenGL" problem with [nix](https://nixos.org/nix/). Works all mesa
      4 drivers (intel cards and "free" version fro Nvidia or AMD cards), Nvidia
      5 proprietary drivers, even with hybrid configuration (with bumblebee). It works
      6 for Vulkan programs too.
      7 
      8 # Motivation
      9 
     10 You use Nix on any distribution, and any GL application installed fails with this error:
     11 
     12 ```bash
     13 $ program
     14 libGL error: unable to load driver: i965_dri.so
     15 libGL error: driver pointer missing
     16 libGL error: failed to load driver: i965
     17 libGL error: unable to load driver: i965_dri.so
     18 libGL error: driver pointer missing
     19 libGL error: failed to load driver: i965
     20 libGL error: unable to load driver: swrast_dri.so
     21 libGL error: failed to load driver: swrast
     22 ```
     23 
     24 NixGL provides a set of wrappers able to launch GL or Vulkan applications:
     25 
     26 ```bash
     27 $ nixGLXXX program
     28 $ nixVulkanXXX program
     29 ```
     30 
     31 # Installation
     32 
     33 Clone this git repository:
     34 
     35 ```bash
     36 $ git clone https://github.com/guibou/nixGL
     37 $ cd nixGL
     38 ```
     39 
     40 Many wrappers are available, depending on your hardware and the graphical API
     41 you want to use (i.e. Vulkan or OpenGL). You may want to install a few of them,
     42 for example if you want to support OpenGL and Vulkan on a laptop with an hybrid
     43 configuration.
     44 
     45 ## OpenGL wrappers
     46 
     47 - `nix-env -f ./ -iA nixGLIntel`: Mesa OpenGL implementation (intel, amd, nouveau, ...).
     48 - `nix-env -f ./ -iA nixGLNvidiaBumblebee`: Proprietary Nvidia driver on hybrid hardware.
     49 - `nix-env -f ./ -iA nixGLNvidia`: Proprietary Nvidia driver.
     50 - `nix-env -f ./ -iA nixGLDefault`: Tries to auto-detect and install Nvidia,
     51     if not, fallback to mesa.
     52 
     53 ## Vulkan wrappers
     54 
     55 - `nix-env -f ./ -iA nixVulkanNvidia`: Proprietary Nvidia driver.
     56 - `nix-env -f ./ -iA nixVulkanIntel`: Mesa Vulkan implementation.
     57 
     58 The Vulkan wrapper also sets `VK_LAYER_PATH` the validation layers in the nix store.
     59 
     60 # Usage
     61 
     62 Just launch the program you want prefixed by the right wrapped.
     63 
     64 For OpenGL programs:
     65 
     66 ```bash
     67 $ nixGLXXX program args
     68 ```
     69 
     70 For Vulkan programs:
     71 
     72 ```bash
     73 $ nixVulkanXXX program args
     74 ```
     75 
     76 Replace `XXX` by the implementation pour previously selected, such as `nixGLIntel` or `nixGLNvidia`.
     77 
     78 ## Examples
     79 
     80 # OpenGL - Hybrid Intel + Nvidia laptop
     81 
     82 After installing `nixGLIntel` and `nixGLNvidiaBumblebee`.
     83 
     84 ```bash
     85 $ nixGLIntel $(nix run nixpkgs.glxinfo -c glxinfo) | grep -i 'OpenGL version string'
     86 OpenGL version string: 3.0 Mesa 17.3.3
     87 $ nixGLNvidiaBumblebee $(nix run nixpkgs.glxinfo -c glxinfo) | grep -i 'OpenGL version string'
     88 OpenGL version string: 4.6.0 NVIDIA 390.25
     89 ```
     90 
     91 If the program you'd like to run is already installed by nix in your current environment, you can simply run it with the wrapper, for example:
     92 
     93 ```bash
     94 $ nixGLIntel blender
     95 ```
     96 
     97 # Vulkan - Intel GPU
     98 
     99 After installing `nixVulkanIntel`.
    100 
    101 ```bash
    102 $ sudo apt install mesa-vulkan-drivers
    103 ...
    104 $ nixVulkanIntel $(nix-build '<nixpkgs>' --no-out-link -A vulkan-tools)/bin/vulkaninfo | grep VkPhysicalDeviceProperties -A 7
    105 VkPhysicalDeviceProperties:
    106 ===========================
    107         apiVersion     = 0x400036  (1.0.54)
    108         driverVersion  = 71311368 (0x4402008)
    109         vendorID       = 0x8086
    110         deviceID       = 0x591b
    111         deviceType     = INTEGRATED_GPU
    112         deviceName     = Intel(R) HD Graphics 630 (Kaby Lake GT2)
    113 ```
    114 
    115 # Troubleshooting
    116 
    117 ## Nvidia auto detection does not work
    118 
    119 ```bash
    120 building '/nix/store/ijs5h6h07faai0k74diiy5b2xlxh891g-auto-detect-nvidia.drv'...
    121 pcregrep: Failed to open /proc/driver/nvidia/ersion: No such file or directory
    122 builder for '/nix/store/ijs5h6h07faai0k74diiy5b2xlxh891g-auto-detect-nvidia.drv' failed with exit code 2
    123 error: build of '/nix/store/ijs5h6h07faai0k74diiy5b2xlxh891g-auto-detect-nvidia.drv' faile
    124 ```
    125 
    126 You can run the Nvidia installer using an explicit version string instead of the automatic detection method:
    127 
    128 ```bash
    129 nix-build -A nixGLNvidia --argstr nvidiaVersion 440.82
    130 ```
    131 
    132 The version of your driver can be found using `glxinfo` from your system default package manager, or `nvidia-settings`.
    133 
    134 ## On nixOS
    135 
    136 `nixGL` can also be used on nixOS if the system is installed with a different
    137 nixpkgs clone than the one your application are installed with. Override the
    138 `pkgs` argument of the script with the correct nixpkgs clone:
    139 
    140 ```bash
    141 nix-build ./default.nix -A nixGLIntel --arg pkgs "import path_to_your_nixpkgs {}".
    142 ```
    143 
    144 ## Old nvidia drivers
    145 
    146 Users of Nvidia legacy driver should use the `backport/noGLVND` branch. This branch is not tested and may not work well, please open a bug report, it will be taken care of as soon as possible.
    147 
    148 # `nixGLCommon`
    149 
    150 `nixGLCommon nixGLXXX` can be used to get `nixGL` executable which fallsback to `nixGLXXX`. It is a shorter name for people with only one OpenGL configuration.
    151 
    152 For example:
    153 
    154 ```
    155 nix-build -E "with import ./default.nix {}; nixGLCommon nixGLIntel"
    156 ```
    157 
    158 # Using nixGL in your project
    159 
    160 
    161 
    162 
    163 # Limitations
    164 
    165 `nixGL` is badly tested, mostly because it is difficult to test automatically in a continuous integration context because you need access to different type of hardware.
    166 
    167 Some OpenGL configurations may not work, for example AMD proprietary drivers. There is no fundamental limitation, so if you want support for theses configurations, open an issue.
    168 
    169 # Hacking
    170 
    171 One great way to contribute to nixGL is to run the test suite. Just run
    172 `./Test.hs` in the main directory and check that all the test relevant to your
    173 hardware are green.