Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ lib 2, stdenv 3, fetchFromGitHub 4, nixosTests 5 6# Dependencies 7, bzip2 8, cmake 9, freetype 10, libGL 11, libjpeg_turbo 12, makeWrapper 13, mesa # for built-in 3D software rendering using swrast 14, openjdk # for the client with Java GUI 15, openjdk_headless # for the server 16, openssh 17, openssl 18, pam 19, perl 20, python3 21, which 22, xkbcomp 23, xkeyboard_config 24, xorg 25, xterm 26, zlib 27}: 28 29stdenv.mkDerivation rec { 30 pname = "turbovnc"; 31 version = "3.0.1"; 32 33 src = fetchFromGitHub { 34 owner = "TurboVNC"; 35 repo = "turbovnc"; 36 rev = version; 37 sha256 = "sha256-GRY6aW6Kvy5sDQRiOVz2cUgKEG0IMveh80S26/rGWdM="; 38 }; 39 40 # TODO: 41 # * Build outputs that are unclear: 42 # * `-- FONT_ENCODINGS_DIRECTORY = /var/empty/share/X11/fonts/encodings` 43 # Maybe relevant what the tigervnc and tightvnc derivations 44 # do with their `fontDirectories`? 45 # * `SERVER_MISC_CONFIG_PATH = /var/empty/lib64/xorg` 46 # * The thing about xorg `protocol.txt` 47 # * Does SSH support require `openssh` on PATH? 48 # * Add `enableClient ? true` flag that disables the client GUI 49 # so that the server can be built without openjdk dependency. 50 # * Perhaps allow to build the client on non-Linux platforms. 51 52 nativeBuildInputs = [ 53 cmake 54 makeWrapper 55 openjdk_headless 56 python3 57 ]; 58 59 buildInputs = [ 60 bzip2 61 freetype 62 libGL # for -DTVNC_SYSTEMX11=1 63 libjpeg_turbo 64 openssl 65 pam 66 perl 67 zlib 68 ] ++ (with xorg; [ 69 libfontenc # for -DTVNC_SYSTEMX11=1 70 libSM 71 libX11 72 libXdamage # for -DTVNC_SYSTEMX11=1 73 libXdmcp # for -DTVNC_SYSTEMX11=1 74 libXext 75 libXfont2 # for -DTVNC_SYSTEMX11=1 76 libxkbfile # for -DTVNC_SYSTEMX11=1 77 libXi 78 mesa # for -DTVNC_SYSTEMX11=1 79 pixman # for -DTVNC_SYSTEMX11=1 80 xorgproto 81 xtrans # for -DTVNC_SYSTEMX11=1 82 ]); 83 84 postPatch = '' 85 substituteInPlace unix/Xvnc/CMakeLists.txt --replace 'string(REGEX REPLACE "X11" "Xfont2" X11_Xfont2_LIB' 'set(X11_Xfont2_LIB ${xorg.libXfont2}/lib/libXfont2.so) #' 86 substituteInPlace unix/Xvnc/CMakeLists.txt --replace 'string(REGEX REPLACE "X11" "fontenc" X11_Fontenc_LIB' 'set(X11_Fontenc_LIB ${xorg.libfontenc}/lib/libfontenc.so) #' 87 substituteInPlace unix/Xvnc/CMakeLists.txt --replace 'string(REGEX REPLACE "X11" "pixman-1" X11_Pixman_LIB' 'set(X11_Pixman_LIB ${xorg.pixman}/lib/libpixman-1.so) #' 88 ''; 89 90 cmakeFlags = [ 91 # For the 3D software rendering built into TurboVNC, pass the path 92 # to the swrast dri driver in Mesa. 93 # Can also be given at runtime to its `Xvnc` as: 94 # -dridir /nix/store/...-mesa-20.1.10-drivers/lib/dri/ 95 "-DDRI_DRIVER_PATH=${mesa.drivers}/lib/dri" 96 # The build system doesn't find these files automatically. 97 "-DTJPEG_JAR=${libjpeg_turbo.out}/share/java/turbojpeg.jar" 98 "-DTJPEG_JNILIBRARY=${libjpeg_turbo.out}/lib/libturbojpeg.so" 99 "-DXKB_BASE_DIRECTORY=${xkeyboard_config}/share/X11/xkb" 100 "-DXKB_BIN_DIRECTORY=${xkbcomp}/bin" 101 # use system libs 102 "-DTVNC_SYSTEMLIBS=1" 103 "-DTVNC_SYSTEMX11=1" 104 "-DTVNC_DLOPENSSL=0" 105 ]; 106 107 postInstall = '' 108 # turbovnc dlopen()s libssl.so depending on the requested encryption. 109 wrapProgram $out/bin/Xvnc \ 110 --prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath [ openssl ]} 111 112 # `twm` is the default window manager that `vncserver` tries to start, 113 # and it has minimal dependencies (no non-Xorg). 114 # (This default is written by `vncserver` to `~/.vnc/xstartup.turbovnc`, 115 # see https://github.com/TurboVNC/turbovnc/blob/ffdb57d9/unix/vncserver.in#L201.) 116 # It checks for it using `which twm`. 117 # vncserver needs also needs `xauth` and we add in `xterm` for convenience 118 wrapProgram $out/bin/vncserver \ 119 --prefix PATH : ${lib.makeBinPath [ which xorg.twm xorg.xauth xterm ]} 120 121 # Patch /usr/bin/perl 122 patchShebangs $out/bin/vncserver 123 124 # The viewer is in Java and requires `JAVA_HOME` (which is a single 125 # path, cannot be multiple separated paths). 126 # For SSH support, `ssh` is required on `PATH`. 127 wrapProgram $out/bin/vncviewer \ 128 --set JAVA_HOME "${lib.makeLibraryPath [ openjdk ]}/openjdk" \ 129 --prefix PATH : ${lib.makeBinPath [ openssh ]} 130 ''; 131 132 passthru.tests.turbovnc-headless-server = nixosTests.turbovnc-headless-server; 133 134 meta = { 135 homepage = "https://turbovnc.org/"; 136 license = lib.licenses.gpl2Plus; 137 description = "High-speed version of VNC derived from TightVNC"; 138 maintainers = with lib.maintainers; [ nh2 ]; 139 platforms = with lib.platforms; linux; 140 changelog = "https://github.com/TurboVNC/turbovnc/blob/${version}/ChangeLog.md"; 141 }; 142}