diff mbox series

[bug#54796,v4,19/22] gnu: Add rebar3.

Message ID 120da897838074daac150b733b46c2716f24da2c.1649616716.git.h.goebel@crazy-compilers.com
State Accepted
Headers show
Series Add importer for hex.pm and rebar3 build-system for Erlang | expand

Commit Message

Hartmut Goebel April 10, 2022, 6:57 p.m. UTC
* gnu/packages/erlang.scm (rebar3): New variable.
---
 gnu/packages/erlang.scm | 76 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 76 insertions(+)

Comments

Ludovic Courtès April 29, 2022, 1:16 p.m. UTC | #1
Hartmut Goebel <h.goebel@crazy-compilers.com> skribis:

> * gnu/packages/erlang.scm (rebar3): New variable.

[...]

> +    (inputs
> +     `(("bbmustache-source" ,(package-source erlang-bbmustache))
> +       ("certifi-source" ,(package-source erlang-certifi))
> +       ("cf-source" ,(package-source erlang-cf))
> +       ("cth_readable-source" ,(package-source erlang-cth-readable))
> +       ("erlware_commons-source" ,(package-source erlang-erlware-commons))
> +       ("eunit_formatters-source" ,(package-source erlang-eunit-formatters))
> +       ("getopt-source" ,(package-source erlang-getopt))
> +       ("hex_core-source" ,(package-source erlang-hex-core))
> +       ("parse_trans-source" ,(package-source erlang-parse-trans))
> +       ("relx-source" ,(package-source erlang-relx))
> +       ("ssl_verify_fun-source" ,(package-source erlang-ssl-verify-fun))
> +       ("providers-source" ,(package-source erlang-providers))))

Not a blocker, but I’d rather see this eventually changed to use a gexp,
like so:

  #:arguments #~(modify-phases …
                  (add-before …
                    (lambda …
                      (for-each (lambda (source) …)
                                '(#$@(map package-source
                                          (list erlang-bbmustache …)))))))

Ludo’.
Hartmut Goebel May 6, 2022, 2:58 p.m. UTC | #2
Am 29.04.22 um 15:16 schrieb Ludovic Courtès:
> Not a blocker, but I’d rather see this eventually changed to use a gexp,
> like so:

Writing some decent code for with is beyond my scheme knowledge. I leave 
this as an excersice for guile experts.
Ludovic Courtès May 9, 2022, 8:25 a.m. UTC | #3
Hi,

Hartmut Goebel <h.goebel@crazy-compilers.com> skribis:

> Am 29.04.22 um 15:16 schrieb Ludovic Courtès:
>> Not a blocker, but I’d rather see this eventually changed to use a gexp,
>> like so:
>
> Writing some decent code for with is beyond my scheme knowledge. I
> leave this as an excersice for guile experts.

To be fair, there’s not much expertise to be had beyond mimicking the
example I gave you in the parent message; it’s close to working code!

Thanks,
Ludo’.
Hartmut Goebel May 9, 2022, 10:15 a.m. UTC | #4
Am 09.05.22 um 10:25 schrieb Ludovic Courtès:
> To be fair, there’s not much expertise to be had beyond mimicking the
> example I gave you in the parent message; it’s close to working code!

This is what I thought. But beside the package, there is also required 
the original package's name (no prefix, underscores instead of dashes). 
And the code I was able to write was ugly.
diff mbox series

Patch

diff --git a/gnu/packages/erlang.scm b/gnu/packages/erlang.scm
index 18ea933333..e8f43e7de2 100644
--- a/gnu/packages/erlang.scm
+++ b/gnu/packages/erlang.scm
@@ -554,3 +554,79 @@  a well configured release directory.")
     (description "This package provides SSL verification functions for
 Erlang.")
     (license license:expat)))
+
+(define-public rebar3
+  (package
+    (name "rebar3")
+    (version "3.18.0")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/erlang/rebar3")
+             (commit version)))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32 "09648hzc2mnjwf9klm20cg4hb5rn2xv2gmzcg98ffv37p5yfl327"))))
+    (build-system gnu-build-system)
+    ;; TODO: remove vendored modules, install man-page, install lib(?)
+    (arguments
+     `(#:phases
+       (modify-phases %standard-phases
+         (delete 'bootstrap)
+         (add-after 'unpack 'unpack-dependency-sources
+           (lambda* (#:key inputs #:allow-other-keys)
+             (for-each
+              (lambda (pkgname)
+                (let* ((src (string-append pkgname "-source"))
+                       (input (assoc-ref inputs src))
+                       (checkouts-dir (string-append "_checkouts/" pkgname))
+                       (lib-dir (string-append "_build/default/lib/" pkgname)))
+                  (mkdir-p checkouts-dir)
+                  (invoke "tar" "-xf" input "-C" checkouts-dir)
+                  (invoke "tar" "-xzf"
+                          (pk (string-append checkouts-dir "/contents.tar.gz"))
+                          "-C" checkouts-dir)
+                  (mkdir-p lib-dir)
+                  (copy-recursively checkouts-dir lib-dir)))
+              (list "bbmustache" "certifi" "cf" "cth_readable"
+                    "eunit_formatters" "getopt" "hex_core" "erlware_commons"
+                    "parse_trans" "relx" "ssl_verify_fun" "providers"))))
+         (delete 'configure)
+         (replace 'build
+           (lambda _
+             (setenv "HOME" (getcwd))
+             (invoke "./bootstrap")))
+         (replace 'install
+           (lambda* (#:key outputs #:allow-other-keys)
+             (let* ((out (assoc-ref outputs "out")))
+               (install-file "rebar3" (string-append out "/bin")))))
+         (delete 'check))))
+    (native-inputs
+     (list erlang))
+    (inputs
+     `(("bbmustache-source" ,(package-source erlang-bbmustache))
+       ("certifi-source" ,(package-source erlang-certifi))
+       ("cf-source" ,(package-source erlang-cf))
+       ("cth_readable-source" ,(package-source erlang-cth-readable))
+       ("erlware_commons-source" ,(package-source erlang-erlware-commons))
+       ("eunit_formatters-source" ,(package-source erlang-eunit-formatters))
+       ("getopt-source" ,(package-source erlang-getopt))
+       ("hex_core-source" ,(package-source erlang-hex-core))
+       ("parse_trans-source" ,(package-source erlang-parse-trans))
+       ("relx-source" ,(package-source erlang-relx))
+       ("ssl_verify_fun-source" ,(package-source erlang-ssl-verify-fun))
+       ("providers-source" ,(package-source erlang-providers))))
+    (home-page "https://www.rebar3.org/")
+    (synopsis "Sophisticated build-tool for Erlang projects that follows OTP
+principles")
+    (description "@code{rebar3} is an Erlang build tool that makes it easy to
+compile and test Erlang applications, port drivers and releases.
+
+@code{rebar3} is a self-contained Erlang script, so it's easy to distribute or
+even embed directly in a project.  Where possible, rebar uses standard
+Erlang/OTP conventions for project structures, thus minimizing the amount of
+build configuration work.  @code{rebar3} also provides dependency management,
+enabling application writers to easily re-use common libraries from a variety
+of locations (git, hg, etc).")
+    (license license:asl2.0)))