wine.scm 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2014, 2015 Sou Bunnbu <iyzsong@gmail.com>
  3. ;;; Copyright © 2016 Ricardo Wurmus <rekado@elephly.net>
  4. ;;; Copyright © 2016, 2017, 2018 Efraim Flashner <efraim@flashner.co.il>
  5. ;;; Copyright © 2017, 2018, 2019 Rutger Helling <rhelling@mykolab.com>
  6. ;;; Copyright © 2017, 2020 Nicolas Goaziou <mail@nicolasgoaziou.fr>
  7. ;;; Copyright © 2018, 2019, 2020 Tobias Geerinckx-Rice <me@tobias.gr>
  8. ;;; Copyright © 2019 Pierre Neidhardt <mail@ambrevar.xyz>
  9. ;;;
  10. ;;; This file is part of GNU Guix.
  11. ;;;
  12. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  13. ;;; under the terms of the GNU General Public License as published by
  14. ;;; the Free Software Foundation; either version 3 of the License, or (at
  15. ;;; your option) any later version.
  16. ;;;
  17. ;;; GNU Guix is distributed in the hope that it will be useful, but
  18. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  19. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. ;;; GNU General Public License for more details.
  21. ;;;
  22. ;;; You should have received a copy of the GNU General Public License
  23. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  24. (define-module (gnu packages wine)
  25. #:use-module ((guix licenses) #:prefix license:)
  26. #:use-module (guix packages)
  27. #:use-module (guix download)
  28. #:use-module (guix git-download)
  29. #:use-module (guix utils)
  30. #:use-module (guix build-system gnu)
  31. #:use-module (guix build-system meson)
  32. #:use-module (guix build-system trivial)
  33. #:use-module (gnu packages)
  34. #:use-module (gnu packages admin)
  35. #:use-module (gnu packages audio)
  36. #:use-module (gnu packages autotools)
  37. #:use-module (gnu packages base)
  38. #:use-module (gnu packages bash)
  39. #:use-module (gnu packages bison)
  40. #:use-module (gnu packages cups)
  41. #:use-module (gnu packages databases)
  42. #:use-module (gnu packages fontutils)
  43. #:use-module (gnu packages flex)
  44. #:use-module (gnu packages image)
  45. #:use-module (gnu packages gcc)
  46. #:use-module (gnu packages gettext)
  47. #:use-module (gnu packages ghostscript)
  48. #:use-module (gnu packages gl)
  49. #:use-module (gnu packages glib)
  50. #:use-module (gnu packages gstreamer)
  51. #:use-module (gnu packages gtk)
  52. #:use-module (gnu packages kerberos)
  53. #:use-module (gnu packages libusb)
  54. #:use-module (gnu packages linux)
  55. #:use-module (gnu packages mingw)
  56. #:use-module (gnu packages openldap)
  57. #:use-module (gnu packages perl)
  58. #:use-module (gnu packages pulseaudio)
  59. #:use-module (gnu packages pkg-config)
  60. #:use-module (gnu packages python)
  61. #:use-module (gnu packages mp3)
  62. #:use-module (gnu packages photo)
  63. #:use-module (gnu packages samba)
  64. #:use-module (gnu packages scanner)
  65. #:use-module (gnu packages sdl)
  66. #:use-module (gnu packages tls)
  67. #:use-module (gnu packages video)
  68. #:use-module (gnu packages vulkan)
  69. #:use-module (gnu packages xml)
  70. #:use-module (gnu packages xorg)
  71. #:use-module (ice-9 match)
  72. #:use-module (srfi srfi-1))
  73. (define-public wine
  74. (package
  75. (name "wine")
  76. (version "6.16")
  77. (source
  78. (origin
  79. (method url-fetch)
  80. (uri (let ((dir (string-append
  81. (version-major version)
  82. (if (string-suffix? ".0" (version-major+minor version))
  83. ".0/"
  84. ".x/"))))
  85. (string-append "https://dl.winehq.org/wine/source/" dir
  86. "wine-" version ".tar.xz")))
  87. (sha256
  88. (base32 "1s7sz1rimax4kxij1ngkwnx4hcljwjq3q5gksz22k8cq1l2r4l39"))))
  89. (build-system gnu-build-system)
  90. (native-inputs
  91. `(("bison" ,bison)
  92. ("flex" ,flex)
  93. ("gettext" ,gettext-minimal)
  94. ("perl" ,perl)
  95. ("pkg-config" ,pkg-config)))
  96. (inputs
  97. `(("alsa-lib" ,alsa-lib)
  98. ("dbus" ,dbus)
  99. ("cups" ,cups)
  100. ("eudev" ,eudev)
  101. ("faudio" ,faudio)
  102. ("fontconfig" ,fontconfig)
  103. ("freetype" ,freetype)
  104. ("gnutls" ,gnutls)
  105. ("gst-plugins-base" ,gst-plugins-base)
  106. ("lcms" ,lcms)
  107. ("libxml2" ,libxml2)
  108. ("libxslt" ,libxslt)
  109. ("libgphoto2" ,libgphoto2)
  110. ("libmpg123" ,mpg123)
  111. ("libldap" ,openldap)
  112. ("libnetapi" ,samba)
  113. ("libsane" ,sane-backends)
  114. ("libpcap" ,libpcap)
  115. ("libpng" ,libpng)
  116. ("libjpeg" ,libjpeg-turbo)
  117. ("libusb" ,libusb)
  118. ("libtiff" ,libtiff)
  119. ("libICE" ,libice)
  120. ("libX11" ,libx11)
  121. ("libXi" ,libxi)
  122. ("libXext" ,libxext)
  123. ("libXcursor" ,libxcursor)
  124. ("libXrender" ,libxrender)
  125. ("libXrandr" ,libxrandr)
  126. ("libXinerama" ,libxinerama)
  127. ("libXxf86vm" ,libxxf86vm)
  128. ("libXcomposite" ,libxcomposite)
  129. ("mit-krb5" ,mit-krb5)
  130. ("openal" ,openal)
  131. ("pulseaudio" ,pulseaudio)
  132. ("sdl2" ,sdl2)
  133. ("unixodbc" ,unixodbc)
  134. ("v4l-utils" ,v4l-utils)
  135. ("vkd3d" ,vkd3d)
  136. ("vulkan-loader" ,vulkan-loader)))
  137. (arguments
  138. `(;; Force a 32-bit build targeting a similar architecture, i.e.:
  139. ;; armhf for armhf/aarch64, i686 for i686/x86_64.
  140. #:system ,@(match (%current-system)
  141. ((or "armhf-linux" "aarch64-linux")
  142. `("armhf-linux"))
  143. (_
  144. `("i686-linux")))
  145. ;; XXX: There's a test suite, but it's unclear whether it's supposed to
  146. ;; pass.
  147. #:tests? #f
  148. #:configure-flags
  149. (list (string-append "LDFLAGS=-Wl,-rpath=" %output "/lib/wine32"))
  150. #:make-flags
  151. (list "SHELL=bash"
  152. (string-append "libdir=" %output "/lib/wine32"))
  153. #:phases
  154. (modify-phases %standard-phases
  155. ;; Explicitly set the 32-bit version of vulkan-loader when installing
  156. ;; to i686-linux or x86_64-linux.
  157. ;; TODO: Add more JSON files as they become available in Mesa.
  158. ,@(match (%current-system)
  159. ((or "i686-linux" "x86_64-linux")
  160. `((add-after 'install 'wrap-executable
  161. (lambda* (#:key inputs outputs #:allow-other-keys)
  162. (let* ((out (assoc-ref outputs "out"))
  163. (icd (string-append out "/share/vulkan/icd.d")))
  164. (mkdir-p icd)
  165. (copy-file (string-append
  166. (assoc-ref inputs "mesa")
  167. "/share/vulkan/icd.d/radeon_icd.i686.json")
  168. (string-append icd "/radeon_icd.i686.json"))
  169. (copy-file (string-append
  170. (assoc-ref inputs "mesa")
  171. "/share/vulkan/icd.d/intel_icd.i686.json")
  172. (string-append icd "/intel_icd.i686.json"))
  173. (wrap-program (string-append out "/bin/wine-preloader")
  174. `("VK_ICD_FILENAMES" ":" =
  175. (,(string-append icd
  176. "/radeon_icd.i686.json" ":"
  177. icd "/intel_icd.i686.json"))))
  178. #t)))))
  179. (_
  180. `()))
  181. (add-after 'configure 'patch-dlopen-paths
  182. ;; Hardcode dlopened sonames to absolute paths.
  183. (lambda _
  184. (let* ((library-path (search-path-as-string->list
  185. (getenv "LIBRARY_PATH")))
  186. (find-so (lambda (soname)
  187. (search-path library-path soname))))
  188. (substitute* "include/config.h"
  189. (("(#define SONAME_.* )\"(.*)\"" _ defso soname)
  190. (format #f "~a\"~a\"" defso (find-so soname))))
  191. #t)))
  192. (add-after 'patch-generated-file-shebangs 'patch-makefile
  193. (lambda* (#:key outputs #:allow-other-keys)
  194. (invoke "make" "Makefile") ; Makefile is first regenerated
  195. (substitute* "Makefile"
  196. (("-lntdll" id)
  197. (string-append id
  198. " -Wl,-rpath=" (assoc-ref outputs "out")
  199. "/lib/wine32/wine/$(ARCH)-unix")))
  200. #t)))))
  201. (home-page "https://www.winehq.org/")
  202. (synopsis "Implementation of the Windows API (32-bit only)")
  203. (description
  204. "Wine (originally an acronym for \"Wine Is Not an Emulator\") is a
  205. compatibility layer capable of running Windows applications. Instead of
  206. simulating internal Windows logic like a virtual machine or emulator, Wine
  207. translates Windows API calls into POSIX calls on-the-fly, eliminating the
  208. performance and memory penalties of other methods and allowing you to cleanly
  209. integrate Windows applications into your desktop.")
  210. ;; Any platform should be able to build wine, but based on '#:system' these
  211. ;; are thr ones we currently support.
  212. (supported-systems '("i686-linux" "x86_64-linux" "armhf-linux"))
  213. (license license:lgpl2.1+)))
  214. (define-public wine64
  215. (package
  216. (inherit wine)
  217. (name "wine64")
  218. (inputs `(("wine" ,wine)
  219. ,@(package-inputs wine)))
  220. (arguments
  221. `(#:make-flags
  222. (list "SHELL=bash"
  223. (string-append "libdir=" %output "/lib/wine64"))
  224. #:phases
  225. (modify-phases %standard-phases
  226. ;; Explicitly set both the 64-bit and 32-bit versions of vulkan-loader
  227. ;; when installing to x86_64-linux so both are available.
  228. ;; TODO: Add more JSON files as they become available in Mesa.
  229. ,@(match (%current-system)
  230. ((or "x86_64-linux")
  231. `((add-after 'copy-wine32-binaries 'wrap-executable
  232. (lambda* (#:key inputs outputs #:allow-other-keys)
  233. (let* ((out (assoc-ref outputs "out")))
  234. (wrap-program (string-append out "/bin/wine-preloader")
  235. `("VK_ICD_FILENAMES" ":" =
  236. (,(string-append
  237. (assoc-ref inputs "mesa")
  238. "/share/vulkan/icd.d/radeon_icd.x86_64.json" ":"
  239. (assoc-ref inputs "mesa")
  240. "/share/vulkan/icd.d/intel_icd.x86_64.json" ":"
  241. (assoc-ref inputs "wine")
  242. "/share/vulkan/icd.d/radeon_icd.i686.json" ":"
  243. (assoc-ref inputs "wine")
  244. "/share/vulkan/icd.d/intel_icd.i686.json"))))
  245. (wrap-program (string-append out "/bin/wine64-preloader")
  246. `("VK_ICD_FILENAMES" ":" =
  247. (,(string-append
  248. (assoc-ref inputs "mesa")
  249. "/share/vulkan/icd.d/radeon_icd.x86_64.json"
  250. ":" (assoc-ref inputs "mesa")
  251. "/share/vulkan/icd.d/intel_icd.x86_64.json"
  252. ":" (assoc-ref inputs "wine")
  253. "/share/vulkan/icd.d/radeon_icd.i686.json"
  254. ":" (assoc-ref inputs "wine")
  255. "/share/vulkan/icd.d/intel_icd.i686.json"))))
  256. #t)))))
  257. (_
  258. `()))
  259. (add-after 'patch-generated-file-shebangs 'patch-makefile
  260. (lambda* (#:key outputs #:allow-other-keys)
  261. (invoke "make" "Makefile") ; Makefile is first regenerated
  262. (substitute* "Makefile"
  263. (("-lntdll" id)
  264. (string-append id
  265. " -Wl,-rpath=" (assoc-ref outputs "out")
  266. "/lib/wine64/wine/$(ARCH)-unix")))
  267. #t))
  268. (add-after 'install 'copy-wine32-binaries
  269. (lambda* (#:key outputs #:allow-other-keys)
  270. (let* ((wine32 (assoc-ref %build-inputs "wine"))
  271. (out (assoc-ref %outputs "out")))
  272. ;; Copy the 32-bit binaries needed for WoW64.
  273. (copy-file (string-append wine32 "/bin/wine")
  274. (string-append out "/bin/wine"))
  275. ;; Copy the real 32-bit wine-preloader instead of the wrapped
  276. ;; version.
  277. (copy-file (string-append wine32 "/bin/.wine-preloader-real")
  278. (string-append out "/bin/wine-preloader"))
  279. #t)))
  280. (add-after 'install 'copy-wine32-libraries
  281. (lambda* (#:key outputs #:allow-other-keys)
  282. (let* ((wine32 (assoc-ref %build-inputs "wine"))
  283. (out (assoc-ref %outputs "out")))
  284. (copy-recursively (string-append wine32 "/lib/wine32")
  285. (string-append out "/lib/wine32"))
  286. #t)))
  287. (add-after 'compress-documentation 'copy-wine32-manpage
  288. (lambda* (#:key outputs #:allow-other-keys)
  289. (let* ((wine32 (assoc-ref %build-inputs "wine"))
  290. (out (assoc-ref %outputs "out")))
  291. ;; Copy the missing man file for the wine binary from wine.
  292. (copy-file (string-append wine32 "/share/man/man1/wine.1.gz")
  293. (string-append out "/share/man/man1/wine.1.gz"))
  294. #t)))
  295. (add-after 'configure 'patch-dlopen-paths
  296. ;; Hardcode dlopened sonames to absolute paths.
  297. (lambda _
  298. (let* ((library-path (search-path-as-string->list
  299. (getenv "LIBRARY_PATH")))
  300. (find-so (lambda (soname)
  301. (search-path library-path soname))))
  302. (substitute* "include/config.h"
  303. (("(#define SONAME_.* )\"(.*)\"" _ defso soname)
  304. (format #f "~a\"~a\"" defso (find-so soname))))
  305. #t))))
  306. #:configure-flags
  307. (list "--enable-win64"
  308. (string-append "LDFLAGS=-Wl,-rpath=" %output "/lib/wine64"))
  309. ,@(strip-keyword-arguments '(#:configure-flags #:make-flags #:phases
  310. #:system)
  311. (package-arguments wine))))
  312. (synopsis "Implementation of the Windows API (WoW64 version)")
  313. (supported-systems '("x86_64-linux" "aarch64-linux"))))
  314. ;; This minimal build of Wine is needed to prevent a circular dependency with
  315. ;; vkd3d.
  316. (define-public wine-minimal
  317. (package
  318. (inherit wine)
  319. (name "wine-minimal")
  320. (native-inputs (fold alist-delete (package-native-inputs wine)
  321. '("gettext" "perl" "pkg-config")))
  322. (inputs `())
  323. (arguments
  324. `(#:validate-runpath? #f
  325. #:phases
  326. (modify-phases %standard-phases
  327. (add-after 'configure 'patch-dlopen-paths
  328. ;; Hardcode dlopened sonames to absolute paths.
  329. (lambda _
  330. (let* ((library-path (search-path-as-string->list
  331. (getenv "LIBRARY_PATH")))
  332. (find-so (lambda (soname)
  333. (search-path library-path soname))))
  334. (substitute* "include/config.h"
  335. (("(#define SONAME_.* )\"(.*)\"" _ defso soname)
  336. (format #f "~a\"~a\"" defso (find-so soname))))
  337. #t))))
  338. #:configure-flags
  339. (list "--without-freetype"
  340. "--without-x")
  341. ,@(strip-keyword-arguments '(#:configure-flags #:phases)
  342. (package-arguments wine))))))
  343. (define-public wine-staging-patchset-data
  344. (package
  345. (name "wine-staging-patchset-data")
  346. (version "6.6")
  347. (source
  348. (origin
  349. (method git-fetch)
  350. (uri (git-reference
  351. (url "https://github.com/wine-staging/wine-staging")
  352. (commit (string-append "v" version))))
  353. (file-name (git-file-name name version))
  354. (sha256
  355. (base32 "0d5m9pvafr0iw99ny7rgzfmw7zw45q5wfcw68zj88mvzs47xkgms"))))
  356. (build-system trivial-build-system)
  357. (native-inputs
  358. `(("bash" ,bash)
  359. ("coreutils" ,coreutils)))
  360. (arguments
  361. `(#:modules ((guix build utils))
  362. #:builder
  363. (begin
  364. (use-modules (guix build utils))
  365. (let* ((build-directory ,(string-append name "-" version))
  366. (source (assoc-ref %build-inputs "source"))
  367. (bash (assoc-ref %build-inputs "bash"))
  368. (coreutils (assoc-ref %build-inputs "coreutils"))
  369. (out (assoc-ref %outputs "out"))
  370. (wine-staging (string-append out "/share/wine-staging")))
  371. (copy-recursively source build-directory)
  372. (with-directory-excursion build-directory
  373. (substitute* "patches/patchinstall.sh"
  374. (("/bin/sh")
  375. (string-append bash "/bin/sh")))
  376. (substitute* "patches/gitapply.sh"
  377. (("/usr/bin/env")
  378. (string-append coreutils "/bin/env"))))
  379. (copy-recursively build-directory wine-staging)
  380. #t))))
  381. (home-page "https://github.com/wine-staging")
  382. (synopsis "Patchset for Wine")
  383. (description
  384. "wine-staging-patchset-data contains the patchset to build Wine-Staging.")
  385. (license license:lgpl2.1+)))
  386. (define-public wine-staging
  387. (package
  388. (inherit wine)
  389. (name "wine-staging")
  390. (version (package-version wine-staging-patchset-data))
  391. (source
  392. (let* ((wine-version (version-major+minor version))
  393. (subdirectory (string-append
  394. (version-major version)
  395. (if (string-suffix? ".0" wine-version)
  396. ".0"
  397. ".x"))))
  398. (origin
  399. (method url-fetch)
  400. (uri (string-append "https://dl.winehq.org/wine/source/"
  401. subdirectory "/"
  402. "wine-" wine-version ".tar.xz"))
  403. (file-name (string-append name "-" wine-version ".tar.xz"))
  404. (sha256
  405. (base32 "1bc4zmqpdqs1ncz3qisp8a313pqzi5a31gq1s99ivb60vk325rcr")))))
  406. (inputs `(("autoconf" ,autoconf) ; for autoreconf
  407. ("ffmpeg" ,ffmpeg)
  408. ("gtk+" ,gtk+)
  409. ("libva" ,libva)
  410. ("mesa" ,mesa)
  411. ("python" ,python)
  412. ("util-linux" ,util-linux) ; for hexdump
  413. ("wine-staging-patchset-data" ,wine-staging-patchset-data)
  414. ,@(package-inputs wine)))
  415. (arguments
  416. `(#:phases
  417. (modify-phases %standard-phases
  418. ;; Explicitly set the 32-bit version of vulkan-loader when installing
  419. ;; to i686-linux or x86_64-linux.
  420. ;; TODO: Add more JSON files as they become available in Mesa.
  421. ,@(match (%current-system)
  422. ((or "i686-linux" "x86_64-linux")
  423. `((add-after 'install 'wrap-executable
  424. (lambda* (#:key inputs outputs #:allow-other-keys)
  425. (let* ((out (assoc-ref outputs "out"))
  426. (icd (string-append out "/share/vulkan/icd.d")))
  427. (mkdir-p icd)
  428. (copy-file (search-input-file inputs
  429. "/share/vulkan/icd.d/radeon_icd.i686.json")
  430. (string-append icd "/radeon_icd.i686.json"))
  431. (copy-file (search-input-file inputs
  432. "/share/vulkan/icd.d/intel_icd.i686.json")
  433. (string-append icd "/intel_icd.i686.json"))
  434. (wrap-program (string-append out "/bin/wine-preloader")
  435. `("VK_ICD_FILENAMES" ":" =
  436. (,(string-append icd
  437. "/radeon_icd.i686.json" ":"
  438. icd "/intel_icd.i686.json"))))
  439. #t)))))
  440. (_
  441. `())
  442. )
  443. (add-before 'configure 'patch-source-wine-staging
  444. (lambda* (#:key outputs #:allow-other-keys)
  445. (let* ((source (assoc-ref %build-inputs "source"))
  446. (script (string-append (assoc-ref %build-inputs
  447. "wine-staging-patchset-data")
  448. "/share/wine-staging/patches/patchinstall.sh")))
  449. (invoke script (string-append "DESTDIR=" ".") "--all")
  450. #t)))
  451. (add-after 'configure 'patch-dlopen-paths
  452. ;; Hardcode dlopened sonames to absolute paths.
  453. (lambda _
  454. (let* ((library-path (search-path-as-string->list
  455. (getenv "LIBRARY_PATH")))
  456. (find-so (lambda (soname)
  457. (search-path library-path soname))))
  458. (substitute* "include/config.h"
  459. (("(#define SONAME_.* )\"(.*)\"" _ defso soname)
  460. (format #f "~a\"~a\"" defso (find-so soname))))
  461. #t))))
  462. ,@(strip-keyword-arguments '(#:phases)
  463. (package-arguments wine))))
  464. (synopsis "Implementation of the Windows API (staging branch, 32-bit only)")
  465. (description "Wine-Staging is the testing area of Wine. It
  466. contains bug fixes and features, which have not been integrated into
  467. the development branch yet. The idea of Wine-Staging is to provide
  468. experimental features faster to end users and to give developers the
  469. possibility to discuss and improve their patches before they are
  470. integrated into the main branch.")
  471. (home-page "https://github.com/wine-staging")
  472. ;; In addition to the regular Wine license (lgpl2.1+), Wine-Staging
  473. ;; provides Liberation and WenQuanYi Micro Hei fonts. Those use
  474. ;; different licenses. In particular, the latter is licensed under
  475. ;; both GPL3+ and Apache 2 License.
  476. (license
  477. (list license:lgpl2.1+ license:silofl1.1 license:gpl3+ license:asl2.0))))
  478. (define-public wine64-staging
  479. (package
  480. (inherit wine-staging)
  481. (name "wine64-staging")
  482. (inputs `(("wine-staging" ,wine-staging)
  483. ,@(package-inputs wine-staging)))
  484. (arguments
  485. `(#:make-flags
  486. (list "SHELL=bash"
  487. (string-append "libdir=" %output "/lib/wine64"))
  488. #:phases
  489. (modify-phases %standard-phases
  490. ;; Explicitly set both the 64-bit and 32-bit versions of vulkan-loader
  491. ;; when installing to x86_64-linux so both are available.
  492. ;; TODO: Add more JSON files as they become available in Mesa.
  493. ,@(match (%current-system)
  494. ((or "x86_64-linux")
  495. `((add-after 'copy-wine32-binaries 'wrap-executable
  496. (lambda* (#:key inputs outputs #:allow-other-keys)
  497. (let* ((out (assoc-ref outputs "out")))
  498. (wrap-program (string-append out "/bin/wine-preloader")
  499. `("VK_ICD_FILENAMES" ":" =
  500. (,(string-append (assoc-ref inputs "mesa")
  501. "/share/vulkan/icd.d/radeon_icd.x86_64.json" ":"
  502. (assoc-ref inputs "mesa")
  503. "/share/vulkan/icd.d/intel_icd.x86_64.json" ":"
  504. (assoc-ref inputs "wine-staging")
  505. "/share/vulkan/icd.d/radeon_icd.i686.json" ":"
  506. (assoc-ref inputs "wine-staging")
  507. "/share/vulkan/icd.d/intel_icd.i686.json"))))
  508. (wrap-program (string-append out "/bin/wine64-preloader")
  509. `("VK_ICD_FILENAMES" ":" =
  510. (,(string-append (assoc-ref inputs "mesa")
  511. "/share/vulkan/icd.d/radeon_icd.x86_64.json"
  512. ":" (assoc-ref inputs "mesa")
  513. "/share/vulkan/icd.d/intel_icd.x86_64.json"
  514. ":" (assoc-ref inputs "wine-staging")
  515. "/share/vulkan/icd.d/radeon_icd.i686.json"
  516. ":" (assoc-ref inputs "wine-staging")
  517. "/share/vulkan/icd.d/intel_icd.i686.json"))))
  518. #t)))))
  519. (_
  520. `())
  521. )
  522. (add-before 'configure 'patch-source-wine-staging
  523. (lambda* (#:key outputs #:allow-other-keys)
  524. (let* ((source (assoc-ref %build-inputs "source"))
  525. (script (string-append (assoc-ref %build-inputs
  526. "wine-staging-patchset-data")
  527. "/share/wine-staging/patches/patchinstall.sh")))
  528. (invoke script (string-append "DESTDIR=" ".") "--all")
  529. #t)))
  530. (add-after 'install 'copy-wine32-binaries
  531. (lambda* (#:key outputs #:allow-other-keys)
  532. (let* ((wine32 (assoc-ref %build-inputs "wine-staging"))
  533. (out (assoc-ref %outputs "out")))
  534. ;; Copy the 32-bit binaries needed for WoW64.
  535. (copy-file (string-append wine32 "/bin/wine")
  536. (string-append out "/bin/wine"))
  537. ;; Copy the real 32-bit wine-preloader instead of the wrapped
  538. ;; version.
  539. (copy-file (string-append wine32 "/bin/.wine-preloader-real")
  540. (string-append out "/bin/wine-preloader"))
  541. #t)))
  542. (add-after 'install 'copy-wine32-libraries
  543. (lambda* (#:key outputs #:allow-other-keys)
  544. (let* ((wine32 (assoc-ref %build-inputs "wine-staging"))
  545. (out (assoc-ref %outputs "out")))
  546. (copy-recursively (string-append wine32 "/lib/wine32")
  547. (string-append out "/lib/wine32"))
  548. #t)))
  549. (add-after 'compress-documentation 'copy-wine32-manpage
  550. (lambda* (#:key outputs #:allow-other-keys)
  551. (let* ((wine32 (assoc-ref %build-inputs "wine-staging"))
  552. (out (assoc-ref %outputs "out")))
  553. ;; Copy the missing man file for the wine binary from
  554. ;; wine-staging.
  555. (copy-file (string-append wine32 "/share/man/man1/wine.1.gz")
  556. (string-append out "/share/man/man1/wine.1.gz"))
  557. #t)))
  558. (add-after 'configure 'patch-dlopen-paths
  559. ;; Hardcode dlopened sonames to absolute paths.
  560. (lambda _
  561. (let* ((library-path (search-path-as-string->list
  562. (getenv "LIBRARY_PATH")))
  563. (find-so (lambda (soname)
  564. (search-path library-path soname))))
  565. (substitute* "include/config.h"
  566. (("(#define SONAME_.* )\"(.*)\"" _ defso soname)
  567. (format #f "~a\"~a\"" defso (find-so soname))))
  568. #t))))
  569. #:configure-flags
  570. (list "--enable-win64"
  571. (string-append "LDFLAGS=-Wl,-rpath=" %output "/lib/wine64"))
  572. ,@(strip-keyword-arguments '(#:configure-flags #:make-flags #:phases
  573. #:system)
  574. (package-arguments wine-staging))))
  575. (synopsis "Implementation of the Windows API (staging branch, WoW64
  576. version)")
  577. (supported-systems '("x86_64-linux" "aarch64-linux"))))
  578. (define dxvk32
  579. ;; This package provides 32-bit dxvk libraries on 64-bit systems.
  580. (package
  581. (name "dxvk32")
  582. (version "1.5.5")
  583. (home-page "https://github.com/doitsujin/dxvk/")
  584. (source (origin
  585. (method git-fetch)
  586. (uri (git-reference
  587. (url home-page)
  588. (commit (string-append "v" version))))
  589. (file-name (git-file-name name version))
  590. (sha256
  591. (base32
  592. "1inl0qswgvbp0fs76md86ilqf9mbshkpjm8ga81khn9zd6v3fvan"))))
  593. (build-system meson-build-system)
  594. (arguments
  595. `(#:system "i686-linux"
  596. #:configure-flags (list "--cross-file"
  597. (string-append (assoc-ref %build-inputs "source")
  598. "/build-wine32.txt"))))
  599. (native-inputs
  600. ;; Since 1.5 dxvk needs gcc-8.1. See
  601. ;; https://github.com/doitsujin/dxvk/issues/1292#issuecomment-567067373.
  602. `(("gcc" ,gcc-9)
  603. ("glslang" ,glslang)))
  604. (inputs
  605. `(("wine" ,wine-staging)))
  606. (synopsis "Vulkan-based D3D9, D3D10 and D3D11 implementation for Wine")
  607. (description "A Vulkan-based translation layer for Direct3D 9/10/11 which
  608. allows running complex 3D applications with high performance using Wine.
  609. Use @command{setup_dxvk} to install the required libraries to a Wine prefix.")
  610. (supported-systems '("x86_64-linux"))
  611. (license license:zlib)))
  612. (define-public dxvk
  613. (package
  614. (inherit dxvk32)
  615. (name "dxvk")
  616. (arguments
  617. `(#:configure-flags (list "--cross-file"
  618. (string-append (assoc-ref %build-inputs "source")
  619. "/build-wine"
  620. ,(match (%current-system)
  621. ("x86_64-linux" "64")
  622. (_ "32"))
  623. ".txt"))
  624. #:phases
  625. (modify-phases %standard-phases
  626. ,@(if (string=? (%current-system) "x86_64-linux")
  627. `((add-after 'unpack 'install-32
  628. (lambda* (#:key inputs outputs #:allow-other-keys)
  629. (let* ((out (assoc-ref outputs "out"))
  630. (dxvk32 (assoc-ref inputs "dxvk32")))
  631. (mkdir-p (string-append out "/lib32"))
  632. (copy-recursively (string-append dxvk32 "/lib")
  633. (string-append out "/lib32"))
  634. #t))))
  635. '())
  636. (add-after 'install 'install-setup
  637. (lambda* (#:key inputs outputs #:allow-other-keys)
  638. (let* ((out (assoc-ref outputs "out"))
  639. (bin (string-append out "/bin/setup_dxvk")))
  640. (mkdir-p (string-append out "/bin"))
  641. (copy-file "../source/setup_dxvk.sh"
  642. bin)
  643. (chmod bin #o755)
  644. (substitute* bin
  645. (("wine=\"wine\"")
  646. (string-append "wine=" (assoc-ref inputs "wine") "/bin/wine"))
  647. (("x32") ,(match (%current-system)
  648. ("x86_64-linux" "../lib32")
  649. (_ "../lib")))
  650. (("x64") "../lib"))))))))
  651. (inputs
  652. `(("wine" ,(match (%current-system)
  653. ;; ("x86_64-linux" wine64)
  654. ("x86_64-linux" wine64-staging)
  655. ;; ("x86_64-linux" mingw-w64-x86_64)
  656. (_ wine)))
  657. ,@(match (%current-system)
  658. ("x86_64-linux"
  659. `(("dxvk32" ,dxvk32)))
  660. (_ '()))))
  661. (supported-systems '("i686-linux" "x86_64-linux"))))