nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 xorg,
6 xkeyboard_config,
7 zlib,
8 libjpeg_turbo,
9 pixman,
10 fltk,
11 cmake,
12 gettext,
13 libtool,
14 libGLU,
15 gnutls,
16 gawk,
17 pam,
18 nettle,
19 xterm,
20 openssh,
21 perl,
22 makeWrapper,
23 nixosTests,
24 ffmpeg,
25}:
26
27stdenv.mkDerivation (finalAttrs: {
28 version = "1.15.0";
29 pname = "tigervnc";
30
31 src = fetchFromGitHub {
32 owner = "TigerVNC";
33 repo = "tigervnc";
34 tag = "v${finalAttrs.version}";
35 hash = "sha256-ZuuvRJe/lAqULWObPxGHVJrDPCTK4IVSqX0K1rWOctw=";
36 };
37
38 postPatch =
39 lib.optionalString stdenv.hostPlatform.isLinux ''
40 sed -i -e '/^\$cmd \.= " -pn";/a$cmd .= " -xkbdir ${xkeyboard_config}/etc/X11/xkb";' unix/vncserver/vncserver.in
41 fontPath=
42 substituteInPlace vncviewer/vncviewer.cxx \
43 --replace '"/usr/bin/ssh' '"${openssh}/bin/ssh'
44 source_top="$(pwd)"
45 ''
46 + ''
47 # On Mac, do not build a .dmg, instead copy the .app to the source dir
48 gawk -i inplace 'BEGIN { del=0 } /hdiutil/ { del=2 } del<=0 { print } /$VERSION.dmg/ { del -= 1 }' release/makemacapp.in
49 echo "mv \"\$APPROOT\" \"\$SRCDIR/\"" >> release/makemacapp.in
50 '';
51
52 dontUseCmakeBuildDir = true;
53
54 cmakeFlags = [
55 "-DCMAKE_INSTALL_PREFIX=${placeholder "out"}"
56 "-DCMAKE_INSTALL_SBINDIR=${placeholder "out"}/bin"
57 "-DCMAKE_INSTALL_LIBEXECDIR=${placeholder "out"}/bin"
58 ];
59
60 env.NIX_CFLAGS_COMPILE = toString [
61 "-Wno-error=array-bounds"
62 ];
63
64 postBuild =
65 lib.optionalString stdenv.hostPlatform.isLinux ''
66 export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -Wno-error=int-to-pointer-cast -Wno-error=pointer-to-int-cast"
67 export CXXFLAGS="$CXXFLAGS -fpermissive"
68 # Build Xvnc
69 tar xf ${xorg.xorgserver.src}
70 cp -R xorg*/* unix/xserver
71 pushd unix/xserver
72 version=$(echo ${xorg.xorgserver.name} | sed 's/.*-\([0-9]\+\).[0-9]\+.*/\1/g')
73 patch -p1 < "$source_top/unix/xserver$version.patch"
74 autoreconf -vfi
75 ./configure $configureFlags --disable-devel-docs --disable-docs \
76 --disable-xorg --disable-xnest --disable-xvfb --disable-dmx \
77 --disable-xwin --disable-xephyr --disable-kdrive --with-pic \
78 --disable-xorgcfg --disable-xprint --disable-static \
79 --enable-composite --disable-xtrap --enable-xcsecurity \
80 --disable-{a,c,m}fb \
81 --disable-xwayland \
82 --disable-config-dbus --disable-config-udev --disable-config-hal \
83 --disable-xevie \
84 --disable-dri --disable-dri2 --disable-dri3 --enable-glx \
85 --enable-install-libxf86config \
86 --prefix="$out" --disable-unit-tests \
87 --with-xkb-path=${xkeyboard_config}/share/X11/xkb \
88 --with-xkb-bin-directory=${xorg.xkbcomp}/bin \
89 --with-xkb-output=$out/share/X11/xkb/compiled
90 make TIGERVNC_SRC=$src TIGERVNC_BUILDDIR=`pwd`/../.. -j$NIX_BUILD_CORES
91 popd
92 ''
93 + lib.optionalString stdenv.hostPlatform.isDarwin ''
94 make dmg
95 '';
96
97 postInstall =
98 lib.optionalString stdenv.hostPlatform.isLinux ''
99 pushd unix/xserver/hw/vnc
100 make TIGERVNC_SRC=$src TIGERVNC_BUILDDIR=`pwd`/../../../.. install
101 popd
102 rm -f $out/lib/xorg/protocol.txt
103
104 wrapProgram $out/bin/vncserver \
105 --prefix PATH : ${
106 lib.makeBinPath (
107 with xorg;
108 [
109 xterm
110 twm
111 xsetroot
112 xauth
113 ]
114 )
115 }
116 ''
117 + lib.optionalString stdenv.hostPlatform.isDarwin ''
118 mkdir -p $out/Applications
119 mv 'TigerVNC Viewer ${finalAttrs.version}.app' $out/Applications/
120 rm $out/bin/vncviewer
121 echo "#!/usr/bin/env bash
122 open $out/Applications/TigerVNC\ Viewer\ ${finalAttrs.version}.app --args \$@" >> $out/bin/vncviewer
123 chmod +x $out/bin/vncviewer
124 '';
125
126 buildInputs = [
127 fltk
128 gnutls
129 libjpeg_turbo
130 pixman
131 gawk
132 ffmpeg
133 ]
134 ++ lib.optionals stdenv.hostPlatform.isLinux (
135 with xorg;
136 [
137 nettle
138 pam
139 perl
140 xorgproto
141 utilmacros
142 libXtst
143 libXext
144 libX11
145 libXext
146 libICE
147 libXi
148 libSM
149 libXft
150 libxkbfile
151 libXfont2
152 libpciaccess
153 libGLU
154 libXrandr
155 libXdamage
156 ]
157 ++ xorg.xorgserver.buildInputs
158 );
159
160 nativeBuildInputs = [
161 cmake
162 gettext
163 ]
164 ++ lib.optionals stdenv.hostPlatform.isLinux (
165 with xorg;
166 [
167 fontutil
168 libtool
169 makeWrapper
170 utilmacros
171 zlib
172 ]
173 ++ xorg.xorgserver.nativeBuildInputs
174 );
175
176 propagatedBuildInputs = lib.optional stdenv.hostPlatform.isLinux xorg.xorgserver.propagatedBuildInputs;
177
178 passthru.tests.tigervnc = nixosTests.tigervnc;
179
180 meta = {
181 homepage = "https://tigervnc.org/";
182 license = lib.licenses.gpl2Plus;
183 description = "Fork of tightVNC, made in cooperation with VirtualGL";
184 maintainers = [ ];
185 platforms = lib.platforms.unix;
186 broken = stdenv.hostPlatform.isDarwin;
187 # Prevent a store collision.
188 priority = 4;
189 };
190})