unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
* [bug#73458] Fix mix-build-system bugs (73453 , 73454)
@ 2024-09-24 17:03 paul via Guix-patches via
  2024-09-25  8:24 ` [bug#73458] [PATCH 1/2] build-system: mix: Allow loading Erlang dependencies in Mix driven builds Giacomo Leidi via Guix-patches via
  2024-09-25 21:39 ` [bug#73458] [PATCH v2 " Giacomo Leidi via Guix-patches via
  0 siblings, 2 replies; 8+ messages in thread
From: paul via Guix-patches via @ 2024-09-24 17:03 UTC (permalink / raw)
  To: 73458

Dear Guix,

I'm sending an updated patchset to fix a couple of bugs [0][1] with the 
mix-build-system.

Thank you for your work,


giacomo


[0]: https://issues.guix.gnu.org/73453

[1]: https://issues.guix.gnu.org/73454





^ permalink raw reply	[flat|nested] 8+ messages in thread

* [bug#73458] [PATCH 1/2] build-system: mix: Allow loading Erlang dependencies in Mix driven builds.
  2024-09-24 17:03 [bug#73458] Fix mix-build-system bugs (73453 , 73454) paul via Guix-patches via
@ 2024-09-25  8:24 ` Giacomo Leidi via Guix-patches via
  2024-09-25  8:24   ` [bug#73458] [PATCH 2/2] build-system: mix: Fix decoding of package names with git versions Giacomo Leidi via Guix-patches via
  2024-09-25 18:42   ` [bug#73458] [PATCH 1/2] build-system: mix: Allow loading Erlang dependencies in Mix driven builds Liliana Marie Prikler
  2024-09-25 21:39 ` [bug#73458] [PATCH v2 " Giacomo Leidi via Guix-patches via
  1 sibling, 2 replies; 8+ messages in thread
From: Giacomo Leidi via Guix-patches via @ 2024-09-25  8:24 UTC (permalink / raw)
  To: 73458; +Cc: Giacomo Leidi

Fixes <https://issues.guix.gnu.org/73453>

* guix/build/mix-build-system.scm (elixir-relative-libdir): New
variable;
(elixir-libdir): call elixir-relative-libdir;
(set-erl-env): this new phase sets ERL_LIBS to allow Erlang's virtual
machine to load Erlang dependencies in Mix builds, in addition to Elixir
ones;
(%standard-phases): add set-erl-env phases.

Change-Id: Ic1ef5db20680bfd265fbac72bafb760d21135f68
---
 guix/build/mix-build-system.scm | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/guix/build/mix-build-system.scm b/guix/build/mix-build-system.scm
index 0b021da791..41f6061444 100644
--- a/guix/build/mix-build-system.scm
+++ b/guix/build/mix-build-system.scm
@@ -1,6 +1,7 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2023 Pierre-Henry Fröhring <contact@phfrohring.com>
 ;;; Copyright © 2024 Igor Goryachev <igor@goryachev.org>
+;;; Copyright © 2024 Giacomo Leidi <goodoldpaul@autistici.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -39,10 +40,15 @@ (define-module (guix build mix-build-system)
 ;; minor version number of the Elixir used in the build.
 (define %elixir-version (make-parameter "X.Y"))
 
+(define (elixir-relative-libdir version)
+  "Return the relative path inside a package namespace in the store where all
+libraries for a specified Elixir VERSION are installed."
+  (string-append "lib/elixir/" version))
+
 (define* (elixir-libdir path #:optional (version (%elixir-version)))
   "Return the path where all libraries under PATH for a specified Elixir
 VERSION are installed."
-  (string-append path "/lib/elixir/" version))
+  (string-append path "/" (elixir-relative-libdir version)))
 
 (define* (strip-prefix name #:optional (prefix "elixir-"))
   "Return NAME without the prefix PREFIX."
@@ -94,6 +100,17 @@ (define* (set-mix-env #:key inputs mix-path mix-exs #:allow-other-keys)
   (setenv "MIX_PATH" (or mix-path ""))
   (setenv "MIX_REBAR3" (string-append (assoc-ref inputs "rebar3") "/bin/rebar3")))
 
+(define* (set-erl-env #:key inputs #:allow-other-keys)
+  "Add dependencies in Elixir's load path."
+  (setenv "ERL_LIBS"
+          (string-join (search-path-as-list
+                        `("lib/erlang/lib"
+                          ,(elixir-relative-libdir (elixir-version inputs)))
+                        (map (match-lambda
+                               ((label . package) package))
+                             inputs))
+                       ":")))
+
 (define* (set-elixir-version #:key inputs #:allow-other-keys)
   "Store the version number of the Elixir input in a parameter."
   (%elixir-version (elixir-version inputs))
@@ -152,6 +169,7 @@ (define %standard-phases
     (delete 'configure)
     (add-after 'install-locale 'set-mix-env set-mix-env)
     (add-after 'set-mix-env 'set-elixir-version set-elixir-version)
+    (add-after 'set-elixir-version 'set-erl-env set-erl-env)
     (replace 'unpack unpack)
     (replace 'build build)
     (replace 'check check)

base-commit: 3ac69c1a757430d6dfdd37eb948ba1d6967967cc
-- 
2.46.0





^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [bug#73458] [PATCH 2/2] build-system: mix: Fix decoding of package names with git versions.
  2024-09-25  8:24 ` [bug#73458] [PATCH 1/2] build-system: mix: Allow loading Erlang dependencies in Mix driven builds Giacomo Leidi via Guix-patches via
@ 2024-09-25  8:24   ` Giacomo Leidi via Guix-patches via
  2024-09-25 19:54     ` Liliana Marie Prikler
  2024-09-25 18:42   ` [bug#73458] [PATCH 1/2] build-system: mix: Allow loading Erlang dependencies in Mix driven builds Liliana Marie Prikler
  1 sibling, 1 reply; 8+ messages in thread
From: Giacomo Leidi via Guix-patches via @ 2024-09-25  8:24 UTC (permalink / raw)
  To: 73458; +Cc: Giacomo Leidi

Fixes <https://issues.guix.gnu.org/73454>

* guix/build/mix-build-system.scm (%git-version-rx): New variable,
(package-name->elixir-name): use %git-version-rx to discriminate git
versions from regular ones.

Change-Id: Icc6dc56c3db62dfbc17c7c71354a7a7e3d2e5b2a
---
 guix/build/mix-build-system.scm | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/guix/build/mix-build-system.scm b/guix/build/mix-build-system.scm
index 41f6061444..7250785914 100644
--- a/guix/build/mix-build-system.scm
+++ b/guix/build/mix-build-system.scm
@@ -40,6 +40,9 @@ (define-module (guix build mix-build-system)
 ;; minor version number of the Elixir used in the build.
 (define %elixir-version (make-parameter "X.Y"))
 
+(define %git-version-rx
+  (make-regexp "^(.*)-[0-9]+(\\.[0-9]+)?(\\.[0-9]+)?-[0-9]+\\..+$"))
+
 (define (elixir-relative-libdir version)
   "Return the relative path inside a package namespace in the store where all
 libraries for a specified Elixir VERSION are installed."
@@ -141,10 +144,12 @@ (define* (remove-mix-dirs . _)
 
 (define (package-name->elixir-name name+ver)
   "Convert the Guix package NAME-VER to the corresponding Elixir name-version
-format.  Example: elixir-a-pkg-1.2.3 -> a_pkg"
+format.  Example: elixir-a-pkg-1.2.3 -> a_pkg or elixir-a-pkg-0.0.0-0.e51e36e
+-> a_pkg"
+  (define git-version? (regexp-exec %git-version-rx name+ver))
   ((compose
     (cute string-join <> "_")
-    (cute drop-right <> 1)
+    (cute drop-right <> (if git-version? 2 1))
     (cute string-split <> #\-))
    (strip-prefix name+ver)))
 
-- 
2.46.0





^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [bug#73458] [PATCH 1/2] build-system: mix: Allow loading Erlang dependencies in Mix driven builds.
  2024-09-25  8:24 ` [bug#73458] [PATCH 1/2] build-system: mix: Allow loading Erlang dependencies in Mix driven builds Giacomo Leidi via Guix-patches via
  2024-09-25  8:24   ` [bug#73458] [PATCH 2/2] build-system: mix: Fix decoding of package names with git versions Giacomo Leidi via Guix-patches via
@ 2024-09-25 18:42   ` Liliana Marie Prikler
  1 sibling, 0 replies; 8+ messages in thread
From: Liliana Marie Prikler @ 2024-09-25 18:42 UTC (permalink / raw)
  To: Giacomo Leidi, 73458

Am Mittwoch, dem 25.09.2024 um 10:24 +0200 schrieb Giacomo Leidi:
> Fixes <https://issues.guix.gnu.org/73453>
Note: It's not official yet, but Fixes: <URL> is nice for a trailer. 
If it fits into 80 columns, you can also do Fixes: [shortdoc] <URL>.

> * guix/build/mix-build-system.scm (elixir-relative-libdir): New
> variable;
> (elixir-libdir): call elixir-relative-libdir;
Use full sentences, end each with a period (dot).
> (set-erl-env): this new phase sets ERL_LIBS to allow Erlang's virtual
> machine to load Erlang dependencies in Mix builds, in addition to
> Elixir
> ones;
> (%standard-phases): add set-erl-env phases.
> 
> Change-Id: Ic1ef5db20680bfd265fbac72bafb760d21135f68
> ---
>  guix/build/mix-build-system.scm | 20 +++++++++++++++++++-
>  1 file changed, 19 insertions(+), 1 deletion(-)
> 
> diff --git a/guix/build/mix-build-system.scm b/guix/build/mix-build-
> system.scm
> index 0b021da791..41f6061444 100644
> --- a/guix/build/mix-build-system.scm
> +++ b/guix/build/mix-build-system.scm
> @@ -1,6 +1,7 @@
>  ;;; GNU Guix --- Functional package management for GNU
>  ;;; Copyright © 2023 Pierre-Henry Fröhring <contact@phfrohring.com>
>  ;;; Copyright © 2024 Igor Goryachev <igor@goryachev.org>
> +;;; Copyright © 2024 Giacomo Leidi <goodoldpaul@autistici.org>
>  ;;;
>  ;;; This file is part of GNU Guix.
>  ;;;
> @@ -39,10 +40,15 @@ (define-module (guix build mix-build-system)
>  ;; minor version number of the Elixir used in the build.
>  (define %elixir-version (make-parameter "X.Y"))
>  
> +(define (elixir-relative-libdir version)
> +  "Return the relative path inside a package namespace in the store
> where all
> +libraries for a specified Elixir VERSION are installed."
> +  (string-append "lib/elixir/" version))
> +
>  (define* (elixir-libdir path #:optional (version (%elixir-version)))
>    "Return the path where all libraries under PATH for a specified
> Elixir
>  VERSION are installed."
> -  (string-append path "/lib/elixir/" version))
> +  (string-append path "/" (elixir-relative-libdir version)))
Rather than having two procedures here, I think calling elixir-libdir
on "lib/erlang/lib" does what you want.


>  (define* (strip-prefix name #:optional (prefix "elixir-"))
>    "Return NAME without the prefix PREFIX."
> @@ -94,6 +100,17 @@ (define* (set-mix-env #:key inputs mix-path mix-
> exs #:allow-other-keys)
>    (setenv "MIX_PATH" (or mix-path ""))
>    (setenv "MIX_REBAR3" (string-append (assoc-ref inputs "rebar3")
> "/bin/rebar3")))
>  
> +(define* (set-erl-env #:key inputs #:allow-other-keys)
> +  "Add dependencies in Elixir's load path."
> +  (setenv "ERL_LIBS"
> +          (string-join (search-path-as-list
> +                        `("lib/erlang/lib"
> +                          ,(elixir-relative-libdir (elixir-version
> inputs)))
> +                        (map (match-lambda
> +                               ((label . package) package))
> +                             inputs))
> +                       ":")))
> +
>  (define* (set-elixir-version #:key inputs #:allow-other-keys)
>    "Store the version number of the Elixir input in a parameter."
>    (%elixir-version (elixir-version inputs))
> @@ -152,6 +169,7 @@ (define %standard-phases
>      (delete 'configure)
>      (add-after 'install-locale 'set-mix-env set-mix-env)
>      (add-after 'set-mix-env 'set-elixir-version set-elixir-version)
> +    (add-after 'set-elixir-version 'set-erl-env set-erl-env)
I think we can reorder this so that set-elixir-version is called first
and set-erl-env can be inlined into set-mix-env.

Cheers




^ permalink raw reply	[flat|nested] 8+ messages in thread

* [bug#73458] [PATCH 2/2] build-system: mix: Fix decoding of package names with git versions.
  2024-09-25  8:24   ` [bug#73458] [PATCH 2/2] build-system: mix: Fix decoding of package names with git versions Giacomo Leidi via Guix-patches via
@ 2024-09-25 19:54     ` Liliana Marie Prikler
  2024-09-25 21:30       ` paul via Guix-patches via
  0 siblings, 1 reply; 8+ messages in thread
From: Liliana Marie Prikler @ 2024-09-25 19:54 UTC (permalink / raw)
  To: Giacomo Leidi, 73458

Am Mittwoch, dem 25.09.2024 um 10:24 +0200 schrieb Giacomo Leidi:
> Fixes <https://issues.guix.gnu.org/73454>
> 
> * guix/build/mix-build-system.scm (%git-version-rx): New variable,
> (package-name->elixir-name): use %git-version-rx to discriminate git
> versions from regular ones.
> 
> Change-Id: Icc6dc56c3db62dfbc17c7c71354a7a7e3d2e5b2a
> ---
>  guix/build/mix-build-system.scm | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/guix/build/mix-build-system.scm b/guix/build/mix-build-
> system.scm
> index 41f6061444..7250785914 100644
> --- a/guix/build/mix-build-system.scm
> +++ b/guix/build/mix-build-system.scm
> @@ -40,6 +40,9 @@ (define-module (guix build mix-build-system)
>  ;; minor version number of the Elixir used in the build.
>  (define %elixir-version (make-parameter "X.Y"))
>  
> +(define %git-version-rx
> +  (make-regexp "^(.*)-[0-9]+(\\.[0-9]+)?(\\.[0-9]+)?-[0-9]+\\..+$"))
> +
This regexp appears unsafe to me.  It matches a numeric component in
the package name as well.

>  (define (elixir-relative-libdir version)
>    "Return the relative path inside a package namespace in the store
> where all
>  libraries for a specified Elixir VERSION are installed."
> @@ -141,10 +144,12 @@ (define* (remove-mix-dirs . _)
>  
>  (define (package-name->elixir-name name+ver)
>    "Convert the Guix package NAME-VER to the corresponding Elixir
> name-version
> -format.  Example: elixir-a-pkg-1.2.3 -> a_pkg"
> +format.  Example: elixir-a-pkg-1.2.3 -> a_pkg or elixir-a-pkg-0.0.0-
> 0.e51e36e
> +-> a_pkg"
> +  (define git-version? (regexp-exec %git-version-rx name+ver))
>    ((compose
>      (cute string-join <> "_")
> -    (cute drop-right <> 1)
> +    (cute drop-right <> (if git-version? 2 1))
>      (cute string-split <> #\-))
I think we might have it easier if we pick the left side from a string-
split with #\.  Ideally, package names should not contain dots.
>     (strip-prefix name+ver)))

Cheers





^ permalink raw reply	[flat|nested] 8+ messages in thread

* [bug#73458] [PATCH 2/2] build-system: mix: Fix decoding of package names with git versions.
  2024-09-25 19:54     ` Liliana Marie Prikler
@ 2024-09-25 21:30       ` paul via Guix-patches via
  0 siblings, 0 replies; 8+ messages in thread
From: paul via Guix-patches via @ 2024-09-25 21:30 UTC (permalink / raw)
  To: Liliana Marie Prikler, 73458

Hi Liliana,

Thank you for your help! I'm sending  v2 addressing your comments. I 
dropped the

elixir-relative-libdir

procedure all together because after some experimentation over at [0] it 
doesn't seem to be actually required. About splitting at dots it would 
complicate the logic imho as you would need to discriminate dots between 
version numbers and the dot before the commit. If you don't consider 
this as a blocking issue I think the regexp should be enough for the 
cases I tried.

Thank you for your work,

giacomo



[0]: https://github.com/fishinthecalculator/bonfire-guix





^ permalink raw reply	[flat|nested] 8+ messages in thread

* [bug#73458] [PATCH v2 1/2] build-system: mix: Allow loading Erlang dependencies in Mix driven builds.
  2024-09-24 17:03 [bug#73458] Fix mix-build-system bugs (73453 , 73454) paul via Guix-patches via
  2024-09-25  8:24 ` [bug#73458] [PATCH 1/2] build-system: mix: Allow loading Erlang dependencies in Mix driven builds Giacomo Leidi via Guix-patches via
@ 2024-09-25 21:39 ` Giacomo Leidi via Guix-patches via
  2024-09-25 21:39   ` [bug#73458] [PATCH v2 2/2] build-system: mix: Fix decoding of package names with git versions Giacomo Leidi via Guix-patches via
  1 sibling, 1 reply; 8+ messages in thread
From: Giacomo Leidi via Guix-patches via @ 2024-09-25 21:39 UTC (permalink / raw)
  To: 73458; +Cc: Giacomo Leidi

* guix/build/mix-build-system.scm (set-mix-env): sets ERL_LIBS to allow
Erlang's virtual machine to load Erlang dependencies in Mix builds.

Fixes <https://issues.guix.gnu.org/73453>
Change-Id: Ic1ef5db20680bfd265fbac72bafb760d21135f68

Change-Id: I2e0ae4908353833d81003b4f750af56ff3f8dbfb
---
 guix/build/mix-build-system.scm | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/guix/build/mix-build-system.scm b/guix/build/mix-build-system.scm
index 0b021da791..73af575b10 100644
--- a/guix/build/mix-build-system.scm
+++ b/guix/build/mix-build-system.scm
@@ -1,6 +1,7 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2023 Pierre-Henry Fröhring <contact@phfrohring.com>
 ;;; Copyright © 2024 Igor Goryachev <igor@goryachev.org>
+;;; Copyright © 2024 Giacomo Leidi <goodoldpaul@autistici.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -92,7 +93,15 @@ (define* (set-mix-env #:key inputs mix-path mix-exs #:allow-other-keys)
   (setenv "MIX_EXS" mix-exs)
   (setenv "MIX_HOME" (getcwd))
   (setenv "MIX_PATH" (or mix-path ""))
-  (setenv "MIX_REBAR3" (string-append (assoc-ref inputs "rebar3") "/bin/rebar3")))
+  (setenv "MIX_REBAR3" (string-append (assoc-ref inputs "rebar3") "/bin/rebar3"))
+  ;; Add Erlang dependencies in Elixir's load path.
+  (setenv "ERL_LIBS"
+          (string-join (search-path-as-list
+                        `("lib/erlang/lib")
+                        (map (match-lambda
+                               ((label . package) package))
+                             inputs))
+                       ":")))
 
 (define* (set-elixir-version #:key inputs #:allow-other-keys)
   "Store the version number of the Elixir input in a parameter."

base-commit: a1dc5ac832a106d46450961e78e7db3f83bf2bff
-- 
2.46.0





^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [bug#73458] [PATCH v2 2/2] build-system: mix: Fix decoding of package names with git versions.
  2024-09-25 21:39 ` [bug#73458] [PATCH v2 " Giacomo Leidi via Guix-patches via
@ 2024-09-25 21:39   ` Giacomo Leidi via Guix-patches via
  0 siblings, 0 replies; 8+ messages in thread
From: Giacomo Leidi via Guix-patches via @ 2024-09-25 21:39 UTC (permalink / raw)
  To: 73458; +Cc: Giacomo Leidi

* guix/build/mix-build-system.scm (%git-version-rx): New variable,
(package-name->elixir-name): use %git-version-rx to discriminate git
versions from regular ones.

Fixes <https://issues.guix.gnu.org/73454>
Change-Id: Icc6dc56c3db62dfbc17c7c71354a7a7e3d2e5b2a

Change-Id: I99ad5e36680928e50c0cba5beb85f34c7bfa12df
---
 guix/build/mix-build-system.scm | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/guix/build/mix-build-system.scm b/guix/build/mix-build-system.scm
index 73af575b10..6b7541cf56 100644
--- a/guix/build/mix-build-system.scm
+++ b/guix/build/mix-build-system.scm
@@ -40,6 +40,9 @@ (define-module (guix build mix-build-system)
 ;; minor version number of the Elixir used in the build.
 (define %elixir-version (make-parameter "X.Y"))
 
+(define %git-version-rx
+  (make-regexp "^(.*)-[0-9]+(\\.[0-9]+)?(\\.[0-9]+)?-[0-9]+\\..+$"))
+
 (define* (elixir-libdir path #:optional (version (%elixir-version)))
   "Return the path where all libraries under PATH for a specified Elixir
 VERSION are installed."
@@ -133,10 +136,12 @@ (define* (remove-mix-dirs . _)
 
 (define (package-name->elixir-name name+ver)
   "Convert the Guix package NAME-VER to the corresponding Elixir name-version
-format.  Example: elixir-a-pkg-1.2.3 -> a_pkg"
+format.  Example: elixir-a-pkg-1.2.3 -> a_pkg or elixir-a-pkg-0.0.0-0.e51e36e
+-> a_pkg"
+  (define git-version? (regexp-exec %git-version-rx name+ver))
   ((compose
     (cute string-join <> "_")
-    (cute drop-right <> 1)
+    (cute drop-right <> (if git-version? 2 1))
     (cute string-split <> #\-))
    (strip-prefix name+ver)))
 
-- 
2.46.0





^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2024-09-25 21:49 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-24 17:03 [bug#73458] Fix mix-build-system bugs (73453 , 73454) paul via Guix-patches via
2024-09-25  8:24 ` [bug#73458] [PATCH 1/2] build-system: mix: Allow loading Erlang dependencies in Mix driven builds Giacomo Leidi via Guix-patches via
2024-09-25  8:24   ` [bug#73458] [PATCH 2/2] build-system: mix: Fix decoding of package names with git versions Giacomo Leidi via Guix-patches via
2024-09-25 19:54     ` Liliana Marie Prikler
2024-09-25 21:30       ` paul via Guix-patches via
2024-09-25 18:42   ` [bug#73458] [PATCH 1/2] build-system: mix: Allow loading Erlang dependencies in Mix driven builds Liliana Marie Prikler
2024-09-25 21:39 ` [bug#73458] [PATCH v2 " Giacomo Leidi via Guix-patches via
2024-09-25 21:39   ` [bug#73458] [PATCH v2 2/2] build-system: mix: Fix decoding of package names with git versions Giacomo Leidi via Guix-patches via

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).