GNU bug report logs - #73458
Fix mix-build-system bugs (73453 , 73454)

Previous Next

Package: guix-patches;

Reported by: paul <goodoldpaul <at> autistici.org>

Date: Tue, 24 Sep 2024 17:33:02 UTC

Severity: normal

Done: Ludovic Courtès <ludo <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 73458 in the body.
You can then email your comments to 73458 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#73458; Package guix-patches. (Tue, 24 Sep 2024 17:33:03 GMT) Full text and rfc822 format available.

Acknowledgement sent to paul <goodoldpaul <at> autistici.org>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Tue, 24 Sep 2024 17:33:03 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: paul <goodoldpaul <at> autistici.org>
To: guix-patches <at> gnu.org
Subject: Fix mix-build-system bugs (73453 , 73454)
Date: Tue, 24 Sep 2024 19:03:42 +0200
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





Information forwarded to guix-patches <at> gnu.org:
bug#73458; Package guix-patches. (Wed, 25 Sep 2024 08:26:02 GMT) Full text and rfc822 format available.

Message #8 received at 73458 <at> debbugs.gnu.org (full text, mbox):

From: Giacomo Leidi <goodoldpaul <at> autistici.org>
To: 73458 <at> debbugs.gnu.org
Cc: Giacomo Leidi <goodoldpaul <at> autistici.org>
Subject: [PATCH 1/2] build-system: mix: Allow loading Erlang dependencies in
 Mix driven builds.
Date: Wed, 25 Sep 2024 10:24:32 +0200
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 <at> phfrohring.com>
 ;;; Copyright © 2024 Igor Goryachev <igor <at> goryachev.org>
+;;; Copyright © 2024 Giacomo Leidi <goodoldpaul <at> 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





Information forwarded to guix-patches <at> gnu.org:
bug#73458; Package guix-patches. (Wed, 25 Sep 2024 08:26:02 GMT) Full text and rfc822 format available.

Message #11 received at 73458 <at> debbugs.gnu.org (full text, mbox):

From: Giacomo Leidi <goodoldpaul <at> autistici.org>
To: 73458 <at> debbugs.gnu.org
Cc: Giacomo Leidi <goodoldpaul <at> autistici.org>
Subject: [PATCH 2/2] build-system: mix: Fix decoding of package names with git
 versions.
Date: Wed, 25 Sep 2024 10:24:33 +0200
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





Information forwarded to guix-patches <at> gnu.org:
bug#73458; Package guix-patches. (Wed, 25 Sep 2024 18:45:02 GMT) Full text and rfc822 format available.

Message #14 received at 73458 <at> debbugs.gnu.org (full text, mbox):

From: Liliana Marie Prikler <liliana.prikler <at> gmail.com>
To: Giacomo Leidi <goodoldpaul <at> autistici.org>, 73458 <at> debbugs.gnu.org
Subject: Re: [PATCH 1/2] build-system: mix: Allow loading Erlang
 dependencies in Mix driven builds.
Date: Wed, 25 Sep 2024 20:42:47 +0200
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 <at> phfrohring.com>
>  ;;; Copyright © 2024 Igor Goryachev <igor <at> goryachev.org>
> +;;; Copyright © 2024 Giacomo Leidi <goodoldpaul <at> 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




Information forwarded to guix-patches <at> gnu.org:
bug#73458; Package guix-patches. (Wed, 25 Sep 2024 20:56:02 GMT) Full text and rfc822 format available.

Message #17 received at 73458 <at> debbugs.gnu.org (full text, mbox):

From: Liliana Marie Prikler <liliana.prikler <at> gmail.com>
To: Giacomo Leidi <goodoldpaul <at> autistici.org>, 73458 <at> debbugs.gnu.org
Subject: Re: [PATCH 2/2] build-system: mix: Fix decoding of package names
 with git versions.
Date: Wed, 25 Sep 2024 21:54:21 +0200
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





Information forwarded to guix-patches <at> gnu.org:
bug#73458; Package guix-patches. (Wed, 25 Sep 2024 21:49:02 GMT) Full text and rfc822 format available.

Message #20 received at 73458 <at> debbugs.gnu.org (full text, mbox):

From: paul <goodoldpaul <at> autistici.org>
To: Liliana Marie Prikler <liliana.prikler <at> gmail.com>, 73458 <at> debbugs.gnu.org
Subject: Re: [PATCH 2/2] build-system: mix: Fix decoding of package names with
 git versions.
Date: Wed, 25 Sep 2024 23:30:02 +0200
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





Information forwarded to guix-patches <at> gnu.org:
bug#73458; Package guix-patches. (Wed, 25 Sep 2024 21:49:02 GMT) Full text and rfc822 format available.

Message #23 received at 73458 <at> debbugs.gnu.org (full text, mbox):

From: Giacomo Leidi <goodoldpaul <at> autistici.org>
To: 73458 <at> debbugs.gnu.org
Cc: Giacomo Leidi <goodoldpaul <at> autistici.org>
Subject: [PATCH v2 1/2] build-system: mix: Allow loading Erlang dependencies
 in Mix driven builds.
Date: Wed, 25 Sep 2024 23:39:17 +0200
* 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 <at> phfrohring.com>
 ;;; Copyright © 2024 Igor Goryachev <igor <at> goryachev.org>
+;;; Copyright © 2024 Giacomo Leidi <goodoldpaul <at> 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





Information forwarded to guix-patches <at> gnu.org:
bug#73458; Package guix-patches. (Wed, 25 Sep 2024 21:49:03 GMT) Full text and rfc822 format available.

Message #26 received at 73458 <at> debbugs.gnu.org (full text, mbox):

From: Giacomo Leidi <goodoldpaul <at> autistici.org>
To: 73458 <at> debbugs.gnu.org
Cc: Giacomo Leidi <goodoldpaul <at> autistici.org>
Subject: [PATCH v2 2/2] build-system: mix: Fix decoding of package names with
 git versions.
Date: Wed, 25 Sep 2024 23:39:18 +0200
* 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





Reply sent to Ludovic Courtès <ludo <at> gnu.org>:
You have taken responsibility. (Sat, 12 Oct 2024 18:41:07 GMT) Full text and rfc822 format available.

Notification sent to paul <goodoldpaul <at> autistici.org>:
bug acknowledged by developer. (Sat, 12 Oct 2024 18:41:07 GMT) Full text and rfc822 format available.

Message #31 received at 73458-done <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Giacomo Leidi <goodoldpaul <at> autistici.org>
Cc: 73458-done <at> debbugs.gnu.org
Subject: Re: bug#73458: Fix mix-build-system bugs (73453 , 73454)
Date: Sat, 12 Oct 2024 19:51:53 +0200
Giacomo Leidi <goodoldpaul <at> autistici.org> skribis:

> * 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

[...]

> * 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

Applied, thanks!

Ludo'.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 10 Nov 2024 12:24:09 GMT) Full text and rfc822 format available.

This bug report was last modified 280 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.