summary refs log tree commit diff
path: root/nixos/modules/programs/turbovnc.nix
blob: e6f8836aa367f54f1c4bc524e70506ee4ac04c5a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# Global configuration for the SSH client.

{ config, lib, pkgs, ... }:

with lib;

let
  cfg = config.programs.turbovnc;
in
{
  options = {

    programs.turbovnc = {

      ensureHeadlessSoftwareOpenGL = mkOption {
        type = types.bool;
        default = false;
        description = ''
          Whether to set up NixOS such that TurboVNC's built-in software OpenGL
          implementation works.

          This will enable <option>hardware.opengl.enable</option> so that OpenGL
          programs can find Mesa's llvmpipe drivers.

          Setting this option to <code>false</code> does not mean that software
          OpenGL won't work; it may still work depending on your system
          configuration.

          This option is also intended to generate warnings if you are using some
          configuration that's incompatible with using headless software OpenGL
          in TurboVNC.
        '';
      };

    };

  };

  config = mkIf cfg.ensureHeadlessSoftwareOpenGL {

    # TurboVNC has builtin support for Mesa llvmpipe's `swrast`
    # software rendering to implemnt GLX (OpenGL on Xorg).
    # However, just building TurboVNC with support for that is not enough
    # (it only takes care of the X server side part of OpenGL);
    # the indiviudual applications (e.g. `glxgears`) also need to directly load
    # the OpenGL libs.
    # Thus, this creates `/run/opengl-driver` populated by Mesa so that the applications
    # can find the llvmpipe `swrast.so` software rendering DRI lib via `libglvnd`.
    # This comment exists to explain why `hardware.` is involved,
    # even though 100% software rendering is used.
    hardware.opengl.enable = true;

  };
}