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