code:
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2013, 2014, 2015 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2015 Eric Bavier <bavier@member.fsf.org>
;;; Copyright © 2015 Ricardo Wurmus <rekado@elephly.net>
;;; Copyright © 2016 Leo Famulari <leo@famulari.name>
;;; Copyright © 2016 Mark H Weaver <mhw@netris.org>
;;; Copyright © 2017 Efraim Flashner <efraim@flashner.co.il>
;;; Copyright © 2018, 2019 Tobias Geerinckx-Rice <me@tobias.gr>
;;; Copyright © 2018 Alex Vong <alexvong1995@gmail.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 imagemagick)
  #:use-module (guix packages)
  #:use-module (guix build-system gnu)
  #:use-module (guix build-system perl)
  #:use-module (guix download)
  #:use-module (guix utils)
  #:use-module ((guix licenses) #:prefix license:)
  #:use-module (gnu packages)
  #:use-module (gnu packages algebra)
  #:use-module (gnu packages compression)
  #:use-module (gnu packages fontutils)
  #:use-module (gnu packages ghostscript)
  #:use-module (gnu packages graphviz)
  #:use-module (gnu packages gtk)
  #:use-module (gnu packages image)
  #:use-module (gnu packages pkg-config)
  #:use-module (gnu packages xml)
  #:use-module (gnu packages xorg))

(define-public imagemagick
  (package
    (name "imagemagick")
    ;; The 7 release series has an incompatible API, while the 6 series is still
    ;; maintained. Don't update to 7 until we've made sure that the ImageMagick
    ;; users are ready for the 7-series API.
    (version "6.9.11-11")
    (source (origin
             (method url-fetch)
             (uri (string-append "mirror://imagemagick/ImageMagick-"
                                 version ".tar.xz"))
             (sha256
              (base32
               "1b67rrppvm04aqr76qky5h2a0j2d161h8kwa04fv611w5xwandr2"))))
    (build-system gnu-build-system)
    (arguments
     `(#:configure-flags '("--with-frozenpaths" "--without-gcc-arch"

                           ;; Do not embed the build date in binaries.
                           "--enable-reproducible-build")

       ;; FIXME: The test suite succeeded before version 6.9.6-2.
       ;; Try enabling it again with newer releases.
       #:tests? #f
       #:phases (modify-phases %standard-phases
                  (add-before
                   'build 'pre-build
                   (lambda* (#:key outputs #:allow-other-keys)
                     (substitute* "Makefile"
                       ;; Clear the `LIBRARY_PATH' setting, which otherwise
                       ;; interferes with our own use.
                       (("^LIBRARY_PATH[[:blank:]]*=.*$")
                        "")

                       ;; Since the Makefile overrides $docdir, modify it to
                       ;; refer to what we want.
                       (("^DOCUMENTATION_PATH[[:blank:]]*=.*$")
                        (let ((doc (assoc-ref outputs "doc")))
                          (string-append "DOCUMENTATION_PATH = "
                                         doc "/share/doc/"
                                         ,name "-" ,version "\n"))))
                     #t))
                  (add-before
                   'configure 'strip-configure-xml
                   (lambda _
                     (substitute* "config/configure.xml.in"
                       ;; Do not record 'configure' arguments in the
                       ;; configure.xml file that gets installed: That would
                       ;; include --docdir, and thus retain a reference to the
                       ;; 'doc' output.
                       (("@CONFIGURE_ARGS@")
                        "not recorded"))
                     #t)))))
    ;; TODO: Add Jasper etc.
    (inputs `(("fftw" ,fftw)
              ("graphviz" ,graphviz)
              ("ghostscript" ,ghostscript)
              ("lcms" ,lcms)
              ("libx11" ,libx11)
              ("zlib" ,zlib)
              ("libxml2" ,libxml2)
              ("libtiff" ,libtiff)
              ("libpng" ,libpng)
              ("libjpeg" ,libjpeg-turbo)
              ("pango" ,pango)
              ("freetype" ,freetype)
              ("bzip2" ,bzip2)
              ("xz" ,xz)))
    (native-inputs `(("pkg-config" ,pkg-config)))
    (outputs '("out"
               "doc"))                          ; 26 MiB of HTML documentation
    (home-page "https://www.imagemagick.org/")
    (synopsis "Create, edit, compose, or convert bitmap images")
    (description
     "ImageMagick is a software suite to create, edit, compose, or convert
bitmap images.  It can read and write images in a variety of formats (over 100)
including DPX, EXR, GIF, JPEG, JPEG-2000, PDF, PhotoCD, PNG, Postscript, SVG,
and TIFF.  Use ImageMagick to resize, flip, mirror, rotate, distort, shear and
transform images, adjust image colors, apply various special effects, or draw
text, lines, polygons, ellipses and Bézier curves.")
    (license (license:fsf-free "http://www.imagemagick.org/script/license.php"))))

(define-public perl-image-magick
  (package
    (name "perl-image-magick")
    (version "6.89")
    (source
     (origin
       (method url-fetch)
       (uri (string-append "mirror://cpan/authors/id/J/JC/JCRISTY/"
                           "PerlMagick-" version "-1.tar.gz"))
       (sha256
        (base32
         "0n9afy1z5bhf9phrbahnkwhgcmijn8jggpbzwrivw1zhliliiy68"))))
    (build-system perl-build-system)
    (native-inputs `(("pkg-config" ,pkg-config)))
    (inputs `(("imagemagick" ,imagemagick)))
    (arguments
     `(#:tests? #f ;;Failed 2/23 test programs. 2/353 subtests failed.
       #:phases
       (modify-phases %standard-phases
         (add-before
          'configure 'image-magick-flags
          (lambda* (#:key inputs #:allow-other-keys)
            (let ((im (assoc-ref inputs "imagemagick")))
              (substitute* "Makefile.PL"
                (("my \\$INC_magick = .*")
                 "my $INC_magick = `pkg-config --cflags ImageMagick`;\n")
                (("my \\$LIBS_magick = .*")
                 "my $LIBS_magick = `pkg-config --libs ImageMagick`;\n"))
              #t)))
         (add-before
          'check 'skip-mpeg-tests
          (lambda _
            ;; TODO: MPEG tests fail even though our imagemagick supports
            ;; MPEG.  Has been reported elsewhere,
            ;; http://www.imagemagick.org/discourse-server/viewtopic.php?f=7&t=25036,
            ;; so skip for now.
            (delete-file "t/mpeg/read.t")
            #t)))))
    (home-page "https://metacpan.org/release/PerlMagick")
    (synopsis "Perl interface to ImageMagick")
    (description "This Perl extension allows the reading, manipulation and
writing of a large number of image file formats using the ImageMagick library.
Use it to create, edit, compose, or convert bitmap images from within a Perl
script.")
    ;; See Magick.pm
    (license (package-license imagemagick))))

(define-public graphicsmagick
  (package
    (name "graphicsmagick")
    (version "1.3.35")
    (source
     (origin
       (method url-fetch)
       (uri
        (list
         (string-append "mirror://sourceforge/graphicsmagick/graphicsmagick"
                        "/" version "/GraphicsMagick-" version ".tar.xz")
         (string-append "ftp://ftp.graphicsmagick.org/pub/"
                        "GraphicsMagick/" (version-major+minor version)
                        "/GraphicsMagick-" version ".tar.xz")))
       (sha256
        (base32
         "0l024l4hawm9s3jqrgi2j0lxgm61dqh8sgkj1017ma7y11hqv2hq"))))
    (build-system gnu-build-system)
    (arguments
     `(#:configure-flags
       (list "--with-frozenpaths"
             "--enable-shared=yes"
             "--with-x=yes"
             "--with-quantum-depth=16" ; required by Octave
             "--enable-quantum-library-names"
             (string-append "--with-gs-font-dir="
                            (assoc-ref %build-inputs "gs-fonts")
                            "/share/fonts/type1/ghostscript"))))
    (inputs
     `(("graphviz" ,graphviz)
       ("ghostscript" ,ghostscript)
       ("gs-fonts" ,gs-fonts)
       ("lcms" ,lcms)
       ("libx11" ,libx11)
       ("libxml2" ,libxml2)
       ("libtiff" ,libtiff)
       ("libpng" ,libpng)
       ("libjpeg" ,libjpeg-turbo)
       ("freetype" ,freetype)
       ("bzip2" ,bzip2)
       ("xz" ,xz)
       ("zlib" ,zlib)))
    (native-inputs
     `(("pkg-config" ,pkg-config)))
    (outputs '("out"                  ; 13 MiB
               "doc"))                ; ~7 MiB
    (home-page "http://www.graphicsmagick.org")
    (synopsis "Create, edit, compose, or convert bitmap images")
    (description
     "GraphicsMagick provides a comprehensive collection of utilities,
programming interfaces, and GUIs, to support file format conversion, image
processing, and 2D vector rendering.")
    (license license:expat)))


code:
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2015 Roel Janssen <roel@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 inklingreader)
  #:use-module ((guix licenses) #:prefix license:)
  #:use-module (guix packages)
  #:use-module (guix download)
  #:use-module (guix build-system gnu)
  #:use-module (gnu packages)
  #:use-module (gnu packages autotools)
  #:use-module (gnu packages glib)
  #:use-module (gnu packages gnome)
  #:use-module (gnu packages gtk)
  #:use-module (gnu packages libusb)
  #:use-module (gnu packages pkg-config))

(define-public inklingreader
  (package
    (name "inklingreader")
    (version "0.8")
    (source (origin
              (method url-fetch)
              (uri (string-append
                    "ftp://alpha.gnu.org/gnu/inklingreader/inklingreader-"
                    version ".tar.gz"))
              (sha256
               (base32
                "0ikg95mgwfqh0bq4dzvkfmdiycacqvv27g91hl6adwk5y3gzl96g"))))
    (build-system gnu-build-system)
    (inputs
     `(("glib" ,glib)
       ("cairo" ,cairo)
       ("gtk+" ,gtk+)
       ("librsvg" ,librsvg)
       ("libusb" ,libusb)))
    (native-inputs
     `(("pkg-config" ,pkg-config)))
    (home-page "https://www.gnu.org/software/inklingreader/")
    (synopsis "Wacom Inkling sketch format conversion and manipulation")
    (description
     "GNU InklingReader is a package to support the Wacom Inkling device,
including data conversion to various free formats, basic editing features,
and an Inkscape plugin.")
    (license license:gpl3+)))

license: mit


code:
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2014 John Darrington <jmd@gnu.org>
;;; Copyright © 2014, 2016 Mark H Weaver <mhw@netris.org>
;;; Copyright © 2016, 2018 Ricardo Wurmus <rekado@elephly.net>
;;; Copyright © 2017, 2020 Marius Bakke <mbakke@fastmail.com>
;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
;;; Copyright © 2020 Maxim Cournoyer <maxim.cournoyer@gmail.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 inkscape)
  #: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 (gnu packages)
  #:use-module (gnu packages aspell)
  #:use-module (gnu packages bdw-gc)
  #:use-module (gnu packages boost)
  #:use-module (gnu packages check)
  #:use-module (gnu packages glib)
  #:use-module (gnu packages gnome)
  #:use-module (gnu packages graphics)
  #:use-module (gnu packages gtk)
  #:use-module (gnu packages imagemagick)
  #:use-module (gnu packages libreoffice)
  #:use-module (gnu packages maths)
  #:use-module (gnu packages perl)
  #:use-module (gnu packages pdf)
  #:use-module (gnu packages popt)
  #:use-module (gnu packages python)
  #:use-module (gnu packages xml)
  #:use-module (gnu packages ghostscript)
  #:use-module (gnu packages fontutils)
  #:use-module (gnu packages image)
  #:use-module (gnu packages pkg-config))

(define-public inkscape
  (package
    (name "inkscape")
    (version "0.92.4")
    (source (origin
              (method url-fetch)
              (uri (string-append "https://media.inkscape.org/dl/"
                                  "resources/file/"
                                  "inkscape-" version ".tar.bz2"))
              (patches (search-patches "inkscape-poppler-0.76.patch"))
              (sha256
               (base32
                "0pjinhjibfsz1aywdpgpj3k23xrsszpj4a1ya5562dkv2yl2vv2p"))))
    (build-system cmake-build-system)
    (inputs
     `(("aspell" ,aspell)
       ("gtkmm" ,gtkmm-2)
       ("gtk" ,gtk+-2)
       ("gsl" ,gsl)
       ("poppler" ,poppler)
       ("libpng" ,libpng)
       ("libxml2" ,libxml2)
       ("libxslt" ,libxslt)
       ("libgc" ,libgc)
       ("freetype" ,freetype)
       ("popt" ,popt)
       ("potrace" ,potrace)
       ("python" ,python-2)
       ("lcms" ,lcms)
       ("boost" ,boost)))
    (native-inputs
     `(("intltool" ,intltool)
       ("glib" ,glib "bin")
       ("perl" ,perl)
       ("pkg-config" ,pkg-config)))
    ;; FIXME: tests require gmock
    (arguments
     `(#:tests? #f
       #:phases
       (modify-phases %standard-phases
         (add-after 'unpack 'patch-icon-cache-generator
           (lambda _
             (substitute* "share/icons/application/CMakeLists.txt"
              (("gtk-update-icon-cache") "true"))
             #t))
         (add-after 'unpack 'adjust-for-new-poppler
           (lambda _
             (substitute* (find-files "src/extension/internal/pdfinput")
               ;; Needed for Poppler 0.82.
               (("Unicode \\*u") "Unicode const *u")
               ;; Needed for Poppler 0.83.
               (("\\(GfxPath") "(const GfxPath")
               (("GfxSubpath") "const GfxSubpath")
               (("new GlobalParams\\(\\)")
                "std::unique_ptr<GlobalParams>(new GlobalParams())")
               (("new GlobalParams\\(poppler_datadir\\)")
                "std::unique_ptr<GlobalParams>(new GlobalParams(poppler_datadir))"))
             #t)))))
    (home-page "https://inkscape.org/")
    (synopsis "Vector graphics editor")
    (description "Inkscape is a vector graphics editor.  What sets Inkscape
apart is its use of Scalable Vector Graphics (SVG), an XML-based W3C standard,
as the native format.")
    (license license:gpl2+)))

(define-public inkscape-1.0
  (package
    (name "inkscape")
    (version "1.0")
    (source
     (origin
       (method url-fetch)
       (uri (string-append "https://media.inkscape.org/dl/"
                           "resources/file/"
                           "inkscape-" version ".tar.xz"))
       (sha256
        (base32
         "1fwl7yjkykqb86555k4fm24inhc40mrvxqwgl2v2vi9alv8j7hc9"))
       (modules '((guix build utils)
                  (ice-9 format)))
       (snippet
        '(begin
           (let-syntax
               ;; XXX: The build system doesn't currently support using
               ;; system libraries over bundled ones (see:
               ;; https://gitlab.com/inkscape/inkscape/issues/876).
               ((unbundle
                 (syntax-rules ()
                   ((_ (name source-dir use-pkg-config?) ...)
                    (begin
                      ;; Delete bundled source directories.
                      (delete-file-recursively source-dir) ...
                      (substitute* '("src/CMakeLists.txt"
                                     "src/3rdparty/CMakeLists.txt")
                        (((string-append ".*add_subdirectory\\("
                                         (basename source-dir) "\\).*"))
                         "") ...)
                      ;; Remove bundled entries from INKSCAPE_TARGET_LIBS.
                      (substitute* "src/CMakeLists.txt"
                        (((string-append name "_LIB.*")) "") ...)
                      ;; Register the external libraries, so that their
                      ;; headers are added to INKSCAPE_INCS_SYS and their
                      ;; shared libraries added to INKSCAPE_LIBS.
                      (if use-pkg-config?
                          (let* ((width (string-length "pkg_check_modules("))
                                 (indent (string-join (make-list width " ") "")))
                            (substitute* "CMakeScripts/DefineDependsandFlags.cmake"
                              (("^pkg_check_modules\\(INKSCAPE_DEP REQUIRED.*" start)
                               (string-append start
                                              (format #f "~a~a~%" indent name)))))
                          (substitute* "CMakeScripts/DefineDependsandFlags.cmake"
                            (("^find_package\\(Iconv REQUIRED\\).*" start)
                             (string-append (format #f "
find_path(~a_INCLUDE_DIR NAMES ~:*~a/~:*~a.h ~:*~a.h)
if(NOT ~:*~a_INCLUDE_DIR)
  message(FATAL_ERROR \"~:*~a headers not found\")
else()
  list(APPEND INKSCAPE_INCS_SYS ${~:*~a_INCLUDE_DIR})
endif()

find_library(~:*~a_LIB NAMES ~:*~a)
if(NOT ~:*~a_LIB)
  message(FATAL_ERROR \"~:*~a library not found\")
else()
  list(APPEND INKSCAPE_LIBS ~:*~a_LIB)
endif()~%~%"
                                                    name)
                                            start)))) ...
                      ;; Fix the references to the headers of the
                      ;; unbundled libraries.
                      (substitute* (find-files "." "\\.h$|\\.cpp$")
                        (((string-append "#include (\"|<)3rdparty/"
                                         (basename source-dir)) _ quote)
                         (string-append "#include " quote
                                        (basename source-dir)))
                        ...))))))
             (unbundle ("2geom" "src/2geom" #t)
                       ;; libcroco cannot be unbundled as it is heavily
                       ;; modified (see:
                       ;; https://gitlab.com/inkscape/inkscape/issues/876#note_276114904).
                       ;; ("croco" "src/3rdparty/libcroco" #t)
                       ;; FIXME: Unbundle the following libraries once they
                       ;; have been packaged.
                       ;; ("cola" "src/3rdparty/adaptagrams/libcola")
                       ;; ("avoid" "src/3rdparty/adaptagrams/libavoid")
                       ;; ("vpsc" "src/3rdparty/adaptagrams/libvpsc")
                       ;; libuemf cannot be unbundled as it slightly modified
                       ;; from upstream (see:
                       ;; https://gitlab.com/inkscape/inkscape/issues/973).
                       ;; ("uemf" "src/3rdparty/libuemf" #f)
                       ;; FIXME: libdepixelize upstream is ancient and doesn't
                       ;; build with a recent lib2geom
                       ;; (see: https://bugs.launchpad.net/libdepixelize/+bug/1862458).
                       ;;("depixelize" "src/3rdparty/libdepixelize")
                       ("autotrace" "src/3rdparty/autotrace" #t)))
           ;; Lift the requirement on the double-conversion library, as
           ;; it is only needed by lib2geom, which is now unbundled.
           (substitute* "CMakeScripts/DefineDependsandFlags.cmake"
             ((".*find_package\\(DoubleConversion.*") ""))
           #t))))
    (build-system cmake-build-system)
    (arguments
     `(#:tests? #t
       #:test-target "check"            ;otherwise some test binaries are missing
       #:imported-modules (,@%cmake-build-system-modules
                           (guix build glib-or-gtk-build-system))
       #:modules ((guix build cmake-build-system)
                  ((guix build glib-or-gtk-build-system) #:prefix glib-or-gtk:)
                  (guix build utils))
       #:phases
       (modify-phases %standard-phases
         (add-after 'unpack 'patch-icon-cache-generator
           (lambda _
             (substitute* "share/icons/application/CMakeLists.txt"
               (("gtk-update-icon-cache") "true"))
             #t))
         (add-after 'unpack 'disable-latex-export-tests
           ;; FIXME: For some reason the test.pdf_tex file generated by the
           ;; "--export-latex" lacks "some text" in its content when run in
           ;; the build environment.  Skip the related tests.
           (lambda _
             (substitute* "testfiles/cli_tests/CMakeLists.txt"
               (("add_cli_test\\(export-latex")
                "message(TEST_DISABLED: export-latex"))
             #t))
         (add-after 'unpack 'set-home
           ;; Mute Inkscape warnings during tests.
           (lambda _
             (setenv "HOME" (getcwd))
             (format #t "ARGS is set to: ~a" (getenv "ARGS"))
             #t))
         ;; Move the check phase after the install phase, as when run in the
         ;; tests, Inkscape relies on files that are not yet installed, such
         ;; as the "share/inkscape/ui/units.xml" file.
         (delete 'check)
         (add-after 'install 'check
           (assoc-ref %standard-phases 'check))
         (add-after 'install 'glib-or-gtk-compile-schemas
           (assoc-ref glib-or-gtk:%standard-phases 'glib-or-gtk-compile-schemas))
         (add-after 'glib-or-gtk-compile-schemas 'glib-or-gtk-wrap
           (assoc-ref glib-or-gtk:%standard-phases 'glib-or-gtk-wrap)))))
    (inputs
     `(("aspell" ,aspell)
       ("autotrace" ,autotrace)
       ("gdl" ,gdl-minimal)
       ("gtkmm" ,gtkmm)
       ("gtk" ,gtk+)
       ("gtkspell3" ,gtkspell3)
       ("gsl" ,gsl)
       ("poppler" ,poppler)
       ("lib2geom" ,lib2geom)
       ("libjpeg" ,libjpeg-turbo)
       ("libpng" ,libpng)
       ("libxml2" ,libxml2)
       ("libxslt" ,libxslt)
       ("libgc" ,libgc)
       ("libsoup" ,libsoup-minimal)
       ("libcdr" ,libcdr)
       ("libvisio" ,libvisio)
       ("libwpd" ,libwpd)
       ("libwpg" ,libwpg)
       ("freetype" ,freetype)
       ("popt" ,popt)
       ("potrace" ,potrace)
       ("lcms" ,lcms)
       ("boost" ,boost)))
    (native-inputs
     `(("imagemagick" ,imagemagick)     ;for tests
       ("intltool" ,intltool)
       ("glib" ,glib "bin")
       ("googletest" ,googletest)
       ("perl" ,perl)
       ("pkg-config" ,pkg-config)
       ("python" ,python-wrapper)))
    (home-page "https://inkscape.org/")
    (synopsis "Vector graphics editor")
    (description "Inkscape is a vector graphics editor.  What sets Inkscape
apart is its use of Scalable Vector Graphics (SVG), an XML-based W3C standard,
as the native format.")
    (license license:gpl3+)))           ;see the file COPYING


code:
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2019 Carl Dong <contact@carldong.me>
;;;
;;; 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 installers)
  #:use-module ((guix licenses) #:prefix license:)
  #:use-module (gnu packages)
  #:use-module (gnu packages compression)
  #:use-module (gnu packages cross-base)
  #:use-module (gnu packages python-xyz)
  #:use-module (guix packages)
  #:use-module (guix download)
  #:use-module (guix build-system scons)
  #:use-module (guix utils))

(define (make-nsis machine target-arch nsis-target-type)
  (let* ((triplet (string-append machine "-" "w64-mingw32"))
         (xbinutils (cross-binutils triplet))
         (xlibc (cross-libc triplet))
         (xgcc (cross-gcc triplet #:libc xlibc)))
    (package
      (name (string-append "nsis-" machine))
      (version "3.05")
      (source (origin
                (method url-fetch)
                (uri (string-append "http://prdownloads.sourceforge.net/nsis/nsis-"
                                    version "-src.tar.bz2"))
                (sha256
                 (base32
                  "1sbwx5vzpddharkb7nj4q5z3i5fbg4lan63ng738cw4hmc4v7qdn"))
                (patches (search-patches "nsis-env-passthru.patch"))))
      (build-system scons-build-system)
      (native-inputs `(("xgcc" ,xgcc)
                       ("xbinutils" ,xbinutils)
                       ("mingw-w64" ,xlibc)))
      (inputs `(("zlib" ,zlib)))
      (arguments
       `(#:scons ,scons-python2
         #:modules ((srfi srfi-1)
                    (srfi srfi-26)
                    (guix build utils)
                    (guix build scons-build-system))
         #:tests? #f
         #:scons-flags `("UNICODE=yes"
                         "SKIPUTILS=MakeLangId,Makensisw,NSIS Menu,SubStart,zip2exe"
                         "SKIPDOC=COPYING"
                         "STRIP_CP=no"
                         ,(string-append "PREFIX=" %output)
                         ,(string-append "TARGET_ARCH=" ,target-arch)
                         ,(string-append "XGCC_W32_PREFIX=" ,triplet "-")
                         ,(string-append "PREFIX_PLUGINAPI_INC=" (assoc-ref %build-inputs "mingw-w64") "/include/")
                         ,(string-append "PREFIX_PLUGINAPI_LIB=" (assoc-ref %build-inputs "mingw-w64") "/lib/"))
         #:build-targets '("makensis"
                           "stubs"
                           "plugins"
                           "utils")
         #:install-targets '("install-stubs"
                             "install-plugins"
                             "install-data"
                             "install-utils"
                             "install-compiler"
                             "install-conf")
         #:phases (modify-phases %standard-phases
                    (add-before 'build 'fix-env
                      (lambda _
                        (define* (filter-delimited-string delimited-string predicate #:optional (delimiter #\:))
                          ;; Given a DELIMITED-STRING delimited by DELIMITER,
                          ;; only keep items that satisfy PREDICATE
                          (string-join
                           (filter predicate (string-split delimited-string delimiter))
                           (string delimiter)))
                        (define (mingw-path? path)
                          (string-prefix? (assoc-ref %build-inputs "mingw-w64") path))
                        (for-each
                         (lambda (env-name)
                           (let ((env-val (getenv env-name)))
                             ;; Remove all mingw-w64 paths from env vars meant
                             ;; for native toolchain
                             (setenv env-name
                                     (filter-delimited-string env-val (negate mingw-path?)))
                             ;; Add the removed paths back into
                             ;; CROSS_-prefixed version of env vars
                             (setenv (string-append "CROSS_" env-name)
                                     (filter-delimited-string env-val mingw-path?))))
                         '("CPATH" "LIBRARY_PATH"))
                        ;; Hack to place mingw-w64 path at the end of search
                        ;; paths.  Could probably use a specfile and dirafter
                        (setenv "CROSS_CPLUS_INCLUDE_PATH"
                                (string-join
                                 `(,@(map (cut string-append (assoc-ref %build-inputs "xgcc") <>)
                                          `("/include/c++"
                                            ,(string-append "/include/c++/" ,triplet)
                                            "/include/c++/backward"
                                            ,@(map (cut string-append "/lib/gcc/" ,triplet "/" ,(package-version xgcc) <>)
                                                   '("/include"
                                                     "/include-fixed"))))
                                   ,(getenv "CROSS_CPATH"))
                                 ":"))))
                    (add-before 'build 'fix-target-detection
                      (lambda _
                        ;; NSIS target detection is screwed up, manually
                        ;; change it ourselves
                        (substitute* "Source/build.cpp" (("m_target_type=TARGET_X86ANSI")
                                                         (string-append "m_target_type=" ,nsis-target-type))))))))
      (home-page "http://nsis.sourceforge.net/")
      (synopsis "A professional open source system to create Windows installers")
      (description
       "NSIS (Nullsoft Scriptable Install System) is a professional open
source system to create Windows installers. It is designed to be as small and
flexible as possible and is therefore very suitable for internet
distribution.")
      (license (license:non-copyleft "file://COPYING"
                                     "See COPYING in the distribution.")))))

(define-public nsis-x86_64
  (make-nsis "x86_64" "amd64" "TARGET_AMD64"))

(define-public nsis-i686
  (make-nsis "i686" "x86" "TARGET_X86UNICODE"))


code:
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2018 Pierre Neidhardt <mail@ambrevar.xyz>
;;; Copyright © 2019, 2020 Tobias Geerinckx-Rice <me@tobias.gr>
;;; Copyright © 2019, 2020 Martin Becze <mjbecze@riseup.net>
;;; Copyright © 2020 Michael Rohleder <mike@rohleder.de>
;;;
;;; 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 ipfs)
  #:use-module ((guix licenses) #:prefix license:)
  #:use-module (guix packages)
  #:use-module (guix git-download)
  #:use-module (guix download)
  #:use-module (guix build-system go)
  #:use-module (gnu packages golang))

(define-public go-github-com-ipfs-go-ipfs-cmdkit-files
  (let ((commit
          "386fcf8f18a185ec121676665fe2d9574496048d")
        (revision "0"))
    (package
      (name "go-github-com-ipfs-go-ipfs-cmdkit-files")
      (version (git-version "1.1.3" revision commit))
      (source
        (origin
          (method git-fetch)
          (uri (git-reference
                 (url "https://github.com/ipfs/go-ipfs-cmdkit")
                 (commit commit)))
          (file-name (git-file-name name version))
          (sha256
            (base32
              "0qk6fshgdmhp8dip2ksm13j6nywi41m9mn0czkvmw6b697z85l2r"))))
      (build-system go-build-system)
      (arguments
       '(#:unpack-path "github.com/ipfs/go-ipfs-cmdkit"
         #:import-path "github.com/ipfs/go-ipfs-cmdkit/files"))
      (home-page "https://github.com/ipfs/go-ipfs-cmdkit")
      (synopsis "Shared types, functions and values for go-ipfs")
      (description "@command{cmdkit} offers some types, functions and values
that are shared between @command{go-ipfs/commands} and its rewrite
@command{go-ipfs-cmds}.")
      (license license:expat))))

(define-public go-github-com-ipfs-go-ipfs-api
  (let ((commit
          "dafc2a13a4389ac1a6c2786e34ab70a4f26d3a3f")
        (revision "0"))
    (package
      (name "go-github-com-ipfs-go-ipfs-api")
      (version (git-version "1.3.1" revision commit))
      (source
       (origin
         (method git-fetch)
         (uri (git-reference
               (url "https://github.com/ipfs/go-ipfs-api")
               (commit commit)))
         (file-name (git-file-name name version))
         (sha256
          (base32
           "06kibnwb037sqynk99j07wm8alvxwx3bari9gdax4jv93396kycj"))))
      (build-system go-build-system)
      (arguments
       '(#:import-path "github.com/ipfs/go-ipfs-api"
         ;; TODO: Tests fail, might need network access.
         #:tests? #f))
      (native-inputs
       `(("go-github-com-ipfs-go-ipfs-cmdkit-files" ,go-github-com-ipfs-go-ipfs-cmdkit-files)
         ("go-github-com-libp2p-go-libp2p-metrics" ,go-github-com-libp2p-go-libp2p-metrics)
         ("go-github-com-libp2p-go-flow-metrics" ,go-github-com-libp2p-go-flow-metrics)
         ("go-github-com-libp2p-go-libp2p-peer" ,go-github-com-libp2p-go-libp2p-peer)
         ("go-github-com-libp2p-go-libp2p-protocol" ,go-github-com-libp2p-go-libp2p-protocol)
         ("go-github-com-libp2p-go-libp2p-crypto" ,go-github-com-libp2p-go-libp2p-crypto)
         ("go-github-com-mitchellh-go-homedir" ,go-github-com-mitchellh-go-homedir)
         ("go-github-com-multiformats-go-multiaddr" ,go-github-com-multiformats-go-multiaddr)
         ("go-github-com-multiformats-go-multiaddr-net" ,go-github-com-multiformats-go-multiaddr-net)
         ("go-github-com-btcsuite-btcd-btcec" ,go-github-com-btcsuite-btcd-btcec)
         ("go-github-com-gogo-protobuf" ,go-github-com-gogo-protobuf)
         ("go-github-com-minio-blake2b-simd" ,go-github-com-minio-blake2b-simd)
         ("go-github-com-minio-sha256-simd" ,go-github-com-minio-sha256-simd)
         ("go-github-com-mr-tron-base58" ,go-github-com-mr-tron-base58)
         ("go-github-com-multiformats-go-multihash" ,go-github-com-multiformats-go-multihash)
         ("go-golang-org-x-crypto" ,go-golang-org-x-crypto)
         ("go-github-com-spaolacci-murmur3" ,go-github-com-spaolacci-murmur3)
         ("go-github-com-gxed-hashland-keccakpg" ,go-github-com-gxed-hashland-keccakpg)
         ("go-github-com-whyrusleeping-tar-utils" ,go-github-com-whyrusleeping-tar-utils)
         ("go-github-com-cheekybits-is" ,go-github-com-cheekybits-is)))
      (home-page "https://github.com/ipfs/go-ipfs-api")
      (synopsis "Unofficial Go interface to IPFS's HTTP API")
      (description "An unofficial Go interface to IPFS's HTTP API")
      (license license:expat))))

(define-public gx
  (package
    (name "gx")
    (version "0.14.3")
    (source
     (origin
       (method git-fetch)
       (uri (git-reference
             (url "https://github.com/whyrusleeping/gx")
             (commit (string-append "v" version))))
       (file-name (git-file-name name version))
       (sha256
        (base32 "1sk20kv3rfsnizgwmcmmr69jb1b2iwzqh9wwwd6wg6x0pnqm8swc"))))
    (build-system go-build-system)
    (arguments
     '(#:import-path "github.com/whyrusleeping/gx"))
    (native-inputs
     `(("go-github-com-blang-semver" ,go-github-com-blang-semver)
       ("go-github-com-gxed-hashland-keccakpg" ,go-github-com-gxed-hashland-keccakpg)
       ("go-github-com-ipfs-go-ipfs-api" ,go-github-com-ipfs-go-ipfs-api)
       ("go-github-com-ipfs-go-ipfs-cmdkit-files" ,go-github-com-ipfs-go-ipfs-cmdkit-files)
       ("go-github-com-libp2p-go-flow-metrics" ,go-github-com-libp2p-go-flow-metrics)
       ("go-github-com-libp2p-go-libp2p-crypto" ,go-github-com-libp2p-go-libp2p-crypto)
       ("go-github-com-libp2p-go-libp2p-metrics" ,go-github-com-libp2p-go-libp2p-metrics)
       ("go-github-com-libp2p-go-libp2p-peer" ,go-github-com-libp2p-go-libp2p-peer)
       ("go-github-com-libp2p-go-libp2p-protocol" ,go-github-com-libp2p-go-libp2p-protocol)
       ("go-github-com-minio-blake2b-simd" ,go-github-com-minio-blake2b-simd)
       ("go-github-com-minio-sha256-simd" ,go-github-com-minio-sha256-simd)
       ("go-github-com-mitchellh-go-homedir" ,go-github-com-mitchellh-go-homedir)
       ("go-github-com-mr-tron-base58" ,go-github-com-mr-tron-base58)
       ("go-github-com-multiformats-go-multiaddr" ,go-github-com-multiformats-go-multiaddr)
       ("go-github-com-multiformats-go-multiaddr-net" ,go-github-com-multiformats-go-multiaddr-net)
       ("go-github-com-multiformats-go-multihash" ,go-github-com-multiformats-go-multihash)
       ("go-github-com-spaolacci-murmur3" ,go-github-com-spaolacci-murmur3)
       ("go-github-com-whyrusleeping-tar-utils" ,go-github-com-whyrusleeping-tar-utils)
       ("go-github-com-btcsuite-btcd-btcec" ,go-github-com-btcsuite-btcd-btcec)
       ("go-github-com-gogo-protobuf" ,go-github-com-gogo-protobuf)
       ("go-github-com-sabhiram-go-gitignore" ,go-github-com-sabhiram-go-gitignore)
       ("go-github-com-urfave-cli" ,go-github-com-urfave-cli)
       ("go-github-com-whyrusleeping-json-filter" ,go-github-com-whyrusleeping-json-filter)
       ("go-github-com-whyrusleeping-progmeter" ,go-github-com-whyrusleeping-progmeter)
       ("go-github-com-whyrusleeping-stump" ,go-github-com-whyrusleeping-stump)
       ("go-golang-org-x-crypto" ,go-golang-org-x-crypto)))
    (home-page "https://github.com/whyrusleeping/gx")
    (synopsis "Package management tool using IPFS")
    (description "@command{gx} is a packaging tool built around the
distributed, content addressed file system IPFS.  It aims to be flexible,
powerful and simple.")
    (license license:expat)))

(define-public go-github-com-whyrusleeping-gx-util
  (package
    (inherit gx)
    (name "go-github-com-whyrusleeping-gx-util")
    (arguments
     '(#:unpack-path "github.com/whyrusleeping/gx"
       #:import-path "github.com/whyrusleeping/gx/gxutil"))))

(define-public gx-go
  (package
    (name "gx-go")
    (version "1.9.0")
    (source
     (origin
       (method git-fetch)
       (uri (git-reference
             (url "https://github.com/whyrusleeping/gx-go")
             (commit (string-append "v" version))))
       (file-name (git-file-name name version))
       (sha256
        (base32
         "0fdy4b3ymqw6hzvvjwq37mfrdmizc8lxm53axw93n3x6118na9jc"))))
    (build-system go-build-system)
    (arguments
     '(#:import-path "github.com/whyrusleeping/gx-go"))
    (native-inputs
     `(("go-github-com-whyrusleeping-gx-util" ,go-github-com-whyrusleeping-gx-util)
       ("go-github-com-kr-fs" ,go-github-com-kr-fs)
       ("go-github-com-gxed-hashland-keccakpg" ,go-github-com-gxed-hashland-keccakpg)
       ("go-github-com-ipfs-go-ipfs-api" ,go-github-com-ipfs-go-ipfs-api)
       ("go-github-com-ipfs-go-ipfs-cmdkit-files" ,go-github-com-ipfs-go-ipfs-cmdkit-files)
       ("go-github-com-libp2p-go-flow-metrics" ,go-github-com-libp2p-go-flow-metrics)
       ("go-github-com-libp2p-go-libp2p-crypto" ,go-github-com-libp2p-go-libp2p-crypto)
       ("go-github-com-libp2p-go-libp2p-metrics" ,go-github-com-libp2p-go-libp2p-metrics)
       ("go-github-com-libp2p-go-libp2p-peer" ,go-github-com-libp2p-go-libp2p-peer)
       ("go-github-com-libp2p-go-libp2p-protocol" ,go-github-com-libp2p-go-libp2p-protocol)
       ("go-github-com-minio-blake2b-simd" ,go-github-com-minio-blake2b-simd)
       ("go-github-com-minio-sha256-simd" ,go-github-com-minio-sha256-simd)
       ("go-github-com-mitchellh-go-homedir" ,go-github-com-mitchellh-go-homedir)
       ("go-github-com-mr-tron-base58" ,go-github-com-mr-tron-base58)
       ("go-github-com-multiformats-go-multiaddr" ,go-github-com-multiformats-go-multiaddr)
       ("go-github-com-multiformats-go-multiaddr-net" ,go-github-com-multiformats-go-multiaddr-net)
       ("go-github-com-multiformats-go-multihash" ,go-github-com-multiformats-go-multihash)
       ("go-github-com-spaolacci-murmur3" ,go-github-com-spaolacci-murmur3)
       ("go-github-com-whyrusleeping-tar-utils" ,go-github-com-whyrusleeping-tar-utils)
       ("go-github-com-btcsuite-btcd-btcec" ,go-github-com-btcsuite-btcd-btcec)
       ("go-github-com-gogo-protobuf" ,go-github-com-gogo-protobuf)
       ("go-github-com-sabhiram-go-gitignore" ,go-github-com-sabhiram-go-gitignore)
       ("go-github-com-urfave-cli" ,go-github-com-urfave-cli)
       ("go-github-com-whyrusleeping-progmeter" ,go-github-com-whyrusleeping-progmeter)
       ("go-github-com-whyrusleeping-stump" ,go-github-com-whyrusleeping-stump)
       ("go-golang-org-x-crypto" ,go-golang-org-x-crypto)))
    (home-page "https://github.com/whyrusleeping/gx-go")
    (synopsis "Golang subtool for the @command{gx} package manager")
    (description "A subtool for the @command{gx} package manager for packages
written in Go.")
    (license license:expat)))

(define-public go-ipfs
  (package
    (name "go-ipfs")
    (version "0.6.0")
    (source
     (origin
       (method url-fetch/tarbomb)
       (uri (string-append
             "https://dist.ipfs.io/go-ipfs/v" version
             "/go-ipfs-source.tar.gz"))
       (sha256
        (base32 "14bgq2j2bjjy0pspy2lsj5dm3w9rmfha0l8kyq5ig86yhc4nzn80"))
       (file-name (string-append name "-" version "-source"))))
    (build-system go-build-system)
    (arguments
     '(#:unpack-path "github.com/ipfs/go-ipfs"
       #:import-path "github.com/ipfs/go-ipfs/cmd/ipfs"
       #:phases (modify-phases %standard-phases
                  (add-before 'reset-gzip-timestamps 'make-files-writable
                    (lambda* (#:key outputs #:allow-other-keys)
                      ;; Make sure .gz files are writable so that the
                      ;; 'reset-gzip-timestamps' phase can do its work.
                      (let ((out (assoc-ref outputs "out")))
                        (for-each make-file-writable
                                  (find-files out "\\.gz$"))
                        #t))))))
    (home-page "https://ipfs.io")
    (synopsis "Go implementation of IPFS, a peer-to-peer hypermedia protocol")
    (description "IPFS is a global, versioned, peer-to-peer file system.  It
combines good ideas from Git, BitTorrent, Kademlia, SFS, and the Web.  It is
like a single bittorrent swarm, exchanging git objects.  IPFS provides an
interface as simple as the HTTP web, but with permanence built in.  You can
also mount the world at @code{/ipfs}.")
    (license license:expat)))


code:
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2013 Cyril Roelandt <tipecaml@gmail.com>
;;; Copyright © 2014 Kevin Lemonnier <lemonnierk@ulrar.net>
;;; Copyright © 2015, 2017 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2015, 2016, 2017, 2018, 2019, 2020 Efraim Flashner <efraim@flashner.co.il>
;;; Copyright © 2016 Nikita <nikita@n0.is>
;;; Copyright © 2017 Marius Bakke <mbakke@fastmail.com>
;;; Copyright © 2017, 2018, 2019, 2020 Tobias Geerinckx-Rice <me@tobias.gr>
;;; Copyright © 2020 Oleg Pykhalov <go.wigust@gmail.com>
;;; Copyright © 2020 Vinicius Monego <monego@posteo.net>
;;; Copyright © 2020 Jakub Kądziołka <kuba@kadziolka.net>
;;; Copyright © 2020 Brett Gilio <brettg@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 irc)
  #:use-module ((guix licenses) #:prefix license:)
  #:use-module (guix download)
  #:use-module (guix git-download)
  #:use-module (guix packages)
  #:use-module (guix build-system cmake)
  #:use-module (guix build-system glib-or-gtk)
  #:use-module (guix build-system gnu)
  #:use-module (guix build-system python)
  #:use-module (guix build-system qt)
  #:use-module (gnu packages)
  #:use-module (gnu packages admin)
  #:use-module (gnu packages aspell)
  #:use-module (gnu packages autogen)
  #:use-module (gnu packages autotools)
  #:use-module (gnu packages base)
  #:use-module (gnu packages backup)
  #:use-module (gnu packages check)
  #:use-module (gnu packages compression)
  #:use-module (gnu packages curl)
  #:use-module (gnu packages cyrus-sasl)
  #:use-module (gnu packages databases)
  #:use-module (gnu packages file)
  #:use-module (gnu packages gettext)
  #:use-module (gnu packages geo)
  #:use-module (gnu packages glib)
  #:use-module (gnu packages gnome)
  #:use-module (gnu packages gnupg)
  #:use-module (gnu packages gtk)
  #:use-module (gnu packages guile)
  #:use-module (gnu packages lua)
  #:use-module (gnu packages lxqt)
  #:use-module (gnu packages ncurses)
  #:use-module (gnu packages openldap)
  #:use-module (gnu packages kde)
  #:use-module (gnu packages kde-frameworks)
  #: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 python-crypto)
  #:use-module (gnu packages python-xyz)
  #:use-module (gnu packages regex)
  #:use-module (gnu packages ruby)
  #:use-module (gnu packages sqlite)
  #:use-module (gnu packages qt)
  #:use-module (gnu packages tcl)
  #:use-module (gnu packages textutils)
  #:use-module (gnu packages time)
  #:use-module (gnu packages tls)
  #:use-module (gnu packages web)
  #:use-module (srfi srfi-1)
  #:use-module (srfi srfi-26))

(define-public quassel
  (package
    (name "quassel")
    (version "0.13.1")
    (source
      (origin
        (method url-fetch)
        (uri (string-append "https://quassel-irc.org/pub/quassel-"
                            version ".tar.bz2"))
        (sha256
         (base32
          "0mg8jydc70vlylppzich26q4s40kr78r3ysfyjwisfvlg2byxvs8"))
        (patches (search-patches "quassel-qt-514-compat.patch"))
        (modules '((guix build utils)))
        ;; We don't want to install the bundled inxi script.
        (snippet
         '(begin
            (delete-file "data/scripts/inxi")
            #t))))
    (build-system qt-build-system)
    (arguments
      ;; The three binaries are not mutually exlusive, and are all built
      ;; by default.
     '(#:configure-flags '(;;"-DWANT_QTCLIENT=OFF" ; 6.1 MiB
                           ;;"-DWANT_CORE=OFF" ; 3.0 MiB
                           ;;"-DWANT_MONO=OFF" ; 7.6 MiB
                           "-DWITH_KDE=OFF" ; no to kde integration ...
                           "-DWITH_BUNDLED_ICONS=ON" ; so we install bundled icons
                           "-DWITH_OXYGEN_ICONS=ON" ; also the oxygen ones
                           "-DWITH_WEBENGINE=OFF") ; we don't depend on qtwebengine
       #:phases
       (modify-phases %standard-phases
         (add-after 'unpack 'patch-inxi-reference
           (lambda* (#:key inputs #:allow-other-keys)
             (let ((inxi (string-append (assoc-ref inputs "inxi") "/bin/inxi")))
               (symlink inxi "data/scripts/inxi")
               #t))))
       #:tests? #f)) ; no test target
    (native-inputs
     `(("extra-cmake-modules" ,extra-cmake-modules)
       ("pkg-config" ,pkg-config)
       ("qttools" ,qttools)))
    (inputs
     `(("inxi" ,inxi-minimal)
       ("libdbusmenu-qt" ,libdbusmenu-qt)
       ("qca" ,qca)
       ("qtbase" ,qtbase)
       ("qtmultimedia" ,qtmultimedia)
       ("qtscript" ,qtscript)
       ("qtsvg" ,qtsvg)
       ("snorenotify" ,snorenotify)
       ("zlib" ,zlib)))
    (home-page "https://quassel-irc.org/")
    (synopsis "Distributed IRC client")
    (description "Quassel is a distributed IRC client, meaning that one or more
clients can attach to and detach from the central core.  It resembles the
popular combination of screen and a text-based IRC client such as WeeChat or
irssi, but graphical.")
    (license (list license:gpl2 license:gpl3)))) ;; dual licensed

(define-public irssi
  (package
    (name "irssi")
    (version "1.2.2")
    (source (origin
              (method url-fetch)
              (uri (string-append "https://github.com/irssi/irssi/"
                                  "releases/download/" version "/irssi-"
                                  version ".tar.xz"))
              (sha256
               (base32
                "0y3mhnyr7x8ir8dlj83vbnchpfld28vdfni9yhpvls45j460c9v7"))))
    (build-system gnu-build-system)
    (arguments
     `(#:phases
       (modify-phases %standard-phases
         (replace 'configure
           (lambda* (#:key inputs outputs #:allow-other-keys)
             (let ((out (assoc-ref outputs "out")))
               (setenv "CONFIG_SHELL" (which "bash"))
               (invoke "./configure"
                       (string-append "--prefix=" out)
                       (string-append "--with-proxy")
                       (string-append "--with-socks")
                       (string-append "--with-bot")))))
         (add-before 'check 'set-home
           (lambda _
             (setenv "HOME" (getcwd)))))))
    (inputs
     `(("glib" ,glib)
       ("ncurses" ,ncurses)
       ("openssl" ,openssl)
       ("perl" ,perl)))
    (native-inputs
     `(("pkg-config" ,pkg-config)))
    (home-page "https://irssi.org/")
    (synopsis "Terminal-based IRC client")
    (description
     "Irssi is a terminal based IRC client for UNIX systems.  It also supports
SILC and ICB protocols via plugins.")
    (license license:gpl2+)))

(define-public weechat
  (package
    (name "weechat")
    (version "2.9")
    (source (origin
              (method url-fetch)
              (uri (string-append "https://weechat.org/files/src/weechat-"
                                  version ".tar.xz"))
              (sha256
               (base32
                "03psmp4hxsb9sz35i4cyz6dcbs3ab73amhyx0w0hv8f3hp1hdd7a"))))
    (build-system cmake-build-system)
    (native-inputs
     `(("gettext" ,gettext-minimal)
       ("pkg-config" ,pkg-config)
       ;; For tests.
       ("cpputest" ,cpputest)))
    (inputs
     `(("aspell" ,aspell)
       ("curl" ,curl)
       ("gnutls" ,gnutls)
       ("libgcrypt" ,libgcrypt "out")
       ("ncurses" ,ncurses)
       ("zlib" ,zlib)

       ;; Scripting language plug-ins.
       ("guile" ,guile-3.0)
       ("lua" ,lua-5.1)
       ("perl" ,perl)
       ("python" ,python)
       ("tcl" ,tcl)))
    (arguments
     `(#:configure-flags
       (list "-DENABLE_PHP=OFF"
             "-DENABLE_RUBY=OFF"
             "-DENABLE_TESTS=ON")       ; ‘make test’ fails otherwise
       ;; Tests hang indefinitely on non-Intel platforms.
       #:tests? ,(if (any (cute string-prefix? <> (or (%current-target-system)
                                                      (%current-system)))
                          '("i686" "x86_64"))
                   '#t '#f)))
    (synopsis "Extensible chat client")
    (description "WeeChat (Wee Enhanced Environment for Chat) is an
@dfn{Internet Relay Chat} (IRC) client, which is designed to be light and fast.
The client uses a curses frontend, and there are remote interfaces for Web,
Qt, Android, and Emacs.

Everything in WeeChat can be done with the keyboard, though it also supports
using a mouse.  It is customizable and extensible with plugins and scripts.")
    (home-page "https://www.weechat.org/")
    (license license:gpl3)))

(define-public srain
  (package
    (name "srain")
    (version "1.1.2")
    (source
     (origin
       (method git-fetch)
       (uri (git-reference
             (url "https://github.com/SrainApp/srain")
             (commit version)))
       (file-name (git-file-name name version))
       (sha256
        (base32 "1jjs3lrlz67z9ghpc4c406a5r3naisn1famdh9rwwcg4y4y1vcws"))))
    (arguments
     `(#:tests? #f ;there are no tests
       #:phases
       (modify-phases %standard-phases
         (add-before 'install 'fix-permissions
           ;; Make po folder writable for gettext to install translations.
           (lambda _
             (for-each make-file-writable
                       (find-files "po" "." #:directories? #t)))))))
    (build-system glib-or-gtk-build-system)
    (native-inputs
     `(("gettext" ,gettext-minimal)
       ("glib:bin" ,glib "bin")
       ("pkg-config" ,pkg-config)))
    (inputs
     `(("glib-networking" ,glib-networking)
       ("gsettings-desktop-schemas" ,gsettings-desktop-schemas)
       ("gtk+" ,gtk+)
       ("libconfig" ,libconfig)
       ("libsecret" ,libsecret)
       ("libsoup" ,libsoup)
       ("openssl" ,openssl)))
    (home-page "https://srain.im")
    (synopsis "Modern IRC client written in GTK")
    (description
     "Srain is an IRC client written in GTK.  It aims to be modern and easy to
use while still remaining useful to power users.  It also has partial support
for the IRCv3 protocol.")
    (license license:gpl3+)))

(define-public ircii
  (package
    (name "ircii")
    (version "20151120")
    (source (origin
             (method url-fetch)
             (uri (string-append "https://ircii.warped.com/"
                                 name "-" version ".tar.gz"))
             (sha256
              (base32
               "178dc279f5j894qvp96dzz7c0jpryqlcqw5g0dc9yaxg9kgw1lqm"))))
    (build-system gnu-build-system)
    ;; TODO: We should package a small socks4/5 library/server to configure
    ;; ircii with socks client. `ghc-socks' pulls in lots of haskell, which
    ;; is too big.
    (arguments
     `(#:tests? #f
       #:configure-flags (list
                          "--enable-ipv6"
                          "--with-emacs-meta-keys"
                          (string-append "--with-openssl="
                                         (assoc-ref %build-inputs "openssl")))
       #:phases
       (modify-phases %standard-phases
         (add-after 'unpack 'patch-bsdinstall-absolute-path-bins
           (lambda* (#:key inputs #:allow-other-keys)
             (substitute* "bsdinstall"
               (("/bin/strip") "strip")
               (("/bin/cp") "cp")
               (("/bin/chmod") "chmod")
               (("/etc/chown") "chown")
               (("/bin/chgrp") "chgrp")
               (("/bin/mkdir") "mkdir")
               (("/bin/rm") "rm")
               (("/bin/mv") "mv")))))))
    (inputs
     `(("ncurses" ,ncurses)
       ("openssl" ,openssl)))
    (native-inputs
     `(("pkg-config" ,pkg-config)
       ("perl" ,perl)))
    (home-page "http://www.eterna.com.au/ircii/")
    (synopsis "Terminal-based IRC and ICB client")
    (description
     "ircII is a terminal based IRC and ICB client for UNIX systems.")
    (license license:bsd-3)))

(define-public ii
  (package
    (name "ii")
    (version "1.8")
    (source (origin
              (method url-fetch)
              (uri (string-append "http://dl.suckless.org/tools/"
                                  name "-" version ".tar.gz"))
              (sha256
               (base32
                "1lk8vjl7i8dcjh4jkg8h8bkapcbs465sy8g9c0chfqsywbmf3ndr"))))
    (build-system gnu-build-system)
    (arguments
     `(#:tests? #f                      ; no tests
       #:make-flags (list (string-append "PREFIX=" %output)
                          "CC=gcc")
       #:phases
       (modify-phases %standard-phases
         (delete 'configure))))         ; no configure
    (home-page "https://tools.suckless.org/ii/")
    (synopsis "FIFO and file system based IRC client")
    (description
     "ii (Irc it) is a minimalist FIFO and file system based IRC client.")
    (license license:expat)))

(define-public sic
  (package
    (name "sic")
    (version "1.2")
    (source (origin
              (method url-fetch)
              (uri (string-append "http://dl.suckless.org/tools/"
                                  name "-" version ".tar.gz"))
              (sha256
               (base32
                "11aiavxp44yayibc58bvimi8mrxvbw1plbci8cnbl4syk42zj1xc"))))
    (build-system gnu-build-system)
    (arguments
     `(#:tests? #f ; no tests
       #:make-flags (list "CC=gcc"
                          (string-append "PREFIX=" %output))
       #:phases
       (modify-phases %standard-phases
         (delete 'configure)))) ; no configure
    (home-page "https://tools.suckless.org/sic/")
    (synopsis "Simple IRC client")
    (description
     "sic is a simple IRC client, even more minimalistic than ii.")
    (license license:expat)))

(define-public limnoria
  (package
    (name "limnoria")
    (version "2019.11.22")
    (source
     (origin
       (method url-fetch)
       (uri (pypi-uri "limnoria" version))
       (sha256
        (base32 "0853xk1ps3v6lkmfx50wv56vynnzpl84v66hxnhl8i34zl36kk3c"))))
    (build-system python-build-system)
    (inputs
     `(("python-pytz" ,python-pytz)
       ("python-chardet" ,python-chardet)
       ("python-dateutil" ,python-dateutil)
       ("python-gnupg" ,python-gnupg)
       ("python-feedparser" ,python-feedparser)
       ("python-sqlalchemy" ,python-sqlalchemy)
       ("python-socksipy-branch" ,python-socksipy-branch)
       ("python-ecdsa" ,python-ecdsa)))
    (native-inputs
     `(("python-mock" ,python-mock)))
    ;; Despite the existence of a test folder there is no test phase.
    ;; We need to package https://github.com/ProgVal/irctest and write
    ;; our own testphase.
    (arguments
     `(#:tests? #f))
    (home-page "https://github.com/ProgVal/Limnoria")
    (synopsis "Modified version of Supybot (an IRC bot and framework)")
    (description
     "Modified version of Supybot with Python 3 and IRCv3 support,
embedded web server, translations (fr, fi, it, hu, de), and many
other enhancements and bug fixes.")
    (license license:bsd-3)))

(define-public epic5
  (package
    (name "epic5")
    (version "2.0.1")
    (source (origin
              (method url-fetch)
              (uri (string-append "http://ftp.epicsol.org/pub/"
                                  "epic/EPIC5-PRODUCTION/"
                                  name "-" version ".tar.xz"))
              (sha256
               (base32
                "1ap73d5f4vccxjaaq249zh981z85106vvqmxfm4plvy76b40y9jm"))))
    (build-system gnu-build-system)
    (arguments
     `(#:test-target "test"
       #:phases
       (modify-phases %standard-phases
         (add-after 'unpack 'patch-perl
           (lambda _
             (substitute* "regress/crash-irc"
               (("perl5") (which "perl")))
             #t))
         (add-after 'unpack 'patch-bsdinstall
           ;; If we just remove /bin/ some part of the bsdinstall breaks.
           ;; Furthermore bsdinstalls has a reference to /etc/chmod here, which
           ;; means if we leave /etc/ in, install fails.
           (lambda _
             (substitute* "bsdinstall"
               (("/bin/strip") "strip")
               (("/bin/cp") "cp")
               (("/bin/chmod") "chmod")
               (("/bin/chgrp") "chgrp")
               (("/bin/mkdir") "mkdir")
               (("/bin/rm") "rm")
               (("/bin/mv") "mv")
               (("/etc/") ""))
             #t))
         (replace 'configure
           (lambda* (#:key outputs #:allow-other-keys)
             ;; The tarball uses a very old version of autconf. It does not
             ;; understand extra flags like `--enable-fast-install', so
             ;; we need to invoke it with just what it understands.
             (let ((out (assoc-ref outputs "out")))
               ;; 'configure' doesn't understand '--host'.
               ,@(if (%current-target-system)
                     `((setenv "CHOST" ,(%current-target-system)))
                     '())
               (setenv "CONFIG_SHELL" (which "bash"))
               (setenv "SHELL" (which "bash"))
               (invoke "./configure"
                       (string-append "--prefix=" out)
                       "--with-ipv6" "--with-libarchive"
                       ;; We use libressl because openssl does not come
                       ;; with the lib/libssl.a which is needed for epic5.
                       ;; XXX: No matter which implementation is chosen,
                       ;; epic5 fails to connect to tls ports of roundrobin
                       ;; irc networks. This however is believed to be an
                       ;; protocol issue at epic5 related to ircd.
                       (string-append "--with-ssl="
                                      (assoc-ref %build-inputs "libressl"))
                       (string-append "--with-tcl="
                                      (assoc-ref %build-inputs "tcl")
                                      "/lib/tclConfig.sh"))))))))
    (inputs
     `(("libressl" ,libressl)
       ("ncurses" ,ncurses)
       ("libarchive" ,libarchive) ; CHANGELOG: "Support for loading zip files"
       ("perl" ,perl)
       ("tcl" ,tcl)
       ("ruby" ,ruby)))
    (native-inputs
     `(("pkg-config" ,pkg-config)))
    (home-page "http://epicsol.org")
    (synopsis "Epic5 IRC Client")
    (description
     "EPIC is a IRC client that has been under active development for
over 20 years.  It is stable and mature, and offers an excellent ircII
interface for those who are accustomed to the ircII way of doing things.")
    (license (list license:bsd-3
                   license:isc
                   license:bsd-4
                   ;; The epic license is equal to the standard three-clause
                   ;; BSD license except that you are not permitted to remove the
                   ;; "Redistribution is permitted" clause of the license if you
                   ;; distribute binaries.
                   (license:non-copyleft "http://epicsol.org/copyright")))))

(define-public inspircd
  (package
    (name "inspircd")
    (version "3.7.0")
    (source
     (origin
       (method git-fetch)
       (uri (git-reference
             (url "https://github.com/inspircd/inspircd")
             (commit (string-append "v" version))))
       (file-name (git-file-name name version))
       (sha256
        (base32
         "1npzp23c3ac7m1grkm39i1asj04rs4i0jwf5w0c0j0hmnwslnz7a"))))
    (build-system gnu-build-system)
    (arguments
     `(#:configure-flags (map (lambda (module)
                                (string-append "--enable-extras=" module))
                              '("m_geo_maxmind.cpp"
                                "m_ldap.cpp"
                                "m_mysql.cpp"
                                "m_pgsql.cpp"
                                "m_regex_pcre.cpp"
                                "m_regex_posix.cpp"
                                "m_regex_stdlib.cpp"
                                "m_regex_re2.cpp"
                                "m_regex_tre.cpp"
                                "m_sqlite3.cpp"
                                "m_ssl_gnutls.cpp"
                                "m_ssl_openssl.cpp"
                                "m_ssl_mbedtls.cpp"
                                "m_sslrehashsignal.cpp"))
       #:tests? #f ; Figure out later.
       #:phases
       (modify-phases %standard-phases
         (add-before 'configure 'module-configure
           (lambda* (#:key configure-flags #:allow-other-keys)
             (apply invoke "./configure"
                    configure-flags)
             #t))
         (replace 'configure
           (lambda* (#:key outputs #:allow-other-keys)
             (let* ((out (assoc-ref outputs "out"))
                    (out-lib (string-append out "/lib/"))
                    (out-bin (string-append out "/bin/"))
                    (out-etc (string-append out "/etc/"))
                    (name "inspircd"))
               (invoke "./configure"
                       (string-append "--prefix=" out-lib name)
                       (string-append "--binary-dir=" out-bin)
                       (string-append "--module-dir=" out-lib name "/modules/")
                       (string-append "--config-dir=" out-etc name)))
             #t)))))
    (native-inputs
     `(("gnutls" ,gnutls)
       ("libgcrypt" ,libgcrypt)
       ("libmaxminddb" ,libmaxminddb)
       ("mysql" ,mysql)
       ("mbedtls-apache" ,mbedtls-apache)
       ("openldap" ,openldap)
       ("openssl" ,openssl)
       ("pcre" ,pcre "bin")
       ("perl" ,perl)
       ("pkg-config" ,pkg-config)
       ("postgresql" ,postgresql)
       ("re2" ,re2)
       ("sqlite" ,sqlite)
       ("tre" ,tre)))
    (synopsis "Modular IRC server written in C++")
    (description "InspIRCd is a modular Internet Relay Chat
server written in C++ for Unix-like operating systems.")
    (home-page "https://www.inspircd.org/")
    (license license:gpl2)))


code:
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2013 Cyril Roelandt <tipecaml@gmail.com>
;;; Copyright © 2016, 2019 Efraim Flashner <efraim@flashner.co.il>
;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
;;;
;;; 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 iso-codes)
  #:use-module ((guix licenses) #:prefix license:)
  #:use-module (guix packages)
  #:use-module (guix download)
  #:use-module (guix build-system gnu)
  #:use-module (guix build-system python)
  #:use-module (gnu packages gettext)
  #:use-module (gnu packages perl)
  #:use-module (gnu packages python))

(define-public iso-codes
  (package
    (name "iso-codes")
    (version "3.77")
    (source (origin
             (method url-fetch)
             (uri (string-append
                   "https://pkg-isocodes.alioth.debian.org/downloads/iso-codes-"
                   version ".tar.xz"))
             (sha256
              (base32
               "140dgygv22a49xb8x1941xr5ff12cphd9zzwxds98pgrqsj77k91"))))
    (build-system gnu-build-system)
    (inputs
     `(("gettext" ,gettext-minimal)
       ("perl" ,perl)
       ("python" ,python-wrapper)))
    (home-page "https://salsa.debian.org/iso-codes-team/iso-codes")
    (synopsis "Various ISO standards")
    (description
     "This package provides lists of various ISO standards (e.g. country,
language, language scripts, and currency names) in one place, rather
than repeated in many programs throughout the system.

Currently there are lists of languages and countries embedded in
several different programs, which leads to dozens of lists of
200 languages, translated into more than 30 languages... not
very efficient.

With this package, we create a single \"gettext domain\" for every
supported ISO standard which contains the translations of
that domain.  It is easy for a programmer to re-use those
translations instead of maintaining their own translation
infrastructure.  Moreover, the programmer does not need to follow
changes in the ISO standard and will not work with outdated
information.")
    (license license:gpl2+)))           ; some bits use the lgpl2

(define-public python-iso639
  (package
    (name "python-iso639")
    (version "0.4.5")
    (source
     (origin
       (method url-fetch)
       (uri (pypi-uri "iso-639" version))
       (sha256
        (base32
         "0jffmh4m20q8j27xb2fqbnlghjj0cx8pgsbzqisdg65qh2wd976w"))))
    (build-system python-build-system)
    (home-page "https://github.com/noumar/iso639")
    (synopsis "Python library for ISO 639 standard")
    (description "This package provides a Python library for ISO 639 standard
that is concerned with representation of names for languages and language
groups.")
    (license license:agpl3+)))

(define-public python2-iso639
  (package-with-python2 python-iso639))

(define-public python-iso3166
  (package
    (name "python-iso3166")
    (version "0.9")
    (source
     (origin
       (method url-fetch)
       (uri (pypi-uri "iso3166" version))
       (sha256
        (base32
         "0hm0xm30sprk1jssmn4cqks0x3nx5fp8r5ypvahcysmmayzrsnjl"))))
    (build-system python-build-system)
    (home-page "https://github.com/deactivated/python-iso3166")
    (synopsis "Self-contained ISO 3166-1 country definitions")
    (description "This package provides the ISO 3166-1 country definitions.")
    (license license:expat)))

(define-public python2-iso3166
  (package-with-python2 python-iso3166))


code:
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2019 Pierre Neidhardt <mail@ambrevar.xyz>
;;; Copyright © 2020 Vincent Legoll <vincent.legoll@gmail.com>
;;; Copyright © 2019, 2020 Jan Wielkiewicz <tona_kosmicznego_smiecia@interia.pl>
;;; Copyright © 2020 Maxim Cournoyer <maxim.cournoyer@gmail.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 jami)
  #:use-module ((guix licenses) #:prefix license:)
  #:use-module (gnu packages aidc)
  #:use-module (gnu packages audio)
  #:use-module (gnu packages autotools)
  #:use-module (gnu packages backup)
  #:use-module (gnu packages base)
  #:use-module (gnu packages boost)
  #:use-module (gnu packages check)
  #:use-module (gnu packages compression)
  #:use-module (gnu packages crypto)
  #:use-module (gnu packages documentation)
  #:use-module (gnu packages gettext)
  #:use-module (gnu packages glib)
  #:use-module (gnu packages gnome)
  #:use-module (gnu packages gtk)
  #:use-module (gnu packages libcanberra)
  #:use-module (gnu packages linux)
  #:use-module (gnu packages multiprecision)
  #:use-module (gnu packages networking)
  #:use-module (gnu packages pcre)
  #:use-module (gnu packages perl)
  #:use-module (gnu packages pkg-config)
  #:use-module (gnu packages pulseaudio)
  #:use-module (gnu packages python)
  #:use-module (gnu packages qt)
  #:use-module (gnu packages serialization)
  #:use-module (gnu packages sqlite)
  #:use-module (gnu packages telephony)
  #:use-module (gnu packages tls)
  #:use-module (gnu packages upnp)
  #:use-module (gnu packages video)
  #:use-module (gnu packages webkit)
  #:use-module (gnu packages xiph)
  #:use-module (gnu packages xorg)
  #:use-module (gnu packages)
  #:use-module (guix build-system cmake)
  #:use-module (guix build-system gnu)
  #:use-module (guix download)
  #:use-module (guix git-download)
  #:use-module (guix packages)
  #:use-module (guix utils)
  #:use-module (srfi srfi-1))

(define %jami-version "20200710.1.6bd18d2")

(define* (jami-source #:key keep-contrib-patches?)
  "Return an origin object of the tarball release sources archive of Jami.
When KEEP-CONTRIB-PATCHES? is #t, do not completely remove the contrib
subdirectory, which contains patches to be applied to some of the dependencies
of Jami."
  (origin
    (method url-fetch)
    (uri (string-append "https://dl.jami.net/release/tarballs/jami_"
                        %jami-version
                        ".tar.gz"))
    (modules '((guix build utils)))
    (snippet
     `(begin
        ;; Delete over 200 MiB of bundled tarballs.  The contrib directory
        ;; contains the custom patches for pjproject and other libraries used
        ;; by Savoir-faire Linux.
        (if ,keep-contrib-patches?
            (delete-file-recursively "daemon/contrib/tarballs")
            (delete-file-recursively "daemon/contrib"))
        ;; Remove code from unused Jami clients.
        (for-each delete-file-recursively '("client-android"
                                            "client-macosx"
                                            "client-uwp"
                                            "client-windows"))
        #t))
    (sha256
     (base32
      "0lg61jv39x7kc9lq30by246xb6gcgp1rzj49ak7ff8nqpfzyfvva"))))

(define %sfl-patches (jami-source #:keep-contrib-patches? #t))

(define %jami-sources (jami-source))

;; Savoir-faire Linux modifies many libraries to add features
;; to Jami. This procedure makes applying patches to a given
;; package easy.
(define jami-apply-dependency-patches
  '(lambda* (#:key inputs dep-name patches)
     (let ((patches-directory "sfl-patches"))
       (mkdir-p patches-directory)
       (invoke "tar" "-xvf" (assoc-ref inputs "sfl-patches")
               "-C" patches-directory
               "--strip-components=5"
               (string-append "ring-project/daemon/contrib/src/"
                              dep-name))
       (for-each
        (lambda (file)
          (invoke "patch" "--force" "-p1" "-i"
                  (string-append patches-directory "/"
                                 file ".patch")))
        patches))))

(define-public pjproject-jami
  (package
    (inherit pjproject)
    (name "pjproject-jami")
    (native-inputs
     `(("sfl-patches" ,%sfl-patches)
       ,@(package-native-inputs pjproject)))
    (arguments
     (substitute-keyword-arguments (package-arguments pjproject)
       ((#:phases phases '%standard-phases)
        `(modify-phases ,phases
           (add-after 'make-source-files-writable 'apply-patches
             (lambda* (#:key inputs #:allow-other-keys)
               (,jami-apply-dependency-patches
                #:inputs inputs
                #:dep-name "pjproject"
                #:patches
                '("0001-rfc6544"
                  "0002-rfc2466"
                  "0003-add-tcp-keep-alive"
                  "0004-multiple_listeners"
                  "0005-fix_ebusy_turn"
                  "0006-ignore_ipv6_on_transport_check"
                  "0007-pj_ice_sess"
                  "0008-fix_ioqueue_ipv6_sendto"
                  "0009-add-config-site"
                  ;; Note: The base pjproject is already patched with
                  ;; "0010-fix-pkgconfig".
                  "0011-fix-tcp-death-detection"
                  "0012-fix-turn-shutdown-crash"))
               #t))))))))

;; The following variables are configure flags used by ffmpeg-jami.  They're
;; from the ring-project/daemon/contrib/src/ffmpeg/rules.mak file. We try to
;; keep it as close to the official Jami package as possible, to provide all
;; the codecs and extra features that are expected.
;;
;; See:
;; https://review.jami.net/plugins/gitiles/ring-daemon/+/refs/heads/master/contrib/src/ffmpeg/rules.mak

(define %ffmpeg-default-configure-flags
  '("--disable-everything"
    "--enable-zlib"
    "--enable-gpl"
    "--enable-swscale"
    "--enable-bsfs"
    "--disable-filters"
    "--disable-programs"
    "--disable-postproc"
    "--disable-protocols"
    "--enable-protocol=crypto"
    "--enable-protocol=file"
    "--enable-protocol=rtp"
    "--enable-protocol=srtp"
    "--enable-protocol=tcp"
    "--enable-protocol=udp"
    "--enable-protocol=unix"
    "--enable-protocol=pipe"

    ;; enable muxers/demuxers
    "--disable-demuxers"
    "--disable-muxers"
    "--enable-muxer=rtp"
    "--enable-muxer=g722"
    "--enable-muxer=h263"
    "--enable-muxer=h264"
    "--enable-muxer=hevc"
    "--enable-muxer=webm"
    "--enable-muxer=ogg"
    "--enable-muxer=pcm_s16be"
    "--enable-muxer=pcm_s16le"
    "--enable-demuxer=rtp"
    "--enable-demuxer=mjpeg"
    "--enable-demuxer=mjpeg_2000"
    "--enable-demuxer=mpegvideo"
    "--enable-demuxer=gif"
    "--enable-demuxer=image_jpeg_pipe"
    "--enable-demuxer=image_png_pipe"
    "--enable-demuxer=image_webp_pipe"
    "--enable-demuxer=matroska"
    "--enable-demuxer=m4v"
    "--enable-demuxer=mp3"
    "--enable-demuxer=ogg"
    "--enable-demuxer=flac"
    "--enable-demuxer=wav"
    "--enable-demuxer=ac3"
    "--enable-demuxer=g722"
    "--enable-demuxer=pcm_mulaw"
    "--enable-demuxer=pcm_alaw"
    "--enable-demuxer=pcm_s16be"
    "--enable-demuxer=pcm_s16le"
    "--enable-demuxer=h263"
    "--enable-demuxer=h264"
    "--enable-demuxer=hevc"

    ;; enable parsers
    "--enable-parser=h263"
    "--enable-parser=h264"
    "--enable-parser=hevc"
    "--enable-parser=mpeg4video"
    "--enable-parser=vp8"
    "--enable-parser=vp9"
    "--enable-parser=opus"

    ;; encoders/decoders
    "--enable-encoder=adpcm_g722"
    "--enable-decoder=adpcm_g722"
    "--enable-encoder=rawvideo"
    "--enable-decoder=rawvideo"
    "--enable-encoder=libx264"
    "--enable-decoder=h264"
    "--enable-encoder=pcm_alaw"
    "--enable-decoder=pcm_alaw"
    "--enable-encoder=pcm_mulaw"
    "--enable-decoder=pcm_mulaw"
    "--enable-encoder=mpeg4"
    "--enable-decoder=mpeg4"
    "--enable-encoder=libvpx_vp8"
    "--enable-decoder=vp8"
    "--enable-decoder=vp9"
    "--enable-encoder=h263"
    "--enable-encoder=h263p"
    "--enable-decoder=h263"
    "--enable-encoder=mjpeg"
    "--enable-decoder=mjpeg"
    "--enable-decoder=mjpegb"
    "--enable-libspeex"
    "--enable-libopus"
    "--enable-libvpx"
    "--enable-libx264"
    "--enable-encoder=libspeex"
    "--enable-decoder=libspeex"
    "--enable-encoder=libopus"
    "--enable-decoder=libopus"

    ;; decoders for ringtones and audio streaming
    "--enable-decoder=flac"
    "--enable-decoder=vorbis"
    "--enable-decoder=aac"
    "--enable-decoder=ac3"
    "--enable-decoder=eac3"
    "--enable-decoder=mp3"
    "--enable-decoder=pcm_u24be"
    "--enable-decoder=pcm_u24le"
    "--enable-decoder=pcm_u32be"
    "--enable-decoder=pcm_u32le"
    "--enable-decoder=pcm_u8"
    "--enable-decoder=pcm_f16le"
    "--enable-decoder=pcm_f24le"
    "--enable-decoder=pcm_f32be"
    "--enable-decoder=pcm_f32le"
    "--enable-decoder=pcm_f64be"
    "--enable-decoder=pcm_f64le"
    "--enable-decoder=pcm_s16be"
    "--enable-decoder=pcm_s16be_planar"
    "--enable-decoder=pcm_s16le"
    "--enable-decoder=pcm_s16le_planar"
    "--enable-decoder=pcm_s24be"
    "--enable-decoder=pcm_s24le"
    "--enable-decoder=pcm_s24le_planar"
    "--enable-decoder=pcm_s32be"
    "--enable-decoder=pcm_s32le"
    "--enable-decoder=pcm_s32le_planar"
    "--enable-decoder=pcm_s64be"
    "--enable-decoder=pcm_s64le"
    "--enable-decoder=pcm_s8"
    "--enable-decoder=pcm_s8_planar"
    "--enable-decoder=pcm_u16be"
    "--enable-decoder=pcm_u16le"

    ;; encoders/decoders for images
    "--enable-encoder=gif"
    "--enable-decoder=gif"
    "--enable-encoder=jpegls"
    "--enable-decoder=jpegls"
    "--enable-encoder=ljpeg"
    "--enable-decoder=jpeg2000"
    "--enable-encoder=png"
    "--enable-decoder=png"
    "--enable-encoder=bmp"
    "--enable-decoder=bmp"
    "--enable-encoder=tiff"
    "--enable-decoder=tiff"

    ;; filters
    "--enable-filter=scale"
    "--enable-filter=overlay"
    "--enable-filter=amix"
    "--enable-filter=amerge"
    "--enable-filter=aresample"
    "--enable-filter=format"
    "--enable-filter=aformat"
    "--enable-filter=fps"
    "--enable-filter=transpose"
    "--enable-filter=pad"))

(define %ffmpeg-linux-configure-flags
  '("--enable-pic"
    "--extra-cxxflags=-fPIC"
    "--extra-cflags=-fPIC"
    "--target-os=linux"
    "--enable-indev=v4l2"
    "--enable-indev=xcbgrab"
    "--enable-vdpau"
    "--enable-hwaccel=h264_vdpau"
    "--enable-hwaccel=mpeg4_vdpau"
    "--enable-vaapi"
    "--enable-hwaccel=h264_vaapi"
    "--enable-hwaccel=mpeg4_vaapi"
    "--enable-hwaccel=h263_vaapi"
    "--enable-hwaccel=vp8_vaapi"
    "--enable-hwaccel=mjpeg_vaapi"
    "--enable-hwaccel=hevc_vaapi"
    "--enable-encoder=h264_vaapi"
    "--enable-encoder=vp8_vaapi"
    "--enable-encoder=mjpeg_vaapi"
    "--enable-encoder=hevc_vaapi"))

;; ffnvcodec is not supported on ARM then we enable it here for i386 and
;; x86_64 architectures.
(define %ffmpeg-linux-x86-configure-flags
  '("--arch=x86"
    "--enable-cuvid"
    "--enable-ffnvcodec"
    "--enable-nvdec"
    "--enable-nvenc"
    "--enable-hwaccel=h264_nvdec"
    "--enable-hwaccel=hevc_nvdec"
    "--enable-hwaccel=vp8_nvdec"
    "--enable-hwaccel=mjpeg_nvdec"
    "--enable-encoder=h264_nvenc"
    "--enable-encoder=hevc_nvenc"))

;; This procedure composes the configure flags list for ffmpeg-jami.
(define (ffmpeg-compose-configure-flags)
  (define (system=? s)
    (string-prefix? s (%current-system)))

  `(,@%ffmpeg-default-configure-flags
    ,@(if (string-contains (%current-system) "linux")
          (if (or (system=? "i686")
                  (system=? "x86_64"))
              (append %ffmpeg-linux-configure-flags
                      %ffmpeg-linux-x86-configure-flags)
              %ffmpeg-linux-configure-flags)
          '())))

(define-public ffmpeg-jami
  (package
    (inherit ffmpeg)
    (name "ffmpeg-jami")
    (native-inputs
     `(("sfl-patches" ,%sfl-patches)
       ("libiconv" ,libiconv)
       ,@(package-native-inputs ffmpeg)))
    (supported-systems '("x86_64-linux" "i686-linux"
                         "aarch64-linux" "armhf-linux"))
    (arguments
     (append
      '(#:tests? #f)
      (substitute-keyword-arguments (package-arguments ffmpeg)
        ((#:configure-flags '())
         (ffmpeg-compose-configure-flags))
        ((#:phases phases)
         `(modify-phases ,phases
            (add-after 'unpack 'make-git-checkout-writable
              (lambda _
                (for-each make-file-writable (find-files "."))
                #t))
            (add-after 'unpack 'apply-patches
              (lambda* (#:key inputs #:allow-other-keys)
                (let ((jami-apply-dependency-patches
                       ,jami-apply-dependency-patches))
                  ;; These patches come from:
                  ;; "ring-project/daemon/contrib/src/ffmpeg/rules.mak".
                  (jami-apply-dependency-patches #:inputs inputs
                                                 #:dep-name "ffmpeg"
                                                 #:patches
                                                 '("remove-mjpeg-log"
                                                   "change-RTCP-ratio"
                                                   "rtp_ext_abs_send_time"))
                  #t))))))))))

(define-public libring
  (package
    (name "libring")
    (version %jami-version)
    (source %jami-sources)
    (build-system gnu-build-system)
    (inputs
     `(("alsa-lib" ,alsa-lib)
       ("boost" ,boost)
       ("dbus-c++" ,dbus-c++)
       ("eudev" ,eudev)
       ("ffmpeg" ,ffmpeg-jami)
       ("flac" ,flac)
       ("gmp" ,gmp)
       ("gsm" ,gsm)
       ("jack" ,jack-1)
       ("jsoncpp" ,jsoncpp)
       ("libarchive" ,libarchive)
       ("libnatpmp" ,libnatpmp)
       ("libogg" ,libogg)
       ("libva" ,libva)
       ("opendht" ,opendht)
       ("opus" ,opus)
       ("pcre" ,pcre)
       ("pulseaudio" ,pulseaudio)
       ("libsamplerate" ,libsamplerate)
       ("libsndfile" ,libsndfile)
       ("speex" ,speex)
       ("speexdsp" ,speexdsp)
       ("libupnp" ,libupnp)
       ("libvorbis" ,libvorbis)
       ("libx264" ,libx264)
       ("libvdpau" ,libvdpau)
       ("yaml-cpp" ,yaml-cpp)
       ("zlib" ,zlib)
       ("openssl" ,openssl)
       ("libsecp256k1" ,libsecp256k1)
       ("python" ,python)
       ("python-wrapper" ,python-wrapper)
       ("restinio" ,restinio)
       ("libx11" ,libx11)
       ("asio" ,asio)
       ;; TODO: Upstream seems to rely on a custom pjproject (a.k.a. pjsip) version.
       ;; See https://git.jami.net/savoirfairelinux/ring-daemon/issues/24.
       ("pjproject" ,pjproject-jami)))
    (native-inputs
     `(("autoconf" ,autoconf)
       ("automake" ,automake)
       ("libtool" ,libtool)
       ("pkg-config" ,pkg-config)
       ("which" ,which)
       ("cppunit" ,cppunit)
       ("perl" ,perl)))                 ; Needed for documentation.
    (arguments
     `(#:tests? #f         ; The tests fail to compile due to missing headers.
       #:phases
       (modify-phases %standard-phases
         (add-after 'unpack 'change-directory
           (lambda _
             (chdir "daemon")
             #t))
         (add-before 'build 'add-lib-dir
           (lambda _
             (mkdir-p "src/lib")
             #t)))))
    (synopsis "Distributed multimedia communications platform")
    (description "Jami (formerly GNU Ring) is a secure and distributed voice,
video and chat communication platform that requires no centralized server and
leaves the power of privacy in the hands of the user.  It supports the SIP and
IAX protocols, as well as decentralized calling using P2P-DHT.

This package provides a library and daemon implementing the Jami core
functionality.")
    (home-page "https://jami.net/")
    (license license:gpl3+)))

(define-public libringclient
  (package
    (inherit libring)
    (name "libringclient")
    (build-system cmake-build-system)
    (propagated-inputs
     `(("libring" ,libring)     ; For 'dring'.
       ("qtbase" ,qtbase)       ; Qt is included in several installed headers.
       ("qttools" ,qttools)))
    (arguments
     `(#:tests? #f                      ; There is no testsuite.
       #:configure-flags
       (list (string-append "-DRING_BUILD_DIR="
                            (assoc-ref %build-inputs "libring") "/include"))
       #:phases
       (modify-phases %standard-phases
         (add-after 'unpack 'change-directory
           (lambda _
             (chdir "lrc")
             #t))
         (add-before 'configure 'fix-dbus-interfaces-path
           (lambda* (#:key inputs #:allow-other-keys)
             (substitute* "CMakeLists.txt"
               (("\\$\\{CMAKE_INSTALL_PREFIX\\}(/share/dbus-1/interfaces)" _ dbus-interfaces-path-suffix)
                (string-append (assoc-ref inputs "libring")
                               dbus-interfaces-path-suffix))))))))
    (synopsis "Distributed multimedia communications platform")
    (description "Jami (formerly GNU Ring) is a secure and distributed voice,
video and chat communication platform that requires no centralized server and
leaves the power of privacy in the hands of the user.  It supports the SIP and
IAX protocols, as well as decentralized calling using P2P-DHT.

This package provides a library common to all Jami clients.")
    (home-page "https://jami.net")
    (license license:gpl3+)))

(define-public jami
  (package
    (inherit libring)
    (name "jami")
    (build-system cmake-build-system)
    (inputs
     `(("libringclient" ,libringclient)
       ("gtk+" ,gtk+)
       ("qrencode" ,qrencode)
       ("libnotify" ,libnotify)
       ("clutter" ,clutter)
       ("clutter-gtk" ,clutter-gtk)
       ("libcanberra" ,libcanberra)
       ("webkitgtk" ,webkitgtk)
       ("sqlite" ,sqlite)))
    (native-inputs
     `(("pkg-config" ,pkg-config)
       ("gettext" ,gettext-minimal)
       ("glib:bin" ,glib "bin")
       ("doxygen" ,doxygen)))
    (propagated-inputs
     `(("libring" ,libring) ; Contains `dring', the daemon, which is automatically by d-bus.
       ("adwaita-icon-theme" ,adwaita-icon-theme)
       ("evolution-data-server" ,evolution-data-server)))
    (arguments
     `(#:tests? #f                      ; There is no testsuite.
       #:phases
       (modify-phases %standard-phases
         (add-after 'unpack 'change-directory
           (lambda _
             (chdir "client-gnome")
             #t)))))
    (synopsis "Distributed, privacy-respecting communication program")
    (description "Jami (formerly GNU Ring) is a secure and distributed voice,
video and chat communication platform that requires no centralized server and
leaves the power of privacy in the hands of the user.  It supports the SIP and
IAX protocols, as well as decentralized calling using P2P-DHT.

This package provides the Jami client for the GNOME desktop.")
    (home-page "https://jami.net")
    (license license:gpl3+)))