Merge branch 'staging' into core-updates
[jackhill/guix/guix.git] / gnu / packages / tigervnc.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2019 Todor Kondić <tk.code@protonmail.com>
3 ;;; Copyright © 2020 Oleg Pykhalov <go.wigust@gmail.com>
4 ;;;
5 ;;; This file is part of GNU Guix.
6 ;;;
7 ;;; GNU Guix is free software; you can redistribute it and/or modify it
8 ;;; under the terms of the GNU General Public License as published by
9 ;;; the Free Software Foundation; either version 3 of the License, or (at
10 ;;; your option) any later version.
11 ;;;
12 ;;; GNU Guix is distributed in the hope that it will be useful, but
13 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ;;; GNU General Public License for more details.
16 ;;;
17 ;;; You should have received a copy of the GNU General Public License
18 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
19
20 (define-module (gnu packages tigervnc)
21 #:use-module (gnu packages autotools)
22 #:use-module (gnu packages compression)
23 #:use-module (gnu packages gettext)
24 #:use-module (gnu packages tls)
25 #:use-module (gnu packages linux)
26 #:use-module (gnu packages xorg)
27 #:use-module (gnu packages fltk)
28 #:use-module (gnu packages image)
29 #:use-module (gnu packages cmake)
30 #:use-module (gnu packages perl)
31 #:use-module (gnu packages base)
32 #:use-module (gnu packages commencement)
33 #:use-module (guix build-system cmake)
34 #:use-module (guix packages)
35 #:use-module (guix download)
36 #:use-module (guix git-download)
37 #:use-module (guix utils)
38 #:use-module ((guix licenses) #:prefix license:))
39
40 (define-public tigervnc-client
41 (package
42 (name "tigervnc-client")
43 (version "1.10.1")
44 (source
45 (origin
46 (method git-fetch)
47 (uri
48 (git-reference
49 (url "https://github.com/TigerVNC/tigervnc.git")
50 (commit (string-append "v" version))))
51 (file-name (git-file-name name version))
52 (sha256
53 (base32
54 "001n189d2f3psn7nxgl8188ml6f7jbk26cxn2835y3mnlk5lmhgr"))))
55 (build-system cmake-build-system)
56 (arguments
57 '(#:tests? #f ; Tests that do exists are not automated.
58 #:phases (modify-phases %standard-phases
59 (replace 'install
60 (lambda* (#:key outputs #:allow-other-keys)
61 (with-directory-excursion "vncviewer"
62 (invoke "make" "install")))))))
63 (native-inputs
64 `(("autoconf" ,autoconf)
65 ("gettext-minimal" ,gettext-minimal)
66 ("automake" ,automake)))
67 (inputs
68 `(("zlib" ,zlib)
69 ("gnutls" ,gnutls)
70 ("libjpeg-turbo" ,libjpeg-turbo)
71 ("fltk" ,fltk)
72 ("linux-pam" ,linux-pam)
73 ("libx11" ,libx11)
74 ("libxext" ,libxext)
75 ("libxtst" ,libxtst)
76 ("libxrandr" ,libxrandr)
77 ("libxdamage" ,libxdamage)))
78 (home-page "https://tigervnc.org/")
79 (synopsis "High-performance, platform-neutral
80 implementation of VNC (client)")
81 (description "TigerVNC is a client/server implementation of VNC (Virtual
82 Network Computing). It provides enough performance to run even 3D and video
83 applications. It also provides extensions for advanced authentication methods
84 and TLS encryption. This package installs only the VNC client, the
85 application which is needed to connect to VNC servers.")
86 (license license:gpl2)))
87
88 ;; A VNC server is, in fact, an X server so it seems like a good idea
89 ;; to build on the work already done for xorg-server package. This is
90 ;; not entirely compatible with the recommendation in BUILDING.txt
91 ;; where the client is built first, then the source code of the X
92 ;; server is copied into a subdir of the build directory, patched with
93 ;; VNC additions and then build and installed as Xvnc. The procedure
94 ;; was turned around, where TigerVNC code is downloaded and built
95 ;; inside the Guix X server build dir. Also, the VNC patching process
96 ;; for the X server is automated in a straightforward manner.
97 (define-public tigervnc-server
98 (package
99 (inherit xorg-server)
100 (name "tigervnc-server")
101 (version "1.10.1")
102 (native-inputs
103 `(("tigervnc-src" ,(origin
104 (method git-fetch)
105 (uri
106 (git-reference
107 (url "https://github.com/TigerVNC/tigervnc.git")
108 (commit "v1.9.0")))
109 (sha256
110 (base32
111 "0b47fg3741qs3zdpl2zr0s6jz46dypp2j6gqrappbzm3ywnnmm1x"))))
112 ("autoconf" ,autoconf)
113 ("automake" ,automake)
114 ("libtool" ,libtool)
115 ("gettext-minimal" ,gettext-minimal)
116 ("font-util" ,font-util)
117 ("cmake" ,cmake)
118 ("gcc-toolchain" ,gcc-toolchain)
119 ("perl" ,perl)
120 ,@(package-native-inputs tigervnc-client)
121 ,@(package-inputs tigervnc-client)
122 ,@(package-native-inputs xorg-server)))
123 (inputs
124 `(("perl" ,perl)
125 ("coreutils" ,coreutils)
126 ("xauth" ,xauth)
127 ,@(package-inputs xorg-server)))
128 (propagated-inputs
129 `(("xauth" ,xauth)
130 ,@(package-propagated-inputs xorg-server)))
131 (arguments
132 (substitute-keyword-arguments
133 (package-arguments xorg-server)
134 ((#:configure-flags flags)
135 `(append '("--with-pic" ; Taken from BUILDING.txt
136 "--without-dtrace"
137 "--disable-static"
138 "--disable-dri2"
139 "--disable-xinerama"
140 "--disable-xvfb"
141 "--disable-xnest"
142 "--disable-xorg"
143 "--disable-dmx"
144 "--disable-xwin"
145 "--disable-xephyr"
146 "--disable-kdrive"
147 ;; "--disable-config-dbus" ; This was a warning.
148 "--disable-config-hal"
149 "--disable-config-udev"
150 "--disable-dri2"
151 ;; "--enable-install-libxf86config" ; This, too, was a warning.
152 "--enable-glx")
153 (delete "--enable-xephyr" ,flags)))
154 ((#:modules modules)
155 `(append '((ice-9 ftw)
156 (ice-9 match)
157 (guix build utils)
158 (guix build gnu-build-system))
159 modules))
160 ((#:phases phases)
161 `(modify-phases ,phases
162 (delete 'check) ;)
163 (add-after 'unpack 'copy-tvnc-xserver
164 (lambda _
165 (let*
166 ((tvnc-src (assoc-ref %build-inputs "tigervnc-src"))
167 (tvnc-xserver (string-append tvnc-src "/unix/xserver")))
168 (copy-recursively tvnc-xserver ".")
169 #t)))
170 (add-after 'copy-tvnc-xserver 'patch-xserver
171 (lambda _
172 (let*
173 ((tvnc-src (assoc-ref %build-inputs "tigervnc-src"))
174 (xorg-server-version ,(package-version xorg-server))
175 (which-patch (lambda ()
176 (let*
177 ((patch-num (apply string-append
178 (list-head (string-split xorg-server-version
179 #\.)
180 2)))
181 (fn (format "~a/unix/xserver~a.patch" tvnc-src patch-num)))
182 (when (not (file-exists? fn))
183 (error (format "Patch file, ~a,
184 corresponding to the input xorg-server version, does not exist. Installation
185 will fail. " fn)))
186
187 fn))) ; VNC patches for xserver have the
188 ; form xserverXY[Y].patch, where
189 ; X.Y[Y].Z is the Xorg server
190 ; version.
191 (xserver-patch (which-patch)))
192 (invoke "patch" "-p1" "-i" xserver-patch)
193 (invoke "autoreconf" "-fiv"))))
194 (add-before 'build 'build-tigervnc
195 (lambda _
196 (let* ((out (assoc-ref %outputs "out"))
197 (tvnc-src (assoc-ref %build-inputs "tigervnc-src"))
198 (tvnc-build (string-append (getcwd) "/tigervnc-build")))
199 (mkdir-p tvnc-build)
200 (with-directory-excursion tvnc-build
201 (invoke "cmake" "-G" "Unix Makefiles"
202 (string-append "-DCMAKE_INSTALL_PREFIX=" out)
203 tvnc-src)
204 (invoke "make" "-j" (number->string (parallel-job-count)))))))
205 (replace 'build
206 (lambda _
207 (let* ((tvnc-src (assoc-ref %build-inputs "tigervnc-src"))
208 (tvnc-build (string-append (getcwd) "/tigervnc-build"))
209 (srcarg (string-append "TIGERVNC_SRCDIR=" tvnc-src))
210 (buildarg (string-append "TIGERVNC_BUILDDIR=" tvnc-build)))
211 (invoke "make" srcarg buildarg "-j"
212 (number->string (parallel-job-count))))))
213 (add-before 'install 'install-tigervnc-aux
214 (lambda _
215 (let* ((out (assoc-ref %outputs 'out))
216 (tvnc-src (assoc-ref %build-inputs "tigervnc-src"))
217 (tvnc-build (string-append (getcwd) "/tigervnc-build"))
218 (srcarg (string-append "TIGERVNC_SRCDIR=" tvnc-src))
219 (buildarg (string-append "TIGERVNC_BUILDDIR=" tvnc-build)))
220 (with-directory-excursion (string-append tvnc-build "/unix")
221 (invoke "make" srcarg buildarg "install")))))
222 (replace 'install
223 (lambda* _
224 (let* ((tvnc-src (assoc-ref %build-inputs "tigervnc-src"))
225 (tvnc-build (string-append (getcwd) "/tigervnc-build"))
226 (srcarg (string-append "TIGERVNC_SRCDIR=" tvnc-src))
227 (buildarg (string-append "TIGERVNC_BUILDDIR=" tvnc-build)))
228 (invoke "make" "install" srcarg buildarg))))))))
229 (description "TigerVNC is a client/server implementation of VNC (Virtual
230 Network Computing). It provides enough performance to run even 3D and video
231 applications. It also provides extensions for advanced authentication methods
232 and TLS encryption. This package installs the VNC server, a program that will
233 enable users with VNC clients to log into a graphical session on the machine
234 where the server is installed.")))