gnu: emacs-consult: Fix grammar.
[jackhill/guix/guix.git] / gnu / packages / erlang.scm
index a400e71..7b5dc70 100644 (file)
@@ -1,7 +1,10 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2016 Steve Sprang <scs@stevesprang.com>
-;;; Copyright © 2016 Leo Famulari <leo@famulari.name>
+;;; Copyright © 2016, 2017 Leo Famulari <leo@famulari.name>
 ;;; Copyright © 2016, 2017 Pjotr Prins <pjotr.guix@thebird.nl>
+;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
+;;; Copyright © 2018 Nikita <nikita@n0.is>
+;;; Copyright © 2021 Oskar Köök <oskar@maatriks.ee>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
 (define-module (gnu packages erlang)
   #:use-module ((guix licenses) #:prefix license:)
   #:use-module (guix build-system gnu)
+  #:use-module (guix build-system emacs)
   #:use-module (guix download)
+  #:use-module (guix git-download)
   #:use-module (guix packages)
+  #:use-module (guix utils)
   #:use-module (gnu packages)
   #:use-module (gnu packages autotools)
   #:use-module (gnu packages fontutils)
 (define-public erlang
   (package
     (name "erlang")
-    (version "20.0")
+    (version "23.2.1")
     (source (origin
-              (method url-fetch)
+              (method git-fetch)
               ;; The tarball from http://erlang.org/download contains many
               ;; pre-compiled files, so we use this snapshot of the source
               ;; repository.
-              (uri (string-append "https://github.com/erlang/otp/archive/OTP-"
-                                  version ".tar.gz"))
-              (file-name (string-append name "-" version ".tar.gz"))
+              (uri (git-reference
+                    (url "https://github.com/erlang/otp")
+                    (commit (string-append "OTP-" version))))
+              (file-name (git-file-name name version))
               (sha256
                (base32
-                "1azjjyb743i6vjq7rnh5qnslsqg0x60a9zrlhg9n3dpm13z1b22l"))
+                "1p3lw4bcm2dph3pf1h4i0d9pzrcfr83r0iadqanxkwbmm1bl11pm"))
               (patches (search-patches "erlang-man-path.patch"))))
     (build-system gnu-build-system)
     (native-inputs
         ,(origin
            (method url-fetch)
            (uri (string-append "http://erlang.org/download/otp_doc_man_"
-                               version ".tar.gz"))
+                               (version-major+minor version) ".tar.gz"))
            (sha256
             (base32
-             "1k25p37w1l1j20qd8rga4j4q7s7r0rbsi02x3xwzhw51jhm59wdp"))))))
+             "0rq0rw68f02vckgdiwmvx8bvyv00l81s27cq59i3h79j9prfal2n"))))))
     (inputs
      `(("ncurses" ,ncurses)
        ("openssl" ,openssl)
                   (guix build gnu-build-system))
        #:phases
        (modify-phases %standard-phases
+         (delete 'bootstrap)
          ;; The are several code fragments that embed timestamps into the
          ;; output. Here, we alter those fragments to use the value of
          ;; SOURCE_DATE_EPOCH instead.
          (add-after 'unpack 'remove-timestamps
            (lambda _
              (let ((source-date-epoch
-                     (time-utc->date
-                       (make-time time-utc 0 (string->number
-                                               (getenv "SOURCE_DATE_EPOCH"))))))
+                    (time-utc->date
+                     (make-time time-utc 0 (string->number
+                                            (getenv "SOURCE_DATE_EPOCH"))))))
                (substitute* "lib/reltool/src/reltool_target.erl"
                  (("Date = date\\(\\),")
                   (string-append "Date = "
                (substitute* "lib/dialyzer/test/small_SUITE_data/src/gs_make.erl"
                  (("tuple_to_list\\(date\\(\\)\\),tuple_to_list\\(time\\(\\)\\)")
                   (date->string
-                    source-date-epoch
-                    "tuple_to_list({~Y,~m,~d}), tuple_to_list({~H,~M,~S})")))
+                   source-date-epoch
+                   "tuple_to_list({~Y,~m,~d}), tuple_to_list({~H,~M,~S})")))
                (substitute* "lib/snmp/src/compile/snmpc_mib_to_hrl.erl"
                  (("\\{Y,Mo,D\\} = date\\(\\),")
                   (date->string source-date-epoch
                (substitute* "lib/snmp/src/compile/snmpc_mib_to_hrl.erl"
                  (("\\{H,Mi,S\\} = time\\(\\),")
                   (date->string source-date-epoch
-                                "{H,Mi,S} = {~H,~M,~S},"))))))
+                                "{H,Mi,S} = {~H,~M,~S},")))
+               #t)))
+         (add-after 'unpack 'patch-/bin/sh
+           (lambda _
+             (substitute* "erts/etc/unix/run_erl.c"
+               (("sh = \"/bin/sh\";")
+                (string-append "sh = \""
+                               (which "sh")
+                               "\";")))
+
+             (substitute* "erts/emulator/sys/unix/sys_drivers.c"
+               (("SHELL \"/bin/sh\"")
+                (string-append "SHELL \""
+                               (which "sh")
+                               "\"")))
+             (substitute* "erts/emulator/sys/unix/erl_child_setup.c"
+               (("SHELL \"/bin/sh\"")
+                (string-append "SHELL \""
+                               (which "sh")
+                               "\"")))
+
+             (substitute* "lib/kernel/src/os.erl"
+               (("/bin/sh") (which "sh")))
+
+             #t))
          (add-after 'patch-source-shebangs 'patch-source-env
            (lambda _
              (let ((escripts
                        "make/verify_runtime_dependencies"
                        "make/emd2exml.in"))))
                (substitute* escripts
-                 (("/usr/bin/env") (which "env"))))))
+                 (("/usr/bin/env") (which "env")))
+               #t)))
          (add-before 'configure 'set-erl-top
            (lambda _
-             (setenv "ERL_TOP" (getcwd))))
-         (add-before 'configure 'autoconf
-           (lambda _ (zero? (system* "./otp_build" "autoconf"))))
+             (setenv "ERL_TOP" (getcwd))
+             #t))
+         (add-after 'patch-source-env 'autoconf
+           (lambda _
+             (invoke "./otp_build" "autoconf")
+             #t))
+         (add-after 'autoconf 'patch-configure-script-shell
+           (lambda _
+             (substitute* "configure"
+               (("cmd_str=\"./configure")
+                (string-append "cmd_str=\""
+                               (which "sh")
+                               " ./configure")))
+             #t))
          (add-after 'install 'patch-erl
            ;; This only works after install.
-           (lambda _
-             (substitute* (string-append (assoc-ref %outputs "out") "/bin/erl")
-               (("sed") (which "sed")))))
+           (lambda* (#:key outputs #:allow-other-keys)
+             (let* ((out (assoc-ref outputs "out")))
+               (substitute* (string-append out "/bin/erl")
+                 (("sed") (which "sed")))
+               #t)))
          (add-after 'install 'install-doc
            (lambda* (#:key inputs outputs #:allow-other-keys)
              (let* ((out (assoc-ref outputs "out"))
                     (manpages (assoc-ref inputs "erlang-manpages"))
                     (share (string-append out "/share/")))
-             (mkdir-p share)
-             (mkdir-p (string-append share "/misc/erlang"))
-             (with-directory-excursion share
-               (and
-                 (zero? (system* "tar" "xvf" manpages))
+               (mkdir-p share)
+               (mkdir-p (string-append share "/misc/erlang"))
+               (with-directory-excursion share
+                 (invoke "tar" "xvf" manpages)
                  (rename-file "COPYRIGHT"
                               (string-append share "/misc/erlang/COPYRIGHT"))
                  ;; Delete superfluous file.
-                 (delete-file "PR.template")))))))))
-    (home-page "http://erlang.org/")
+                 (delete-file "PR.template"))
+               #t))))))
+    (home-page "https://www.erlang.org/")
     (synopsis "The Erlang programming language")
     (description
      "Erlang is a programming language used to build massively
@@ -176,3 +222,21 @@ built-in support for concurrency, distribution and fault tolerance.")
     ;; have other licenses. See 'system/COPYRIGHT' in the source distribution.
     (license (list license:asl2.0 license:bsd-2 license:bsd-3 license:expat
                    license:lgpl2.0+ license:tcl/tk license:zlib))))
+
+(define-public emacs-erlang
+  (package
+    (name "emacs-erlang")
+    (version (package-version erlang))
+    (source (package-source erlang))
+    (build-system emacs-build-system)
+    (arguments
+     `(#:phases
+       (modify-phases %standard-phases
+         (add-before 'add-source-to-load-path 'change-working-directory
+           (lambda _ (chdir "lib/tools/emacs") #t)))))
+    (home-page "https://www.erlang.org/")
+    (synopsis "Erlang major mode for Emacs")
+    (description
+     "This package provides an Emacs major mode for editing Erlang source
+files.")
+    (license license:asl2.0)))