1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2016 Steve Sprang <scs@stevesprang.com>
3 ;;; Copyright © 2016, 2017 Leo Famulari <leo@famulari.name>
4 ;;; Copyright © 2016, 2017 Pjotr Prins <pjotr.guix@thebird.nl>
5 ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
6 ;;; Copyright © 2018 Nikita <nikita@n0.is>
7 ;;; Copyright © 2020-2022 Hartmut Goebel <h.goebel@crazy-compilers.com>
8 ;;; Copyright © 2021 Oskar Köök <oskar@maatriks.ee>
9 ;;; Copyright © 2021 Cees de Groot <cg@evrl.com>
11 ;;; This file is part of GNU Guix.
13 ;;; GNU Guix is free software; you can redistribute it and/or modify it
14 ;;; under the terms of the GNU General Public License as published by
15 ;;; the Free Software Foundation; either version 3 of the License, or (at
16 ;;; your option) any later version.
18 ;;; GNU Guix is distributed in the hope that it will be useful, but
19 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
20 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ;;; GNU General Public License for more details.
23 ;;; You should have received a copy of the GNU General Public License
24 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
26 (define-module (gnu packages erlang)
27 #:use-module ((guix licenses) #:prefix license:)
28 #:use-module (guix build-system gnu)
29 #:use-module (guix build-system emacs)
30 #:use-module (guix build-system rebar)
31 #:use-module (guix download)
32 #:use-module (guix git-download)
33 #:use-module (guix packages)
34 #:use-module (guix utils)
35 #:use-module (gnu packages)
36 #:use-module (gnu packages fontutils)
37 #:use-module (gnu packages gl)
38 #:use-module (gnu packages ncurses)
39 #:use-module (gnu packages perl)
40 #:use-module (gnu packages version-control)
41 #:use-module (gnu packages tls)
42 #:use-module (gnu packages wxwidgets))
50 ;; The tarball from http://erlang.org/download contains many
51 ;; pre-compiled files, so we use this snapshot of the source
54 (url "https://github.com/erlang/otp")
55 (commit (string-append "OTP-" version))))
56 (file-name (git-file-name name version))
59 "0n39pd5d8mmyj03d8fdan0zb2pcc383pmqf0v7s356fgirdbsrcm"))
60 (patches (search-patches "erlang-man-path.patch"))))
61 (build-system gnu-build-system)
65 ;; Erlang's documentation is distributed in a separate tarball.
69 (uri (string-append "http://erlang.org/download/otp_doc_man_"
70 (version-major+minor version) ".tar.gz"))
73 "17ap4kawlbqmcl13c543gh54p1ng8ivxmbn6lbbij07k81ry5p1y"))))))
75 (list ncurses openssl wxwidgets))
77 (list fontconfig glu mesa))
79 `(#:test-target "release_tests"
81 (list "--disable-saved-compile-time"
82 "--enable-dynamic-ssl-lib"
83 "--enable-native-libs"
84 "--enable-shared-zlib"
85 "--enable-smp-support"
88 (string-append "--with-ssl=" (assoc-ref %build-inputs "openssl")))
89 #:modules ((srfi srfi-19) ; make-time, et cetera.
91 (guix build gnu-build-system))
93 (modify-phases %standard-phases
95 ;; The are several code fragments that embed timestamps into the
96 ;; output. Here, we alter those fragments to use the value of
97 ;; SOURCE_DATE_EPOCH instead.
98 (add-after 'unpack 'remove-timestamps
100 (let ((source-date-epoch
102 (make-time time-utc 0 (string->number
103 (getenv "SOURCE_DATE_EPOCH"))))))
104 (substitute* "lib/reltool/src/reltool_target.erl"
105 (("Date = date\\(\\),")
106 (string-append "Date = "
107 (date->string source-date-epoch
109 (substitute* "lib/reltool/src/reltool_target.erl"
110 (("Time = time\\(\\),")
111 (string-append "Time = "
112 (date->string source-date-epoch
114 (substitute* '("lib/reltool/src/reltool_target.erl"
115 "lib/sasl/src/systools_make.erl")
116 (("date\\(\\), time\\(\\),")
117 (date->string source-date-epoch
118 "{~Y,~m,~d}, {~H,~M,~S},")))
119 (substitute* "lib/dialyzer/test/small_SUITE_data/src/gs_make.erl"
120 (("tuple_to_list\\(date\\(\\)\\),tuple_to_list\\(time\\(\\)\\)")
123 "tuple_to_list({~Y,~m,~d}), tuple_to_list({~H,~M,~S})")))
124 (substitute* "lib/snmp/src/compile/snmpc_mib_to_hrl.erl"
125 (("\\{Y,Mo,D\\} = date\\(\\),")
126 (date->string source-date-epoch
127 "{Y,Mo,D} = {~Y,~m,~d},")))
128 (substitute* "lib/snmp/src/compile/snmpc_mib_to_hrl.erl"
129 (("\\{H,Mi,S\\} = time\\(\\),")
130 (date->string source-date-epoch
131 "{H,Mi,S} = {~H,~M,~S},"))))))
132 (add-after 'unpack 'patch-/bin/sh
133 (lambda* (#:key inputs #:allow-other-keys)
134 (let ((sh (search-input-file inputs "/bin/sh")))
135 (substitute* "erts/etc/unix/run_erl.c"
136 (("sh = \"/bin/sh\";")
137 (string-append "sh = \"" sh "\";")))
138 (substitute* "erts/emulator/sys/unix/sys_drivers.c"
139 (("SHELL \"/bin/sh\"")
140 (string-append "SHELL \"" sh "\"")))
141 (substitute* "erts/emulator/sys/unix/erl_child_setup.c"
142 (("SHELL \"/bin/sh\"")
143 (string-append "SHELL \"" sh "\"")))
144 (substitute* "lib/kernel/src/os.erl"
146 (add-after 'patch-source-shebangs 'patch-source-env
150 (find-files "." "\\.escript")
151 (find-files "lib/stdlib/test/escript_SUITE_data/")
152 '("erts/lib_src/utils/make_atomics_api"
153 "erts/preloaded/src/add_abstract_code"
154 "lib/diameter/bin/diameterc"
155 "lib/reltool/examples/display_args"
156 "lib/reltool/examples/mnesia_core_dump_viewer"
157 "lib/snmp/src/compile/snmpc.src"
158 "make/verify_runtime_dependencies"
159 "make/emd2exml.in"))))
160 (substitute* escripts
161 (("/usr/bin/env") (which "env"))))))
162 (add-before 'configure 'set-erl-top
164 (setenv "ERL_TOP" (getcwd))))
165 (add-after 'install 'patch-erl
166 ;; This only works after install.
167 (lambda* (#:key outputs #:allow-other-keys)
168 (let ((out (assoc-ref outputs "out")))
169 (substitute* (string-append out "/bin/erl")
170 (("sed") (which "sed"))))))
171 (add-after 'install 'install-doc
172 (lambda* (#:key inputs outputs #:allow-other-keys)
173 (let* ((out (assoc-ref outputs "out"))
174 (manpages (assoc-ref inputs "erlang-manpages"))
175 (share (string-append out "/share/")))
177 (with-directory-excursion share
178 (invoke "tar" "xvf" manpages))))))))
179 (home-page "https://www.erlang.org/")
180 (synopsis "The Erlang programming language")
182 "Erlang is a programming language used to build massively
183 scalable soft real-time systems with requirements on high
184 availability. Some of its uses are in telecoms, banking, e-commerce,
185 computer telephony and instant messaging. Erlang's runtime system has
186 built-in support for concurrency, distribution and fault tolerance.")
187 ;; Erlang is distributed under the Apache License 2.0, but some components
188 ;; have other licenses. See 'system/COPYRIGHT' in the source distribution.
189 (license (list license:asl2.0 license:bsd-2 license:bsd-3 license:expat
190 license:lgpl2.0+ license:tcl/tk license:zlib))))
192 (define-public emacs-erlang
194 (name "emacs-erlang")
195 (version (package-version erlang))
196 (source (package-source erlang))
197 (build-system emacs-build-system)
200 (modify-phases %standard-phases
201 (add-before 'expand-load-path 'change-working-directory
202 (lambda _ (chdir "lib/tools/emacs") #t)))))
203 (home-page "https://www.erlang.org/")
204 (synopsis "Erlang major mode for Emacs")
206 "This package provides an Emacs major mode for editing Erlang source
208 (license license:asl2.0)))
210 (define-public erlang-bbmustache
212 (name "erlang-bbmustache")
217 (uri (hexpm-uri "bbmustache" version))
219 (base32 "0fvvaxdpziygxl30j59g98qkh2n47xlb7w5dfpsm2bfcsnj372v8"))))
220 (build-system rebar-build-system)
222 (list erlang-getopt rebar3-git-vsn
223 erlang-edown)) ; for building the docs
225 `(#:tests? #f ;; requires mustache specification file
227 (modify-phases %standard-phases
228 (add-before 'build 'build-more
230 (invoke "rebar3" "as" "dev" "escriptize")))
231 (add-after 'install 'install-escript
232 (lambda* (#:key outputs #:allow-other-keys)
233 (let* ((out (assoc-ref outputs "out")))
234 (install-file "_build/dev/bin/bbmustache"
235 (string-append out "/bin"))))))))
236 (home-page "https://github.com/soranoba/bbmustache/")
237 (synopsis "Binary pattern match Based Mustache template engine for Erlang")
238 (description "This Erlang library provides a Binary pattern match Based
239 Mustache template engine")
240 (license license:expat)))
242 (define-public erlang-certifi
244 (name "erlang-certifi")
249 (uri (hexpm-uri "certifi" version))
251 (base32 "0ha6vmf5p3xlbf5w1msa89frhvfk535rnyfybz9wdmh6vdms8v96"))))
252 (build-system rebar-build-system)
254 `(#:tests? #f)) ;; have not been updated for latest cert bundle
255 (home-page "https://github.com/certifi/erlang-certifi/")
256 (synopsis "Erlang CA certificate bundle")
257 (description "This Erlang library contains a CA bundle that you can
258 reference in your Erlang application. This is useful for systems that do not
259 have CA bundles that Erlang can find itself, or where a uniform set of CAs is
262 This an Erlang specific port of certifi. The CA bundle is derived from
263 Mozilla's canonical set.")
264 (license license:bsd-3)))
266 (define-public erlang-cf
273 (uri (hexpm-uri "cf" version))
275 (base32 "0wknz4xkqkhgvlx4vx5619p8m65v7g87lfgsvfy04jrsgm28spii"))))
276 (build-system rebar-build-system)
277 (home-page "https://github.com/project-fifo/cf")
278 (synopsis "Terminal colour helper for Erlang io and io_lib")
279 (description "This package provides a helper library for termial colour
280 printing extending the io:format syntax to add colours.")
281 (license license:expat)))
283 (define-public erlang-covertool
285 (name "erlang-covertool")
290 (uri (hexpm-uri "covertool" version))
292 (base32 "1p0c1n3nl4063xwi1sv176l1x68xqf07qwvj444a5z888fx6i5aw"))))
293 (build-system rebar-build-system)
294 (home-page "https://github.com/covertool/covertool")
295 (synopsis "Convert code-coverage data generated by @code{cover} into
296 Cobertura XML reports")
297 (description "This package provides a build tool and plugin to convert
298 exported Erlang @code{cover} data sets into Cobertura XML reports, which can
299 then be feed to the Jenkins Cobertura plug-in.
301 On @emph{hex.pm}, this plugin was previously called @code{rebar_covertool}.")
302 (license license:bsd-2)))
304 (define-public erlang-cth-readable
306 (name "erlang-cth-readable")
311 (uri (hexpm-uri "cth_readable" version))
313 (base32 "104xgybb6iciy6i28pyyrarqzliddi8kjyq43ajaav7y5si42rb8"))))
314 (build-system rebar-build-system)
318 `(#:tests? #f)) ;; no test-suite in hex-pm package
319 (home-page "https://github.com/ferd/cth_readable")
320 (synopsis "Common Test hooks for more readable logs for Erlang")
321 (description "This package provides an OTP library to be used for CT log
322 outputs you want to be readable around all that noise they contain.")
323 (license license:bsd-3)))
325 (define-public erlang-edown
327 (name "erlang-edown")
332 (uri (hexpm-uri "edown" version))
334 (base32 "0ij47gvgs6yfqphj0f54qjzj18crj8y1dsjjlzpp3dp8pscqzbqw"))))
335 (build-system rebar-build-system)
336 (home-page "https://github.com/uwiger/edown")
337 (synopsis "Markdown extension for EDoc")
338 (description "This package provides an extension for EDoc for generating
340 (license license:asl2.0)))
342 (define-public erlang-erlware-commons
344 (name "erlang-erlware-commons")
349 (uri (hexpm-uri "erlware_commons" version))
351 (base32 "18qam9xdzi74wppb0cj4zc8161i0i8djr79z8662m6d276f2jz5m"))))
352 (build-system rebar-build-system)
356 (list git-minimal/fixed)) ;; Required for tests
359 (modify-phases %standard-phases
360 (add-before 'check 'check-setup
362 (setenv "TERM" "xterm")))))) ; enable color in logs
363 (home-page "http://erlware.github.io/erlware_commons/")
364 (synopsis "Additional standard library for Erlang")
365 (description "Erlware Commons is an Erlware project focused on all aspects
366 of reusable Erlang components.")
367 (license license:expat)))
369 (define-public erlang-eunit-formatters
371 (name "erlang-eunit-formatters")
376 (uri (hexpm-uri "eunit_formatters" version))
378 (base32 "1jb3hzb216r29x2h4pcjwfmx1k81431rgh5v0mp4x5146hhvmj6n"))))
379 (build-system rebar-build-system)
380 (home-page "https://github.com/seancribbs/eunit_formatters")
381 (synopsis "Better output for eunit suites")
382 (description "This package provides a better output for Erlang eunits.")
383 (license license:asl2.0)))
385 (define-public erlang-getopt
387 (name "erlang-getopt")
392 (uri (hexpm-uri "getopt" version))
394 (base32 "09pasi7ki1rivw9sl7xndj5qgjbdqvcscxk83yk85yr28gm9l0m0"))))
395 (build-system rebar-build-system)
396 (home-page "https://github.com/jcomellas/getopt")
397 (synopsis "Command-line options parser for Erlang")
398 (description "This package provides an Erlang module to parse command line
399 arguments using the GNU getopt syntax.")
400 (license license:bsd-3)))
402 (define-public erlang-hex-core
404 (name "erlang-hex-core")
409 (uri (hexpm-uri "hex_core" version))
411 (base32 "06p65hlm29ky03vs3fq3qz6px2ylwp8b0f2y75wdf5cm0kx2332b"))))
412 (build-system rebar-build-system)
415 (modify-phases %standard-phases
417 (lambda* (#:key tests? #:allow-other-keys)
419 (invoke "rebar3" "as" "test" "proper")))))))
421 (list erlang-proper rebar3-proper))
422 (home-page "https://github.com/hexpm/hex_core")
423 (synopsis "Reference implementation of Hex specifications")
424 (description "This package provides the reference implementation of Hex
426 (license license:asl2.0)))
428 (define-public erlang-jsone
430 (name "erlang-jsone")
435 (uri (hexpm-uri "jsone" version))
437 (base32 "1gaxiw76syjp3s9rygskm32y9799b917q752rw8bxj3bxq93g8x3"))))
438 (build-system rebar-build-system)
441 (modify-phases %standard-phases
442 (add-after 'unpack 'disable-covertool
443 ;; no need to generate a coverage report
445 (substitute* "rebar.config"
446 (("\\{project_plugins, \\[covertool\\]\\}\\." _) "")))))))
447 (home-page "https://github.com/sile/jsone/")
448 (synopsis "Erlang JSON Library")
449 (description "An Erlang library for encoding and decoding JSON data.")
450 (license license:expat)))
452 (define-public erlang-parse-trans
454 (name "erlang-parse-trans")
459 (uri (hexpm-uri "parse_trans" version))
461 (base32 "16p4c2xjrvz16kzpr9pmcvi6nxq6rwckqi9fp0ksibaxwxn402k2"))))
462 (build-system rebar-build-system)
464 (list erlang-getopt))
465 (home-page "https://github.com/uwiger/parse_trans")
466 (synopsis "Parse transform utilities for Erlang")
467 (description "This package captures some useful patterns in parse
468 transformation and code generation for Erlang.
470 For example generating standardized accessor functions for records or
471 evaluating an expression at compile-time and substitute the result as a
472 compile-time constant.")
473 (license license:asl2.0)))
475 (define-public erlang-proper
477 (name "erlang-proper")
482 (uri (hexpm-uri "proper" version))
484 (base32 "1fwcas4a9kz3w3z1jqdk9lw8822srfjk9lcpvbxkxlsv3115ha0q"))))
485 (build-system rebar-build-system)
488 (modify-phases %standard-phases
489 (add-after 'unpack 'disable-covertool
490 ;; no need to generate a coverage report
492 (substitute* "rebar.config"
493 (("\\{plugins, \\[covertool\\]\\}\\." _) "")))))))
494 (home-page "https://proper-testing.github.io/")
495 (synopsis "QuickCheck-inspired property-based testing tool for Erlang")
496 (description "PropEr is a tool for the automated, semi-random,
497 property-based testing of Erlang programs. It is fully integrated with
498 Erlang's type language, and can also be used for the model-based random
499 testing of stateful systems.")
500 (license license:gpl3+)))
502 (define-public erlang-providers
504 (name "erlang-providers")
509 (uri (hexpm-uri "providers" version))
511 (base32 "05y0kz3xgx77hzn1l05byaisvmk8bgds7c22hrh0a5ba81sfi1yj"))))
512 (build-system rebar-build-system)
514 (list erlang-erlware-commons erlang-getopt))
515 (home-page "https://github.com/tsloughter/providers")
516 (synopsis "Erlang providers library")
517 (description "This package provides an Erlang providers library.")
518 (license license:asl2.0)))
520 (define-public erlang-relx
527 (uri (hexpm-uri "relx" version))
529 (base32 "02gmfx1vxg9m3mq4njsqhs4972l4nb8m5p1pdcf64g09ccf17y1g"))))
530 (build-system rebar-build-system)
532 (list erlang-bbmustache))
533 (home-page "https://erlware.github.io/relx/")
534 (synopsis "Release assembler for Erlang/OTP Releases")
535 (description "Relx assembles releases for an Erlang/OTP release. Given a
536 release specification and a list of directories in which to search for OTP
537 applications it will generate a release output. That output depends heavily on
538 what plugins available and what options are defined, but usually it is simply
539 a well configured release directory.")
540 (license license:asl2.0)))
542 (define-public erlang-ssl-verify-fun
544 (name "erlang-ssl-verify-fun")
549 (uri (hexpm-uri "ssl_verify_fun" version))
551 (base32 "1026l1z1jh25z8bfrhaw0ryk5gprhrpnirq877zqhg253x3x5c5x"))))
552 (build-system rebar-build-system)
553 (home-page "https://github.com/deadtrickster/ssl_verify_fun.erl")
554 (synopsis "SSL verification functions for Erlang")
555 (description "This package provides SSL verification functions for
557 (license license:expat)))
559 (define-public rebar3
567 (url "https://github.com/erlang/rebar3")
569 (file-name (git-file-name name version))
571 (base32 "09648hzc2mnjwf9klm20cg4hb5rn2xv2gmzcg98ffv37p5yfl327"))))
572 (build-system gnu-build-system)
573 ;; TODO: remove vendored modules, install man-page, install lib(?)
576 (modify-phases %standard-phases
578 (add-after 'unpack 'unpack-dependency-sources
579 (lambda* (#:key inputs #:allow-other-keys)
582 (let* ((src (string-append pkgname "-source"))
583 (input (assoc-ref inputs src))
584 (checkouts-dir (string-append "_checkouts/" pkgname))
585 (lib-dir (string-append "_build/default/lib/" pkgname)))
586 (mkdir-p checkouts-dir)
587 (invoke "tar" "-xf" input "-C" checkouts-dir)
589 (pk (string-append checkouts-dir "/contents.tar.gz"))
592 (copy-recursively checkouts-dir lib-dir)))
593 (list "bbmustache" "certifi" "cf" "cth_readable"
594 "eunit_formatters" "getopt" "hex_core" "erlware_commons"
595 "parse_trans" "relx" "ssl_verify_fun" "providers"))))
599 (setenv "HOME" (getcwd))
600 (invoke "./bootstrap")))
602 (lambda* (#:key outputs #:allow-other-keys)
603 (let* ((out (assoc-ref outputs "out")))
604 (install-file "rebar3" (string-append out "/bin")))))
609 `(("bbmustache-source" ,(package-source erlang-bbmustache))
610 ("certifi-source" ,(package-source erlang-certifi))
611 ("cf-source" ,(package-source erlang-cf))
612 ("cth_readable-source" ,(package-source erlang-cth-readable))
613 ("erlware_commons-source" ,(package-source erlang-erlware-commons))
614 ("eunit_formatters-source" ,(package-source erlang-eunit-formatters))
615 ("getopt-source" ,(package-source erlang-getopt))
616 ("hex_core-source" ,(package-source erlang-hex-core))
617 ("parse_trans-source" ,(package-source erlang-parse-trans))
618 ("relx-source" ,(package-source erlang-relx))
619 ("ssl_verify_fun-source" ,(package-source erlang-ssl-verify-fun))
620 ("providers-source" ,(package-source erlang-providers))))
621 (home-page "https://rebar3.org/")
622 (synopsis "Sophisticated build-tool for Erlang projects that follows OTP
624 (description "@code{rebar3} is an Erlang build tool that makes it easy to
625 compile and test Erlang applications, port drivers and releases.
627 @code{rebar3} is a self-contained Erlang script, so it's easy to distribute or
628 even embed directly in a project. Where possible, rebar uses standard
629 Erlang/OTP conventions for project structures, thus minimizing the amount of
630 build configuration work. @code{rebar3} also provides dependency management,
631 enabling application writers to easily re-use common libraries from a variety
632 of locations (git, hg, etc).")
633 (license license:asl2.0)))
635 (define-public rebar3-raw-deps
637 (name "rebar3-raw-deps")
642 (uri (hexpm-uri "rebar3_raw_deps" version))
644 (base32 "1pzmm3m8gb2s9jn8fp6shzgfmy4mvh2vdci0z6nsm74ma3ffh1i3"))))
645 (build-system rebar-build-system)
646 (home-page "https://github.com/soranoba/rebar3_raw_deps")
647 (synopsis "Rebar3 plugin for supporting \"raw\" dependencies")
648 (description "This plugin provides support for handling non-OTP
649 applications as a dependent libraries.")
650 (license license:expat)))
652 (define-public rebar3-git-vsn
654 (name "rebar3-git-vsn")
659 (uri (hexpm-uri "rebar3_git_vsn" version))
661 (base32 "1dfz56034pa25axly9vqdzv3phkn8ll0qwrkws96pbgcprhky1hx"))))
662 (build-system rebar-build-system)
664 (list git-minimal/fixed))
666 `(;; Running the tests require binary artifact (tar-file containing
667 ;; samples git repos) TODO: remove these from the source
670 (modify-phases %standard-phases
671 (add-after 'unpack 'patch-path
672 (lambda* (#:key inputs #:allow-other-keys)
673 (let ((git (assoc-ref inputs "git-minimal")))
674 (substitute* "src/rebar3_git_vsn.erl"
675 (("rebar_utils:sh\\(\"git " _)
676 (string-append "rebar_utils:sh(\"" git "/bin/git ")))))))))
677 (home-page "https://github.com/soranoba/rebar3_git_vsn")
678 (synopsis "Rebar3 plugin for generating the version from git")
679 (description "This plugin adds support for generating the version from
681 (license license:expat)))
683 (define-public rebar3-proper
685 (name "rebar3-proper")
690 (uri (hexpm-uri "rebar3_proper" version))
692 (base32 "1f174fb6h2071wr7qbw9aqqvnglzsjlylmyi8215fhrmi38w94b6"))))
693 (build-system rebar-build-system)
694 (home-page "https://github.com/ferd/rebar3_proper")
695 (synopsis "Rebar3 PropEr plugin")
696 (description "This plugin allows running PropEr test suites from within
698 (license license:bsd-3)))