code:
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2015 Sou Bunnbu <iyzsong@gmail.com>
;;; Copyright © 2015 David Hashe <david.hashe@dhashe.com>
;;; Copyright © 2015 Ricardo Wurmus <rekado@elephly.net>
;;; Copyright © 2015, 2016, 2017, 2018, 2019, 2020 Mark H Weaver <mhw@netris.org>
;;; Copyright © 2018–2021 Tobias Geerinckx-Rice <me@tobias.gr>
;;; Copyright © 2018 Pierre Neidhardt <mail@ambrevar.xyz>
;;; Copyright © 2019 Marius Bakke <mbakke@fastmail.com>
;;;
;;; This file is part of GNU Guix.
;;;
;;; GNU Guix is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or (at
;;; your option) any later version.
;;;
;;; GNU Guix is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.

(define-module (gnu packages webkit)
  #:use-module ((guix licenses) #:prefix license:)
  #:use-module (guix packages)
  #:use-module (guix download)
  #:use-module (guix utils)
  #:use-module (guix build-system cmake)
  #:use-module (guix build-system gnu)
  #:use-module (gnu packages)
  #:use-module (gnu packages base)
  #:use-module (gnu packages bison)
  #:use-module (gnu packages compression)
  #:use-module (gnu packages docbook)
  #:use-module (gnu packages enchant)
  #:use-module (gnu packages flex)
  #:use-module (gnu packages fontutils)
  #:use-module (gnu packages freedesktop)
  #:use-module (gnu packages gcc)
  #:use-module (gnu packages gettext)
  #:use-module (gnu packages gl)
  #:use-module (gnu packages glib)
  #:use-module (gnu packages gnome)
  #:use-module (gnu packages gnupg)
  #:use-module (gnu packages gperf)
  #:use-module (gnu packages gstreamer)
  #:use-module (gnu packages gtk)
  #:use-module (gnu packages icu4c)
  #:use-module (gnu packages image)
  #:use-module (gnu packages libreoffice)
  #:use-module (gnu packages linux)
  #:use-module (gnu packages perl)
  #:use-module (gnu packages pkg-config)
  #:use-module (gnu packages python)
  #:use-module (gnu packages ruby)
  #:use-module (gnu packages sqlite)
  #:use-module (gnu packages tls)
  #:use-module (gnu packages video)
  #:use-module (gnu packages virtualization)
  #:use-module (gnu packages xml)
  #:use-module (gnu packages xdisorg)
  #:use-module (gnu packages xorg))

(define-public libwpe
  (package
    (name "libwpe")
    (version "1.6.0")
    (source
     (origin
       (method url-fetch)
       (uri
        (string-append "https://wpewebkit.org/releases/libwpe-"
                       version ".tar.xz"))
       (sha256
        (base32 "141w35b488jjhanl3nrm0awrbcy6hb579fk8n9vbpx07m2wcd1rm"))))
    (build-system cmake-build-system)
    (arguments
     `(#:tests? #f))                    ;no tests
    (native-inputs
     `(("pkg-config" ,pkg-config)
       ("python" ,python-wrapper)))
    (inputs
     `(("mesa" ,mesa)))
    (propagated-inputs
     `(("libxkbcommon" ,libxkbcommon)))
    (synopsis "General-purpose library for WPE")
    (description "LibWPE is general-purpose library specifically developed for
the WPE-flavored port of WebKit.")
    (home-page "https://wpewebkit.org/")
    (license license:bsd-2)))

(define-public wpebackend-fdo
  (package
    (name "wpebackend-fdo")
    (version "1.6.1")
    (source (origin
              (method url-fetch)
              (uri (string-append "https://wpewebkit.org/releases/"
                                  "wpebackend-fdo-" version ".tar.xz"))
              (sha256
               (base32
                "1jdi43gciqjgvhnqxs160f3hmp1hkqhrllb0hhmldyxc4wryw3kl"))))
    (build-system cmake-build-system)
    (arguments
     `(#:tests? #f))                    ;no tests
    (native-inputs
     `(("pkg-config" ,pkg-config)))
    (inputs
     `(("glib" ,glib)
       ("libwpe" ,libwpe)
       ("mesa" ,mesa)
       ("wayland" ,wayland)))
    (home-page "https://wpewebkit.org/")
    (synopsis "Wayland WPE backend")
    (description
     "This package provides a backend implementation for the WPE WebKit
engine that uses Wayland for graphics output.")
    (license license:bsd-2)))

(define-public wpewebkit
  (package
    (name "wpewebkit")
    (version "2.30.5")
    (source
     (origin
       (method url-fetch)
       (uri
        (string-append "https://wpewebkit.org/releases/"
                       name "-" version ".tar.xz"))
       (sha256
        (base32 "16imr0kmzhs7dz6jva9750xbsdz9v50playnagabajy30x7pymsb"))))
    (build-system cmake-build-system)
    (outputs '("out" "doc"))
    (arguments
     `(#:tests? #f                      ; XXX: To be enabled
       #:configure-flags
       (list
        "-DPORT=WPE"
        ;; XXX: To be enabled.
        ;; "-DENABLE_ACCELERATED_2D_CANVAS=ON"
        "-DUSE_SYSTEMD=OFF"
        "-DENABLE_ENCRYPTED_MEDIA=OFF"
        "-DENABLE_GTKDOC=ON"
        "-DUSE_GSTREAMER_GL=OFF")
       #:phases
       (modify-phases %standard-phases
         (add-after 'unpack 'setenv
           (lambda _
             (setenv "HOME" "/tmp")
             #t))
         (add-after 'unpack 'patch-docbook-xml
           (lambda* (#:key inputs #:allow-other-keys)
             (for-each
              (lambda (file)
                (substitute* file
                  (("http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd")
                   (string-append (assoc-ref inputs "docbook-xml")
                                  "/xml/dtd/docbook/docbookx.dtd"))))
              (find-files "Source" "\\.sgml$"))
             #t))
         (add-after 'install 'move-doc-files
           (lambda* (#:key outputs #:allow-other-keys)
             (let* ((out (assoc-ref outputs "out"))
                    (doc (assoc-ref outputs "doc")))
               (mkdir-p (string-append doc "/share"))
               (rename-file
                (string-append out "/share/gtk-doc")
                (string-append doc "/share/gtk-doc"))
               #t))))))
    (native-inputs
     `(("docbook-xml" ,docbook-xml-4.1.2)
       ("docbook-xsl" ,docbook-xsl)
       ("glib:bin" ,glib "bin")
       ("gobject-introspection" ,gobject-introspection)
       ("gtk-doc" ,gtk-doc/stable)
       ("perl" ,perl)
       ("pkg-config" ,pkg-config)
       ("python" ,python-wrapper)
       ("python2" ,python-2.7)
       ("ruby" ,ruby)))
    (inputs
     `(("atk" ,atk)
       ("atk-bridge" ,at-spi2-atk)
       ("bubblewrap" ,bubblewrap)
       ("cairo" ,cairo)
       ("fontconfig" ,fontconfig)
       ("freetype" ,freetype)
       ("gperf" ,gperf)
       ("gstreamer" ,gstreamer)
       ("gst-plugins-base" ,gst-plugins-base)
       ("harfbuzz" ,harfbuzz)
       ("icu" ,icu4c)
       ("libepoxy" ,libepoxy)
       ("libgcrypt" ,libgcrypt)
       ("libjpeg" ,libjpeg-turbo)
       ("libpng" ,libpng)
       ("libseccomp" ,libseccomp)
       ("libtasn1" ,libtasn1)
       ("libxml2" ,libxml2)
       ("libxslt" ,libxslt)
       ("mesa" ,mesa)
       ("openjpeg" ,openjpeg)
       ("sqlite" ,sqlite)
       ("webp" ,libwebp)
       ("woff2" ,woff2)
       ("xdg-dbus-proxy" ,xdg-dbus-proxy)
       ("zlib" ,zlib)))
    (propagated-inputs
     `(("glib" ,glib)
       ("libsoup" ,libsoup)
       ("wpe" ,libwpe)))
    (synopsis "WebKit port optimized for embedded devices")
    (description "WPE WebKit allows embedders to create simple and performant
systems based on Web platform technologies.  It is designed with hardware
acceleration in mind, leveraging common 3D graphics APIs for best performance.")
    (home-page "https://wpewebkit.org/")
    (license
     (list
      ;; Rendering and JavaScript Engines.
      license:lgpl2.1+
      ;; Others
      license:bsd-2))))

(define-public webkitgtk
  (package
    (name "webkitgtk")
    (version "2.32.3")
    (source (origin
              (method url-fetch)
              (uri (string-append "https://www.webkitgtk.org/releases/"
                                  "webkitgtk-" version ".tar.xz"))
              (sha256
               (base32
                "1g1clppby019bng43ry50xd2dvzfzgrd9yv2xx6gwkk5mksrdx61"))
              (patches (search-patches "webkitgtk-share-store.patch"
                                       "webkitgtk-bind-all-fonts.patch"))))
    (build-system cmake-build-system)
    (outputs '("out" "doc"))
    (arguments
     '(#:tests? #f ; no tests
       #:build-type "Release" ; turn off debugging symbols to save space
       #:configure-flags (list
                          "-DPORT=GTK"
                          "-DENABLE_GTKDOC=ON" ; No doc by default
                          ;; Requires libmanette, new dependency added in 2.32.0.
                          ;; TODO Decide if we should enable this
                          "-DENABLE_GAMEPAD=OFF"
                          "-DUSE_SYSTEMD=OFF"
                          (string-append ; uses lib64 by default
                           "-DLIB_INSTALL_DIR="
                           (assoc-ref %outputs "out") "/lib")

                          ;; XXX Adding GStreamer GL support would apparently
                          ;; require adding gst-plugins-bad to the inputs,
                          ;; which might entail a security risk as a result of
                          ;; the plugins of dubious code quality that are
                          ;; included.  More investigation is needed.  For
                          ;; now, we explicitly disable it to prevent an error
                          ;; at configuration time.
                          "-DUSE_GSTREAMER_GL=OFF")
       #:make-flags
       ;; Never build with unsupported -j1: https://issues.guix.gnu.org/47964#5
       (list "-j" (number->string (max 2 (parallel-job-count))))
       #:phases
       (modify-phases %standard-phases
         (add-after 'unpack 'configure-bubblewrap-store-directory
           (lambda _
             ;; This phase is a corollary to 'webkitgtk-share-store.patch' to
             ;; avoid hard coding /gnu/store, for users with other prefixes.
             (let ((store-directory (%store-directory)))
               (substitute*
                   "Source/WebKit/UIProcess/Launcher/glib/BubblewrapLauncher.cpp"
                 (("@storedir@") store-directory))
               #t)))
         (add-after 'unpack 'patch-gtk-doc-scan
           (lambda* (#:key inputs #:allow-other-keys)
             (for-each (lambda (file)
                         (substitute* file
                           (("http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd")
                            (string-append (assoc-ref inputs "docbook-xml")
                                           "/xml/dtd/docbook/docbookx.dtd"))))
                       (find-files "Source" "\\.sgml$"))
             #t))
         (add-after 'unpack 'embed-absolute-wpebackend-reference
           (lambda* (#:key inputs #:allow-other-keys)
             (let ((wpebackend-fdo (assoc-ref inputs "wpebackend-fdo")))
               (substitute* "Source/WebKit/UIProcess/glib/WebProcessPoolGLib.cpp"
                 (("libWPEBackend-fdo-([\\.0-9]+)\\.so" all version)
                  (string-append wpebackend-fdo "/lib/" all)))
               #t)))
         (add-after 'install 'move-doc-files
           (lambda* (#:key outputs #:allow-other-keys)
             (let ((out (assoc-ref outputs "out"))
                   (doc (assoc-ref outputs "doc")))
               (mkdir-p (string-append doc "/share"))
               (rename-file (string-append out "/share/gtk-doc")
                            (string-append doc "/share/gtk-doc"))
               #t))))))
    (native-inputs
     `(("bison" ,bison)
       ("gettext" ,gettext-minimal)
       ("glib:bin" ,glib "bin") ; for glib-mkenums, etc.
       ("gobject-introspection" ,gobject-introspection)
       ("gperf" ,gperf)
       ("perl" ,perl)
       ("pkg-config" ,pkg-config)
       ("python" ,python-wrapper)
       ("gtk-doc" ,gtk-doc/stable) ; For documentation generation
       ("docbook-xml" ,docbook-xml) ; For documentation generation
       ("ruby" ,ruby)))
    (propagated-inputs
     `(("gtk+" ,gtk+)
       ("libsoup" ,libsoup)))
    (inputs
     `(("at-spi2-core" ,at-spi2-core)
       ("bubblewrap" ,bubblewrap)
       ("enchant" ,enchant)
       ("geoclue" ,geoclue)
       ("gst-plugins-base" ,gst-plugins-base)
       ("gtk+-2" ,gtk+-2)
       ("harfbuzz" ,harfbuzz)
       ("hyphen" ,hyphen)
       ("icu4c" ,icu4c)
       ("libgcrypt" ,libgcrypt)
       ("libjpeg" ,libjpeg-turbo)
       ("libnotify" ,libnotify)
       ("libpng" ,libpng)
       ("libseccomp" ,libseccomp)
       ("libsecret" ,libsecret)
       ("libtasn1" ,libtasn1)
       ("libwebp" ,libwebp)
       ("libwpe" ,libwpe)
       ("libxcomposite" ,libxcomposite)
       ("libxml2" ,libxml2)
       ("libxslt" ,libxslt)
       ("libxt" ,libxt)
       ("mesa" ,mesa)
       ("openjpeg" ,openjpeg)
       ("sqlite" ,sqlite)
       ("woff2" ,woff2)
       ("wpebackend-fdo" ,wpebackend-fdo)
       ("xdg-dbus-proxy" ,xdg-dbus-proxy)))
    (home-page "https://www.webkitgtk.org/")
    (synopsis "Web content engine for GTK+")
    (description
     "WebKitGTK+ is a full-featured port of the WebKit rendering engine,
suitable for projects requiring any kind of web integration, from hybrid
HTML/CSS applications to full-fledged web browsers.")
    ;; WebKit's JavaScriptCore and WebCore components are available under
    ;; the GNU LGPL, while the rest is available under a BSD-style license.
    (license (list license:lgpl2.0
                   license:lgpl2.1+
                   license:bsd-2
                   license:bsd-3))))


code:
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2012 Nikita Karetnikov <nikita@karetnikov.org>
;;; Copyright © 2014, 2015, 2017, 2018 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2016, 2017, 2019, 2020 Efraim Flashner <efraim@flashner.co.il>
;;; Copyright © 2017 Rutger Helling <rhelling@mykolab.com>
;;; Copyright © 2018–2021 Tobias Geerinckx-Rice <me@tobias.gr>
;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
;;;
;;; This file is part of GNU Guix.
;;;
;;; GNU Guix is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or (at
;;; your option) any later version.
;;;
;;; GNU Guix is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.

(define-module (gnu packages wget)
  #:use-module ((guix licenses) #:prefix license:)
  #:use-module (gnu packages)
  #:use-module (gnu packages base)
  #:use-module (gnu packages compression)
  #:use-module (gnu packages documentation)
  #:use-module (gnu packages gnunet)
  #:use-module (gnu packages gnupg)
  #:use-module (gnu packages libidn)
  #:use-module (gnu packages pcre)
  #:use-module (gnu packages perl)
  #:use-module (gnu packages pkg-config)
  #:use-module (gnu packages python)
  #:use-module (gnu packages tls)
  #:use-module (gnu packages web)
  #:use-module (gnu packages xdisorg)
  #:use-module (guix packages)
  #:use-module (guix download)
  #:use-module (guix git-download)
  #:use-module (guix build-system gnu))

(define-public wget
  (package
    (name "wget")
    (version "1.20.3")
    (source
     (origin
      (method url-fetch)
      (uri (string-append "mirror://gnu/wget/wget-"
                          version ".tar.lz"))
      (sha256
       (base32
        "1frajd86ds8vz2hprq30wq8ya89z9dcxnwm8nwk12bbc47l7qq39"))))
    (build-system gnu-build-system)
    (inputs
     `(("gnutls" ,gnutls)
       ("libidn2" ,libidn2)
       ("libpsl" ,libpsl)))
    (native-inputs
     `(("lzip" ,lzip)
       ("pkg-config" ,pkg-config)
       ("perl" ,perl)
       ("python" ,python)               ;for testenv suite
       ("perl-http-daemon" ,perl-http-daemon)
       ("perl-io-socket-ssl" ,perl-io-socket-ssl)))
    (home-page "https://www.gnu.org/software/wget/")
    (synopsis "Non-interactive command-line utility for downloading files")
    (description
     "GNU Wget is a non-interactive tool for fetching files using the HTTP,
HTTPS and FTP protocols.  It can resume interrupted downloads, use file name
wild cards, supports proxies and cookies, and it can convert absolute links
in downloaded documents to relative links.")
    (license license:gpl3+))) ; some files are under GPLv2+

(define-public wgetpaste
  (package
    (name "wgetpaste")
    (version "2.32")
    (source
      (origin
        (method git-fetch)
        (uri (git-reference
              (url "https://github.com/zlin/wgetpaste")
              (commit version)))
        (file-name (git-file-name name version))
        (sha256
         (base32 "13zdqfnbpymwz2f04icw92flj50227n5r0dcms84qxswfxrarnas"))))
    (build-system gnu-build-system)
    (arguments
     `(#:modules ((guix build gnu-build-system)
                  (guix build utils)
                  (srfi srfi-1))
       #:phases
       (modify-phases %standard-phases
         (delete 'configure)
         (delete 'build)
         (add-after 'unpack 'change-unfriendly-default
           (lambda _
             (substitute* "wgetpaste"
               ;; dpaste blocks Tor users.  Use a better default.
               (("DEFAULT_SERVICE:-dpaste")
                "DEFAULT_SERVICE-bpaste"))
             #t))
         (replace 'install
           (lambda* (#:key outputs #:allow-other-keys)
             (let* ((out (assoc-ref outputs "out"))
                    (bin (string-append out "/bin"))
                    (zsh (string-append out "/share/zsh/site-functions")))
               (install-file "wgetpaste" bin)
               (install-file "_wgetpaste" zsh)
               #t)))
         (add-after 'install 'wrap-program
           ;; /bin/wgetpaste prides itself on relying only on the following
           ;; inputs, and doesn't need to execute arbitrary commands, so
           ;; override PATH completely to detect any new dependencies early.
           (lambda* (#:key outputs #:allow-other-keys)
             (let ((out (assoc-ref outputs "out")))
               (wrap-program (string-append out "/bin/wgetpaste")
                 `("PATH" ":" =
                   ,(delete-duplicates
                     (map (lambda (command) (dirname (which command)))
                          (list "bash" "mktemp" "sed" "sort" "tee" "tr"
                                "wget" "xclip")))))
               #t))))
       #:tests? #f))                    ; no test target
    (inputs
     `(("wget" ,wget)
       ("xclip" ,xclip)))
    (home-page "https://wgetpaste.zlin.dk/")
    (synopsis "Script that automates pasting to a number of pastebin services")
    (description
     "@code{wgetpaste} is an extremely simple command-line interface to various
online pastebin services.")
    (license license:expat)))

(define-public wget2
  (package
   (name "wget2")
   (version "1.99.2")
   (source
     (origin
       (method url-fetch)
       (uri (string-append "mirror://gnu/wget/wget2-" version ".tar.gz"))
       (sha256
        (base32
         "0qv55f4bablrlhc8bnic8g3mkk1kq44c4cphrk5jmv92z9aqzi6b"))))
   (build-system gnu-build-system)
   (arguments
    `(#:phases
      (modify-phases %standard-phases
        (add-after 'unpack 'skip-network-tests
          (lambda _
            (substitute* "tests/Makefile.in"
              (("test-gpg-verify-no-file\\$\\(EXEEXT)") "")
              (("test-gpg-valid\\$\\(EXEEXT)") "")
              (("test-gpg-styles\\$\\(EXEEXT)") ""))
            #t)))
      #:configure-flags '("--enable-static=no")))
   (inputs
    `(("bzip2" ,bzip2)
      ("gnutls" ,gnutls/dane)
      ("gpgme" ,gpgme)
      ("libiconv" ,libiconv)
      ("libidn2" ,libidn2)
      ("libmicrohttpd" ,libmicrohttpd)
      ("libpsl" ,libpsl)
      ("pcre2" ,pcre2)
      ("zlib" ,zlib)))
   ;; TODO: Add libbrotlidec, libnghttp2.
   (native-inputs
    `(("pkg-config" ,pkg-config)))
   (home-page "https://gitlab.com/gnuwget/wget2")
   (synopsis "Successor of GNU Wget")
   (description "GNU Wget2 is the successor of GNU Wget, a file and recursive
website downloader.  Designed and written from scratch it wraps around libwget,
that provides the basic functions needed by a web client.")
   (properties '((ftp-directory . "/gnu/wget")))
   (license (list license:gpl3+ license:lgpl3+))))

repo_name: maximed/guix

license: mit


code:
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2015 Mark H Weaver <mhw@netris.org>
;;; Copyright © 2015 Pierre-Antoine Rault <par@rigelk.eu>
;;; Copyright © 2015 Andreas Enge <andreas@enge.fr>
;;; Copyright © 2016 Ludovic Courtès <ludo@gnu.org>
;;;
;;; This file is part of GNU Guix.
;;;
;;; GNU Guix is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or (at
;;; your option) any later version.
;;;
;;; GNU Guix is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.

(define-module (gnu packages wicd)
  #:use-module (guix packages)
  #:use-module (guix download)
  #:use-module (guix build-system python)
  #:use-module (guix licenses)
  #:use-module (guix utils)
  #:use-module (gnu packages)
  #:use-module (gnu packages glib)
  #:use-module (gnu packages gtk)
  #:use-module (gnu packages gnome)
  #:use-module (gnu packages gettext)
  #:use-module (gnu packages linux)
  #:use-module (gnu packages admin)
  #:use-module (gnu packages python)
  #:use-module (gnu packages python-xyz))

(define-public wicd
  (package
    (name "wicd")
    (version "1.7.4")
    (source
     (origin
       (method url-fetch)
       (uri (string-append "https://launchpad.net/wicd/"
                           (version-major+minor version) "/" version
                           "/+download/wicd-" version ".tar.gz"))
       (sha256
        (base32 "0qpbwwsrqdp40mm3a8djpn2d055rxxspdhwijwsdnws700a9d637"))
       (patches (search-patches
                 "wicd-bitrate-none-fix.patch"
                 "wicd-get-selected-profile-fix.patch"
                 "wicd-urwid-1.3.patch"
                 "wicd-wpa2-ttls.patch"))))
    (build-system python-build-system)
    (native-inputs `(("gettext" ,gettext-minimal)))
    (inputs `(("dbus-glib" ,dbus-glib)
              ("python2-dbus" ,python2-dbus)
              ("python2-pygtk" ,python2-pygtk)
              ("python2-urwid" ,python2-urwid)
              ("python2-babel" ,python2-babel)
              ("wireless-tools" ,wireless-tools)
              ("wpa-supplicant" ,wpa-supplicant)
              ("net-tools" ,net-tools)
              ("isc-dhcp" ,isc-dhcp)
              ("iproute" ,iproute)
              ("hicolor-icon-theme" ,hicolor-icon-theme)))
    (arguments
     `(#:python ,python-2
       #:tests? #f                      ; test suite requires networking
       ;; wicd directly extends distutils command classes,
       ;; we can't easily make setup.py use setuptools.
       #:use-setuptools? #f
       #:phases
       (modify-phases %standard-phases
         (add-before 'build 'configure
           (lambda* (#:key inputs outputs #:allow-other-keys)
             (let ((out (assoc-ref outputs "out"))
                   (python (assoc-ref inputs "python")))
               (define (which* cmd)
                 (cond ((string=? cmd "ping")
                        "/run/setuid-programs/ping")
                       ((which cmd)
                        => identity)
                       (else
                        (format (current-error-port)
                                "WARNING: Unable to find absolute path for ~s~%"
                                cmd)
                        #f)))
               (substitute* "setup.py"
                 ;; The handling of unrecognized distros in setup.py is
                 ;; broken.  Work around the problem.
                 (("\\('init=', " all)
                  (string-append "#" all))
                 ;; Inhibit attempts to install in /var or /etc.
                 (("\\(wpath\\.(log|etc|networks|.*scripts), " all)
                  (string-append "#" all)))

               ;; Patch references to subprograms with absolute pathnames.
               (substitute* "wicd/wnettools.py"
                 (("(misc\\.Run\\(\\[?[\"'])([^\"' ]*)" all pre cmd)
                  (string-append pre (which* cmd)))
                 (("(self\\._find_program_path|misc\\.find_path)\\([\"']([^\"']*)[\"']\\)"
                   all dummy cmd)
                  (let ((pathname (which* cmd)))
                    (if pathname
                        (string-append "'" pathname "'")
                        "None")))
                 (("([\"'])(ifconfig|route|wpa_cli|wpa_supplicant|iwconfig|iwpriv|iwlist|ping)"
                   all open-quote cmd)
                  (string-append open-quote (which* cmd))))

               ;; setup.py cannot cope without LANG
               (setenv "LANG" "C")

               (let ((params
                      (list
                       (string-append "--python=" python "/bin/python")
                       "--no-install-init"
                       "--no-install-docs"
                       "--no-install-acpi"
                       "--no-install-pmutils"
                       "--no-install-kde"
                       "--no-install-gnome-shell-extensions"

                       "--distro=guixsd"
                       "--wicdgroup=netdev"
                       "--loggroup=root"
                       "--logperms=0640"

                       ;; XXX setup.py configure asks us to pass --init=,
                       ;; but if we do it says "no such option 'init'".
                       ;; (string-append "--init=" out "/etc/init.d")

                       (string-append "--initfile=" out "/etc/init.d/wicd")
                       (string-append "--lib=" out "/lib/wicd")
                       (string-append "--share=" out "/share/wicd")

                       "--etc=/etc/wicd"
                       "--scripts=/etc/wicd/scripts"
                       "--pmutils=/etc/pm-utils/sleep.d"

                       (string-append "--encryption="
                                      out "/etc/encryption/templates")
                       (string-append "--bin=" out "/bin")
                       (string-append "--sbin=" out "/sbin")
                       (string-append "--daemon=" out "/share/wicd/daemon")
                       (string-append "--backends=" out "/share/wicd/backends")
                       (string-append "--curses=" out "/share/wicd/curses")
                       (string-append "--gtk=" out "/share/wicd/gtk")
                       (string-append "--cli=" out "/share/wicd/cli")
                       (string-append "--gnome-shell-extensions="
                                      out "/share/gnome-shell-extensions")
                       (string-append "--icons=" out "/share/icons/hicolor")
                       (string-append "--pixmaps=" out "/share/pixmaps")
                       (string-append "--images=" out "/share/icons")
                       (string-append "--dbus=" out "/etc/dbus-1/system.d")
                       (string-append "--dbus-service="
                                      out "/share/dbus-1/system-services")
                       (string-append "--systemd=" out "/lib/systemd/system")
                       (string-append "--logrotate=" out "/etc/logrotate.d")
                       (string-append "--desktop=" out "/share/applications")
                       (string-append "--translations=" out "/share/locale")
                       (string-append "--autostart=" out "/etc/xdg/autostart")
                       (string-append "--docdir=" out "/share/doc/wicd")
                       (string-append "--mandir=" out "/share/man")
                       (string-append "--kdedir=" out "/share/autostart"))))
                 (format #t
                         "running ~s with command ~s and parameters ~s~%"
                         "python setup.py" "configure" params)
                 (apply invoke "python" "setup.py" "configure" params)))))
         (add-after 'install 'post-install
           (lambda* (#:key inputs outputs #:allow-other-keys)
             (let ((out (assoc-ref outputs "out")))
               ;; wicd's installer tries to put dhclient.conf.template.default
               ;; in /etc/wicd/other, which is not available in the build
               ;; environment, so here we install it manually in the output
               ;; directory.
               (let ((dest-dir (string-append out "/etc/wicd"))
                     (name "dhclient.conf.template.default"))
                 (install-file (string-append "other/" name) dest-dir))

               ;; Copy index.theme from hicolor-icon-theme.  This is needed to
               ;; allow wicd-gtk to find its icons.
               (let ((hicolor (assoc-ref inputs "hicolor-icon-theme"))
                     (name "/share/icons/hicolor/index.theme"))
                 (install-file (string-append hicolor name)
                               (string-append out "/share/icons/hicolor")))
               #t))))))
    (synopsis "Network connection manager")
    (description "Wicd is a network manager that aims to simplify wired and
wireless networking.")
    (home-page "https://launchpad.net/wicd")
    (license gpl2+)))


code:
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2014, 2015 Sou Bunnbu <iyzsong@gmail.com>
;;; Copyright © 2016 Ricardo Wurmus <rekado@elephly.net>
;;; Copyright © 2016, 2017, 2018 Efraim Flashner <efraim@flashner.co.il>
;;; Copyright © 2017, 2018, 2019 Rutger Helling <rhelling@mykolab.com>
;;; Copyright © 2017, 2020 Nicolas Goaziou <mail@nicolasgoaziou.fr>
;;; Copyright © 2018, 2019, 2020 Tobias Geerinckx-Rice <me@tobias.gr>
;;; Copyright © 2019 Pierre Neidhardt <mail@ambrevar.xyz>
;;;
;;; This file is part of GNU Guix.
;;;
;;; GNU Guix is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or (at
;;; your option) any later version.
;;;
;;; GNU Guix is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.

(define-module (gnu packages wine)
  #:use-module ((guix licenses) #:prefix license:)
  #:use-module (guix packages)
  #:use-module (guix download)
  #:use-module (guix git-download)
  #:use-module (guix utils)
  #:use-module (guix build-system gnu)
  #:use-module (guix build-system meson)
  #:use-module (guix build-system trivial)
  #:use-module (gnu packages)
  #:use-module (gnu packages admin)
  #:use-module (gnu packages audio)
  #:use-module (gnu packages autotools)
  #:use-module (gnu packages base)
  #:use-module (gnu packages bash)
  #:use-module (gnu packages bison)
  #:use-module (gnu packages cups)
  #:use-module (gnu packages databases)
  #:use-module (gnu packages fontutils)
  #:use-module (gnu packages flex)
  #:use-module (gnu packages image)
  #:use-module (gnu packages gcc)
  #:use-module (gnu packages gettext)
  #:use-module (gnu packages ghostscript)
  #:use-module (gnu packages gl)
  #:use-module (gnu packages glib)
  #:use-module (gnu packages gstreamer)
  #:use-module (gnu packages gtk)
  #:use-module (gnu packages kerberos)
  #:use-module (gnu packages libusb)
  #:use-module (gnu packages linux)
  #:use-module (gnu packages mingw)
  #:use-module (gnu packages openldap)
  #:use-module (gnu packages perl)
  #:use-module (gnu packages pulseaudio)
  #:use-module (gnu packages pkg-config)
  #:use-module (gnu packages python)
  #:use-module (gnu packages mp3)
  #:use-module (gnu packages photo)
  #:use-module (gnu packages samba)
  #:use-module (gnu packages scanner)
  #:use-module (gnu packages sdl)
  #:use-module (gnu packages tls)
  #:use-module (gnu packages video)
  #:use-module (gnu packages vulkan)
  #:use-module (gnu packages xml)
  #:use-module (gnu packages xorg)
  #:use-module (ice-9 match)
  #:use-module (srfi srfi-1))

(define-public wine
  (package
    (name "wine")
    (version "6.8")
    (source
     (origin
       (method url-fetch)
       (uri (let ((dir (string-append
                        (version-major version)
                        (if (string-suffix? ".0" (version-major+minor version))
                            ".0/"
                            ".x/"))))
              (string-append "https://dl.winehq.org/wine/source/" dir
                             "wine-" version ".tar.xz")))
       (sha256
        (base32 "1n7bd6kkhfgi23bz981qml3lajgvbs3ibqrc2mqjhhfqczg2shjv"))))
    (build-system gnu-build-system)
    (native-inputs
     `(("bison" ,bison)
       ("flex" ,flex)
       ("gettext" ,gettext-minimal)
       ("perl" ,perl)
       ("pkg-config" ,pkg-config)))
    (inputs
     `(("alsa-lib" ,alsa-lib)
       ("dbus" ,dbus)
       ("cups" ,cups)
       ("eudev" ,eudev)
       ("faudio" ,faudio)
       ("fontconfig" ,fontconfig)
       ("freetype" ,freetype)
       ("gnutls" ,gnutls)
       ("gst-plugins-base" ,gst-plugins-base)
       ("lcms" ,lcms)
       ("libxml2" ,libxml2)
       ("libxslt" ,libxslt)
       ("libgphoto2" ,libgphoto2)
       ("libmpg123" ,mpg123)
       ("libldap" ,openldap)
       ("libnetapi" ,samba)
       ("libsane" ,sane-backends)
       ("libpcap" ,libpcap)
       ("libpng" ,libpng)
       ("libjpeg" ,libjpeg-turbo)
       ("libusb" ,libusb)
       ("libtiff" ,libtiff)
       ("libICE" ,libice)
       ("libX11" ,libx11)
       ("libXi" ,libxi)
       ("libXext" ,libxext)
       ("libXcursor" ,libxcursor)
       ("libXrender" ,libxrender)
       ("libXrandr" ,libxrandr)
       ("libXinerama" ,libxinerama)
       ("libXxf86vm" ,libxxf86vm)
       ("libXcomposite" ,libxcomposite)
       ("mit-krb5" ,mit-krb5)
       ("openal" ,openal)
       ("pulseaudio" ,pulseaudio)
       ("sdl2" ,sdl2)
       ("unixodbc" ,unixodbc)
       ("v4l-utils" ,v4l-utils)
       ("vkd3d" ,vkd3d)
       ("vulkan-loader" ,vulkan-loader)))
    (arguments
     `(;; Force a 32-bit build targeting a similar architecture, i.e.:
       ;; armhf for armhf/aarch64, i686 for i686/x86_64.
       #:system ,@(match (%current-system)
                    ((or "armhf-linux" "aarch64-linux")
                     `("armhf-linux"))
                    (_
                     `("i686-linux")))

       ;; XXX: There's a test suite, but it's unclear whether it's supposed to
       ;; pass.
       #:tests? #f

       #:configure-flags
       (list (string-append "LDFLAGS=-Wl,-rpath=" %output "/lib/wine32"))

       #:make-flags
       (list "SHELL=bash"
             (string-append "libdir=" %output "/lib/wine32"))

       #:phases
       (modify-phases %standard-phases
         ;; Explicitly set the 32-bit version of vulkan-loader when installing
         ;; to i686-linux or x86_64-linux.
         ;; TODO: Add more JSON files as they become available in Mesa.
         ,@(match (%current-system)
             ((or "i686-linux" "x86_64-linux")
              `((add-after 'install 'wrap-executable
                  (lambda* (#:key inputs outputs #:allow-other-keys)
                    (let* ((out (assoc-ref outputs "out"))
                           (icd (string-append out "/share/vulkan/icd.d")))
                      (mkdir-p icd)
                      (copy-file (string-append
                                  (assoc-ref inputs "mesa")
                                  "/share/vulkan/icd.d/radeon_icd.i686.json")
                                 (string-append icd "/radeon_icd.i686.json"))
                      (copy-file (string-append
                                  (assoc-ref inputs "mesa")
                                  "/share/vulkan/icd.d/intel_icd.i686.json")
                                 (string-append icd "/intel_icd.i686.json"))
                      (wrap-program (string-append out "/bin/wine-preloader")
                        `("VK_ICD_FILENAMES" ":" =
                          (,(string-append icd
                                           "/radeon_icd.i686.json" ":"
                                           icd "/intel_icd.i686.json"))))
                      #t)))))
             (_
              `()))
         (add-after 'configure 'patch-dlopen-paths
           ;; Hardcode dlopened sonames to absolute paths.
           (lambda _
             (let* ((library-path (search-path-as-string->list
                                   (getenv "LIBRARY_PATH")))
                    (find-so (lambda (soname)
                               (search-path library-path soname))))
               (substitute* "include/config.h"
                 (("(#define SONAME_.* )\"(.*)\"" _ defso soname)
                  (format #f "~a\"~a\"" defso (find-so soname))))
               #t))))))
    (home-page "https://www.winehq.org/")
    (synopsis "Implementation of the Windows API (32-bit only)")
    (description
     "Wine (originally an acronym for \"Wine Is Not an Emulator\") is a
compatibility layer capable of running Windows applications.  Instead of
simulating internal Windows logic like a virtual machine or emulator, Wine
translates Windows API calls into POSIX calls on-the-fly, eliminating the
performance and memory penalties of other methods and allowing you to cleanly
integrate Windows applications into your desktop.")
    ;; Any platform should be able to build wine, but based on '#:system' these
    ;; are thr ones we currently support.
    (supported-systems '("i686-linux" "x86_64-linux" "armhf-linux"))
    (license license:lgpl2.1+)))

(define-public wine64
  (package
    (inherit wine)
    (name "wine64")
    (inputs `(("wine" ,wine)
              ,@(package-inputs wine)))
    (arguments
     `(#:make-flags
       (list "SHELL=bash"
             (string-append "libdir=" %output "/lib/wine64"))
       #:phases
       (modify-phases %standard-phases
         ;; Explicitly set both the 64-bit and 32-bit versions of vulkan-loader
         ;; when installing to x86_64-linux so both are available.
         ;; TODO: Add more JSON files as they become available in Mesa.
         ,@(match (%current-system)
             ((or "x86_64-linux")
              `((add-after 'copy-wine32-binaries 'wrap-executable
                  (lambda* (#:key inputs outputs #:allow-other-keys)
                    (let* ((out (assoc-ref outputs "out")))
                      (wrap-program (string-append out "/bin/wine-preloader")
                        `("VK_ICD_FILENAMES" ":" =
                          (,(string-append
                             (assoc-ref inputs "mesa")
                             "/share/vulkan/icd.d/radeon_icd.x86_64.json" ":"
                             (assoc-ref inputs "mesa")
                             "/share/vulkan/icd.d/intel_icd.x86_64.json" ":"
                             (assoc-ref inputs "wine")
                             "/share/vulkan/icd.d/radeon_icd.i686.json" ":"
                             (assoc-ref inputs "wine")
                             "/share/vulkan/icd.d/intel_icd.i686.json"))))
                      (wrap-program (string-append out "/bin/wine64-preloader")
                        `("VK_ICD_FILENAMES" ":" =
                          (,(string-append
                             (assoc-ref inputs "mesa")
                             "/share/vulkan/icd.d/radeon_icd.x86_64.json"
                             ":" (assoc-ref inputs "mesa")
                             "/share/vulkan/icd.d/intel_icd.x86_64.json"
                             ":" (assoc-ref inputs "wine")
                             "/share/vulkan/icd.d/radeon_icd.i686.json"
                             ":" (assoc-ref inputs "wine")
                             "/share/vulkan/icd.d/intel_icd.i686.json"))))
                      #t)))))
             (_
              `()))
         (add-after 'install 'copy-wine32-binaries
           (lambda* (#:key outputs #:allow-other-keys)
             (let* ((wine32 (assoc-ref %build-inputs "wine"))
                    (out (assoc-ref %outputs "out")))
               ;; Copy the 32-bit binaries needed for WoW64.
               (copy-file (string-append wine32 "/bin/wine")
                          (string-append out "/bin/wine"))
               ;; Copy the real 32-bit wine-preloader instead of the wrapped
               ;; version.
               (copy-file (string-append wine32 "/bin/.wine-preloader-real")
                          (string-append out "/bin/wine-preloader"))
               #t)))
         (add-after 'install 'copy-wine32-libraries
           (lambda* (#:key outputs #:allow-other-keys)
             (let* ((wine32 (assoc-ref %build-inputs "wine"))
                    (out (assoc-ref %outputs "out")))
               (copy-recursively (string-append wine32 "/lib/wine32")
                                 (string-append out "/lib/wine32"))
               #t)))
         (add-after 'compress-documentation 'copy-wine32-manpage
           (lambda* (#:key outputs #:allow-other-keys)
             (let* ((wine32 (assoc-ref %build-inputs "wine"))
                    (out (assoc-ref %outputs "out")))
               ;; Copy the missing man file for the wine binary from wine.
               (copy-file (string-append wine32 "/share/man/man1/wine.1.gz")
                          (string-append out "/share/man/man1/wine.1.gz"))
               #t)))
         (add-after 'configure 'patch-dlopen-paths
           ;; Hardcode dlopened sonames to absolute paths.
           (lambda _
             (let* ((library-path (search-path-as-string->list
                                   (getenv "LIBRARY_PATH")))
                    (find-so (lambda (soname)
                               (search-path library-path soname))))
               (substitute* "include/config.h"
                 (("(#define SONAME_.* )\"(.*)\"" _ defso soname)
                  (format #f "~a\"~a\"" defso (find-so soname))))
               #t))))
       #:configure-flags
       (list "--enable-win64"
             (string-append "LDFLAGS=-Wl,-rpath=" %output "/lib/wine64"))
       ,@(strip-keyword-arguments '(#:configure-flags #:make-flags #:phases
                                    #:system)
                                  (package-arguments wine))))
    (synopsis "Implementation of the Windows API (WoW64 version)")
    (supported-systems '("x86_64-linux" "aarch64-linux"))))

;; This minimal build of Wine is needed to prevent a circular dependency with
;; vkd3d.
(define-public wine-minimal
  (package
    (inherit wine)
    (name "wine-minimal")
    (native-inputs (fold alist-delete (package-native-inputs wine)
               '("gettext" "perl" "pkg-config")))
    (inputs `())
    (arguments
     `(#:validate-runpath? #f
       #:phases
       (modify-phases %standard-phases
         (add-after 'configure 'patch-dlopen-paths
           ;; Hardcode dlopened sonames to absolute paths.
           (lambda _
             (let* ((library-path (search-path-as-string->list
                                   (getenv "LIBRARY_PATH")))
                    (find-so (lambda (soname)
                               (search-path library-path soname))))
               (substitute* "include/config.h"
                 (("(#define SONAME_.* )\"(.*)\"" _ defso soname)
                  (format #f "~a\"~a\"" defso (find-so soname))))
               #t))))
       #:configure-flags
       (list "--without-freetype"
             "--without-x")
       ,@(strip-keyword-arguments '(#:configure-flags #:phases)
                                  (package-arguments wine))))))

(define-public wine-staging-patchset-data
  (package
    (name "wine-staging-patchset-data")
    (version "6.6")
    (source
     (origin
       (method git-fetch)
       (uri (git-reference
             (url "https://github.com/wine-staging/wine-staging")
             (commit (string-append "v" version))))
       (file-name (git-file-name name version))
       (sha256
        (base32 "0d5m9pvafr0iw99ny7rgzfmw7zw45q5wfcw68zj88mvzs47xkgms"))))
    (build-system trivial-build-system)
    (native-inputs
     `(("bash" ,bash)
       ("coreutils" ,coreutils)))
    (arguments
     `(#:modules ((guix build utils))
       #:builder
       (begin
         (use-modules (guix build utils))
         (let* ((build-directory ,(string-append name "-" version))
                (source (assoc-ref %build-inputs "source"))
                (bash (assoc-ref %build-inputs "bash"))
                (coreutils (assoc-ref %build-inputs "coreutils"))
                (out (assoc-ref %outputs "out"))
                (wine-staging (string-append out "/share/wine-staging")))
           (copy-recursively source build-directory)
           (with-directory-excursion build-directory
             (substitute* "patches/patchinstall.sh"
               (("/bin/sh")
                (string-append bash "/bin/sh")))
             (substitute* "patches/gitapply.sh"
               (("/usr/bin/env")
                (string-append coreutils "/bin/env"))))
           (copy-recursively build-directory wine-staging)
           #t))))
    (home-page "https://github.com/wine-staging")
    (synopsis "Patchset for Wine")
    (description
     "wine-staging-patchset-data contains the patchset to build Wine-Staging.")
    (license license:lgpl2.1+)))

(define-public wine-staging
  (package
    (inherit wine)
    (name "wine-staging")
    (version (package-version wine-staging-patchset-data))
    (source
     (let* ((wine-version (version-major+minor version))
            (subdirectory (string-append
                           (version-major version)
                           (if (string-suffix? ".0" wine-version)
                               ".0"
                               ".x"))))
       (origin
         (method url-fetch)
         (uri (string-append "https://dl.winehq.org/wine/source/"
                             subdirectory "/"
                             "wine-" wine-version ".tar.xz"))
         (file-name (string-append name "-" wine-version ".tar.xz"))
         (sha256
          (base32 "1bc4zmqpdqs1ncz3qisp8a313pqzi5a31gq1s99ivb60vk325rcr")))))
    (inputs `(("autoconf" ,autoconf)    ; for autoreconf
              ("ffmpeg" ,ffmpeg)
              ("gtk+" ,gtk+)
              ("libva" ,libva)
              ("mesa" ,mesa)
              ("python" ,python)
              ("util-linux" ,util-linux) ; for hexdump
              ("wine-staging-patchset-data" ,wine-staging-patchset-data)
              ,@(package-inputs wine)))
    (arguments
     `(#:phases
       (modify-phases %standard-phases
         ;; Explicitly set the 32-bit version of vulkan-loader when installing
         ;; to i686-linux or x86_64-linux.
         ;; TODO: Add more JSON files as they become available in Mesa.
         ,@(match (%current-system)
             ((or "i686-linux" "x86_64-linux")
              `((add-after 'install 'wrap-executable
                  (lambda* (#:key inputs outputs #:allow-other-keys)
                    (let* ((out (assoc-ref outputs "out"))
                           (icd (string-append out "/share/vulkan/icd.d")))
                      (mkdir-p icd)
                      (copy-file (string-append (assoc-ref inputs "mesa")
                                 "/share/vulkan/icd.d/radeon_icd.i686.json")
                                 (string-append icd "/radeon_icd.i686.json"))
                      (copy-file (string-append (assoc-ref inputs "mesa")
                                 "/share/vulkan/icd.d/intel_icd.i686.json")
                                 (string-append icd "/intel_icd.i686.json"))
                      (wrap-program (string-append out "/bin/wine-preloader")
                                    `("VK_ICD_FILENAMES" ":" =
                                      (,(string-append icd
                                        "/radeon_icd.i686.json" ":"
                                        icd "/intel_icd.i686.json"))))
                      #t)))))
             (_
              `())
             )
         (add-before 'configure 'patch-source-wine-staging
           (lambda* (#:key outputs #:allow-other-keys)
             (let* ((source (assoc-ref %build-inputs "source"))
                    (script (string-append (assoc-ref %build-inputs
                            "wine-staging-patchset-data")
                            "/share/wine-staging/patches/patchinstall.sh")))
               (invoke script (string-append "DESTDIR=" ".") "--all")
               #t)))
         (add-after 'configure 'patch-dlopen-paths
           ;; Hardcode dlopened sonames to absolute paths.
           (lambda _
             (let* ((library-path (search-path-as-string->list
                                   (getenv "LIBRARY_PATH")))
                    (find-so (lambda (soname)
                               (search-path library-path soname))))
               (substitute* "include/config.h"
                 (("(#define SONAME_.* )\"(.*)\"" _ defso soname)
                  (format #f "~a\"~a\"" defso (find-so soname))))
               #t))))
       ,@(strip-keyword-arguments '(#:phases)
                                  (package-arguments wine))))
    (synopsis "Implementation of the Windows API (staging branch, 32-bit only)")
    (description "Wine-Staging is the testing area of Wine.  It
contains bug fixes and features, which have not been integrated into
the development branch yet.  The idea of Wine-Staging is to provide
experimental features faster to end users and to give developers the
possibility to discuss and improve their patches before they are
integrated into the main branch.")
    (home-page "https://github.com/wine-staging")
    ;; In addition to the regular Wine license (lgpl2.1+), Wine-Staging
    ;; provides Liberation and WenQuanYi Micro Hei fonts.  Those use
    ;; different licenses.  In particular, the latter is licensed under
    ;; both GPL3+ and Apache 2 License.
    (license
     (list license:lgpl2.1+ license:silofl1.1 license:gpl3+ license:asl2.0))))

(define-public wine64-staging
  (package
    (inherit wine-staging)
    (name "wine64-staging")
    (inputs `(("wine-staging" ,wine-staging)
              ,@(package-inputs wine-staging)))
    (arguments
     `(#:make-flags
       (list "SHELL=bash"
             (string-append "libdir=" %output "/lib/wine64"))
       #:phases
       (modify-phases %standard-phases
         ;; Explicitly set both the 64-bit and 32-bit versions of vulkan-loader
         ;; when installing to x86_64-linux so both are available.
         ;; TODO: Add more JSON files as they become available in Mesa.
         ,@(match (%current-system)
           ((or "x86_64-linux")
             `((add-after 'copy-wine32-binaries 'wrap-executable
               (lambda* (#:key inputs outputs #:allow-other-keys)
                 (let* ((out (assoc-ref outputs "out")))
                   (wrap-program (string-append out "/bin/wine-preloader")
                                 `("VK_ICD_FILENAMES" ":" =
                                   (,(string-append (assoc-ref inputs "mesa")
                                     "/share/vulkan/icd.d/radeon_icd.x86_64.json" ":"
                                     (assoc-ref inputs "mesa")
                                     "/share/vulkan/icd.d/intel_icd.x86_64.json" ":"
                                     (assoc-ref inputs "wine-staging")
                                     "/share/vulkan/icd.d/radeon_icd.i686.json" ":"
                                     (assoc-ref inputs "wine-staging")
                                     "/share/vulkan/icd.d/intel_icd.i686.json"))))
                   (wrap-program (string-append out "/bin/wine64-preloader")
                                 `("VK_ICD_FILENAMES" ":" =
                                   (,(string-append (assoc-ref inputs "mesa")
                                     "/share/vulkan/icd.d/radeon_icd.x86_64.json"
                                     ":" (assoc-ref inputs "mesa")
                                     "/share/vulkan/icd.d/intel_icd.x86_64.json"
                                     ":" (assoc-ref inputs "wine-staging")
                                     "/share/vulkan/icd.d/radeon_icd.i686.json"
                                     ":" (assoc-ref inputs "wine-staging")
                                     "/share/vulkan/icd.d/intel_icd.i686.json"))))
                   #t)))))
           (_
            `())
           )
         (add-before 'configure 'patch-source-wine-staging
           (lambda* (#:key outputs #:allow-other-keys)
             (let* ((source (assoc-ref %build-inputs "source"))
                    (script (string-append (assoc-ref %build-inputs
                            "wine-staging-patchset-data")
                            "/share/wine-staging/patches/patchinstall.sh")))
               (invoke script (string-append "DESTDIR=" ".") "--all")
               #t)))
         (add-after 'install 'copy-wine32-binaries
           (lambda* (#:key outputs #:allow-other-keys)
             (let* ((wine32 (assoc-ref %build-inputs "wine-staging"))
                    (out (assoc-ref %outputs "out")))
               ;; Copy the 32-bit binaries needed for WoW64.
               (copy-file (string-append wine32 "/bin/wine")
                          (string-append out "/bin/wine"))
               ;; Copy the real 32-bit wine-preloader instead of the wrapped
               ;; version.
               (copy-file (string-append wine32 "/bin/.wine-preloader-real")
                          (string-append out "/bin/wine-preloader"))
               #t)))
         (add-after 'install 'copy-wine32-libraries
           (lambda* (#:key outputs #:allow-other-keys)
             (let* ((wine32 (assoc-ref %build-inputs "wine-staging"))
                    (out (assoc-ref %outputs "out")))
               (copy-recursively (string-append wine32 "/lib/wine32")
                                 (string-append out "/lib/wine32"))
               #t)))
         (add-after 'compress-documentation 'copy-wine32-manpage
           (lambda* (#:key outputs #:allow-other-keys)
             (let* ((wine32 (assoc-ref %build-inputs "wine-staging"))
                    (out (assoc-ref %outputs "out")))
               ;; Copy the missing man file for the wine binary from
               ;; wine-staging.
               (copy-file (string-append wine32 "/share/man/man1/wine.1.gz")
                          (string-append out "/share/man/man1/wine.1.gz"))
               #t)))
         (add-after 'configure 'patch-dlopen-paths
           ;; Hardcode dlopened sonames to absolute paths.
           (lambda _
             (let* ((library-path (search-path-as-string->list
                                   (getenv "LIBRARY_PATH")))
                    (find-so (lambda (soname)
                               (search-path library-path soname))))
               (substitute* "include/config.h"
                 (("(#define SONAME_.* )\"(.*)\"" _ defso soname)
                  (format #f "~a\"~a\"" defso (find-so soname))))
               #t))))
       #:configure-flags
       (list "--enable-win64"
             (string-append "LDFLAGS=-Wl,-rpath=" %output "/lib/wine64"))
       ,@(strip-keyword-arguments '(#:configure-flags #:make-flags #:phases
                                    #:system)
                                  (package-arguments wine-staging))))
    (synopsis "Implementation of the Windows API (staging branch, WoW64
version)")
    (supported-systems '("x86_64-linux" "aarch64-linux"))))

(define dxvk32
  ;; This package provides 32-bit dxvk libraries on 64-bit systems.
  (package
    (name "dxvk32")
    (version "1.5.5")
    (home-page "https://github.com/doitsujin/dxvk/")
    (source (origin
              (method git-fetch)
              (uri (git-reference
                    (url home-page)
                    (commit (string-append "v" version))))
              (file-name (git-file-name name version))
              (sha256
               (base32
                "1inl0qswgvbp0fs76md86ilqf9mbshkpjm8ga81khn9zd6v3fvan"))))
    (build-system meson-build-system)
    (arguments
     `(#:system "i686-linux"
       #:configure-flags (list "--cross-file"
                               (string-append (assoc-ref %build-inputs "source")
                                              "/build-wine32.txt"))))
    (native-inputs
     ;; Since 1.5 dxvk needs gcc-8.1.  See
     ;; https://github.com/doitsujin/dxvk/issues/1292#issuecomment-567067373.
     `(("gcc" ,gcc-9)
       ("glslang" ,glslang)))
    (inputs
     `(("wine" ,wine-staging)))
    (synopsis "Vulkan-based D3D9, D3D10 and D3D11 implementation for Wine")
    (description "A Vulkan-based translation layer for Direct3D 9/10/11 which
allows running complex 3D applications with high performance using Wine.

Use @command{setup_dxvk} to install the required libraries to a Wine prefix.")
    (supported-systems '("x86_64-linux"))
    (license license:zlib)))

(define-public dxvk
  (package
    (inherit dxvk32)
    (name "dxvk")
    (arguments
     `(#:configure-flags (list "--cross-file"
                               (string-append (assoc-ref %build-inputs "source")
                                              "/build-wine"
                                              ,(match (%current-system)
                                                 ("x86_64-linux" "64")
                                                 (_ "32"))
                                              ".txt"))
       #:phases
       (modify-phases %standard-phases
         ,@(if (string=? (%current-system) "x86_64-linux")
             `((add-after 'unpack 'install-32
                 (lambda* (#:key inputs outputs #:allow-other-keys)
                   (let* ((out (assoc-ref outputs "out"))
                          (dxvk32 (assoc-ref inputs "dxvk32")))
                     (mkdir-p (string-append out "/lib32"))
                     (copy-recursively (string-append dxvk32 "/lib")
                                       (string-append out "/lib32"))
                     #t))))
             '())
         (add-after 'install 'install-setup
           (lambda* (#:key inputs outputs #:allow-other-keys)
             (let* ((out (assoc-ref outputs "out"))
                    (bin (string-append out "/bin/setup_dxvk")))
               (mkdir-p (string-append out "/bin"))
               (copy-file "../source/setup_dxvk.sh"
                          bin)
               (chmod bin #o755)
               (substitute* bin
                 (("wine=\"wine\"")
                  (string-append "wine=" (assoc-ref inputs "wine") "/bin/wine"))
                 (("x32") ,(match (%current-system)
                             ("x86_64-linux" "../lib32")
                             (_ "../lib")))
                 (("x64") "../lib"))))))))
    (inputs
     `(("wine" ,(match (%current-system)
                  ;; ("x86_64-linux" wine64)
                  ("x86_64-linux" wine64-staging)
                  ;; ("x86_64-linux" mingw-w64-x86_64)
                  (_ wine)))
       ,@(match (%current-system)
           ("x86_64-linux"
            `(("dxvk32" ,dxvk32)))
           (_ '()))))
    (supported-systems '("i686-linux" "x86_64-linux"))))


code:
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2019 Pierre Langlois <pierre.langlois@gmx.com>
;;; Copyright © 2020 Tobias Geerinckx-Rice <me@tobias.gr>
;;; Copyright © 2020 Tanguy Le Carrour <tanguy@bioneland.org>
;;;
;;; This file is part of GNU Guix.
;;;
;;; GNU Guix is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or (at
;;; your option) any later version.
;;;
;;; GNU Guix is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.

(define-module (gnu packages wireservice)
  #:use-module ((guix licenses) #:prefix license:)
  #:use-module (guix build-system python)
  #:use-module (guix download)
  #:use-module (guix git-download)
  #:use-module (guix packages)
  #:use-module (gnu packages)
  #:use-module (gnu packages check)
  #:use-module (gnu packages databases)
  #:use-module (gnu packages python-web)
  #:use-module (gnu packages python-xyz)
  #:use-module (gnu packages sphinx)
  #:use-module (gnu packages time)
  #:use-module (gnu packages xml))

;; Common package definition for packages from https://github.com/wireservice.
(define-syntax-rule (wireservice-package extra-fields ...)
  (package
    (build-system python-build-system)
    (arguments
     `(#:phases
       (modify-phases %standard-phases
         (replace 'check
           (lambda _
             (invoke "nosetests" "tests")))
         (add-after 'install 'install-docs
           (lambda* (#:key outputs #:allow-other-keys)
             (let* ((out (assoc-ref outputs "out"))
                    (doc (string-append out "/share/doc/"
                                        ,(package-name this-package)
                                        "-"
                                        ,(package-version this-package))))
               (with-directory-excursion "docs"
                 (for-each
                  (lambda (target)
                    (invoke "make" target)
                    (copy-recursively (string-append "_build/" target)
                                      (string-append doc "/" target)))
                  '("html" "dirhtml" "singlehtml" "text")))
               #t))))))
    (license license:expat)
    extra-fields ...))

(define-public python-leather
  (wireservice-package
   (name "python-leather")
   (version "0.3.3")
   (source (origin
             (method git-fetch)
             (uri (git-reference
                   (url "https://github.com/wireservice/leather")
                   (commit version)))
             (file-name (git-file-name name version))
             (sha256
              (base32
               "1ck3dplni99sv4s117cbm07ydwwjsrxkhdy19rnk0iglia1d4s5i"))))
   (native-inputs
    `(("python-nose" ,python-nose)
      ("python-sphinx" ,python-sphinx)
      ("python-sphinx-rtd-theme" ,python-sphinx-rtd-theme)
      ("python-csselect" ,python-cssselect)
      ("python-lxml" ,python-lxml)))
   (propagated-inputs
    `(("python-six" ,python-six)))
   (home-page "https://leather.rtfd.org")
   (synopsis "Python charting for 80% of humans")
   (description "Leather is a Python charting library for those who need
charts now and don't care if they're perfect.")))

(define-public python-agate
  (wireservice-package
   (name "python-agate")
   (version "1.6.1")
   (source (origin
             (method git-fetch)
             (uri (git-reference
                   (url "https://github.com/wireservice/agate")
                   (commit version)))
             (file-name (git-file-name name version))
             (sha256
              (base32
               "077zj8xad8hsa3nqywvf7ircirmx3krxdipl8wr3dynv3l3khcpl"))))
   (native-inputs
    `(("python-nose" ,python-nose)
      ("python-sphinx" ,python-sphinx)
      ("python-sphinx-rtd-theme" ,python-sphinx-rtd-theme)
      ("python-csselect" ,python-cssselect)
      ("python-lxml" ,python-lxml)))
   (propagated-inputs
    `(("python-babel" ,python-babel)
      ("python-isodate" ,python-isodate)
      ("python-leather" ,python-leather)
      ("python-parsedatetime" ,python-parsedatetime)
      ("python-pytimeparse" ,python-pytimeparse)
      ("python-six" ,python-six)
      ("python-slugify" ,python-slugify)))
   (home-page "https://agate.rtfd.org")
   (synopsis "Data analysis library")
   (description "Agate is a Python data analysis library.  It is an
alternative to numpy and pandas that solves real-world problems with readable
code.  Agate was previously known as journalism.")))

(define-public python-agate-sql
  (wireservice-package
   (name "python-agate-sql")
   (version "0.5.4")
   (source (origin
             (method git-fetch)
             (uri (git-reference
                   (url "https://github.com/wireservice/agate-sql")
                   (commit version)))
             (file-name (git-file-name name version))
             (sha256
              (base32
               "16q0b211n5b1qmhzkfl2jr56lda0rvyh5j1wzw26h2n4pm4wxlx2"))))
   (native-inputs
    `(("python-nose" ,python-nose)
      ("python-sphinx" ,python-sphinx)
      ("python-sphinx-rtd-theme" ,python-sphinx-rtd-theme)))
   (propagated-inputs
    `(("python-agate" ,python-agate)
      ("python-crate" ,python-crate)
      ("python-sqlalchemy" ,python-sqlalchemy)))
   (home-page "https://agate-sql.rtfd.org")
   (synopsis "SQL read/write support to agate")
   (description "@code{agatesql} uses a monkey patching pattern to add SQL
support to all @code{agate.Table} instances.")))

(define-public python-agate-dbf
  (wireservice-package
   (name "python-agate-dbf")
   (version "0.2.1")
   (source (origin
             (method git-fetch)
             (uri (git-reference
                   (url "https://github.com/wireservice/agate-dbf")
                   (commit version)))
             (file-name (git-file-name name version))
             (sha256
              (base32
               "1y49fi6pmm7gzhajvqmfpcca2sqnwj24fqnsvzwk7r1hg2iaa2gi"))))
   (native-inputs
    `(("python-nose" ,python-nose)
      ("python-sphinx" ,python-sphinx)
      ("python-sphinx-rtd-theme" ,python-sphinx-rtd-theme)))
   (propagated-inputs
    `(("python-agate" ,python-agate)
      ("python-dbfread" ,python-dbfread)))
   (home-page "https://agate-dbf.rtfd.org")
   (synopsis "Add read support for dbf files to agate")
   (description "@code{agatedbf} uses a monkey patching pattern to add read
for dbf files support to all @code{agate.Table} instances.")))

(define-public python-agate-excel
  (wireservice-package
   (name "python-agate-excel")
   (version "0.2.3")
   (source (origin
             (method git-fetch)
             (uri (git-reference
                   (url "https://github.com/wireservice/agate-excel")
                   (commit version)))
             (file-name (git-file-name name version))
             (sha256
              (base32
               "1k5lv21k19s7kgbj5srd1xgrkqvxqqs49qwj33zncs9l7851afy7"))))
   (native-inputs
    `(("python-nose" ,python-nose)
      ("python-sphinx" ,python-sphinx)
      ("python-sphinx-rtd-theme" ,python-sphinx-rtd-theme)))
   (propagated-inputs
    `(("python-agate" ,python-agate)
      ("python-openpyxl" ,python-openpyxl)
      ("python-xlrd" ,python-xlrd)))
   (home-page "https://agate-excel.rtfd.org")
   (synopsis "Add read support for Excel files (xls and xlsx) to agate")
   (description "@code{agateexcel} uses a monkey patching pattern to add read
for xls and xlsx files support to all @code{agate.Table} instances.")))

(define-public csvkit
  (package
    (name "csvkit")
    (version "1.0.5")
    (source (origin
              (method url-fetch)
              (uri (pypi-uri "csvkit" version))
              (sha256
               (base32
                "1ffmbzk4rxnl1yhqfl58v7kvl5m9cbvjm8v7xp4mvr00sgs91lvv"))))
    (build-system python-build-system)
    (native-inputs
     `(("python-psycopg2" ,python-psycopg2) ; to test PostgreSQL support
       ("python-sphinx" ,python-sphinx)
       ("python-sphinx-rtd-theme" ,python-sphinx-rtd-theme)))
    (inputs
     `(("python-agate-dbf" ,python-agate-dbf)
       ("python-agate-excel" ,python-agate-excel)
       ("python-agate-sql" ,python-agate-sql)
       ("python-six" ,python-six)
       ("python-text-unidecode" ,python-text-unidecode)))
    (arguments
     `(#:phases
       (modify-phases %standard-phases
         (add-after 'install 'install-docs
           (lambda* (#:key outputs #:allow-other-keys)
             (let* ((out  (assoc-ref outputs "out"))
                    (man1 (string-append out "/share/man/man1")))
               (with-directory-excursion "docs"
                 (invoke "make" "man")
                 (copy-recursively "_build/man" man1))
               #t))))))
    (home-page "https://csvkit.rtfd.org")
    (synopsis "Command-line tools for working with CSV")
    (description "csvkit is a suite of command-line tools for converting to
and working with CSV.  It provides the following commands:
@itemize
@item Input:
  @itemize
  @item @command{in2csv}: Convert various formats to CSV.
  @item @command{sql2csv}: Execute SQL commands on a database and return the
data as CSV.
  @end itemize
@item Processing:
  @itemize
  @item @command{csvclean}: Remove common syntax errors.
  @item @command{csvcut}: Filter and truncate CSV files.
  @item @command{csvgrep}: Filter tabular data to only those rows where
certain columns contain a given value or match a regular expression.
  @item @command{csvjoin}: Merges two or more CSV tables together using a
method analogous to SQL JOIN operation.
  @item @command{csvsort}: Sort CSV files.
  @item @command{csvstack}: Stack up the rows from multiple CSV files,
optionally adding a grouping value to each row.
  @end itemize
@item Output and analysis:
  @itemize
  @item @command{csvformat}: Convert a CSV file to a custom output format.
  @item @command{csvjson}: Converts a CSV file into JSON or GeoJSON.
  @item @command{csvlook}: Renders a CSV to the command line in a
Markdown-compatible, fixed-width format.
  @item @command{csvpy}: Loads a CSV file into a @code{agate.csv.Reader}
object and then drops into a Python shell so the user can inspect the data
however they see fit.
  @item @command{csvsql}: Generate SQL statements for a CSV file or execute
those statements directly on a database.
  @item @command{csvstat}: Prints descriptive statistics for all columns in a
CSV file.
  @end itemize
@end itemize")
    (license license:expat)))