GNU bug report logs - #68964
[PATCH] gnu: elixir: Remove wrap for mix.

Previous Next

Package: guix-patches;

Reported by: Andrew Tropin <andrew <at> trop.in>

Date: Wed, 7 Feb 2024 06:44:01 UTC

Severity: normal

Tags: patch

Done: Andrew Tropin <andrew <at> trop.in>

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 68964 in the body.
You can then email your comments to 68964 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#68964; Package guix-patches. (Wed, 07 Feb 2024 06:44:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Andrew Tropin <andrew <at> trop.in>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Wed, 07 Feb 2024 06:44:02 GMT) Full text and rfc822 format available.

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

From: Andrew Tropin <andrew <at> trop.in>
To: guix-patches <at> gnu.org
Cc: Pierre-Henry Fröhring <contact <at> phfrohring.com>,
 Liliana Marie Prikler <liliana.prikler <at> gmail.com>,
 Andrew Tropin <andrew <at> trop.in>
Subject: [PATCH] gnu: elixir: Remove wrap for mix.
Date: Wed,  7 Feb 2024 09:39:22 +0300
* gnu/packages/elixir.scm (elixir)[#:phases]: Instead of wrapping mix into
shell script, which sets environment variables, we patch mix itself and set
environmnet variables via elixir code.

Change-Id: Ia4643e18fe927491242a0541938b7570bd56fca1
---
 gnu/packages/elixir.scm | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/elixir.scm b/gnu/packages/elixir.scm
index ef8c39d0d7..70a8fad5e8 100644
--- a/gnu/packages/elixir.scm
+++ b/gnu/packages/elixir.scm
@@ -101,7 +101,18 @@ (define-public elixir
           (add-after 'install 'wrap-programs
             (lambda* (#:key inputs outputs #:allow-other-keys)
               (let* ((out (assoc-ref outputs "out"))
-                     (programs '("elixir" "elixirc" "iex" "mix")))
+                     (programs '("elixir" "elixirc" "iex")))
+                ;; mix can be sourced as an elixir script by other elixir
+                ;; program, for example `iex -S mix`, so we should not wrap
+                ;; mix into shell script.
+                (substitute* (string-append out "/bin/mix")
+                  (("Mix.start\\(\\)") "\
+~w[GUIX_ELIXIR_LIBS ERL_LIBS]
+|> Enum.map(&System.get_env/1)
+|> Enum.reject(&is_nil/1)
+|> Enum.join(\":\")
+|> case do \"\" -> :ok; erl_libs -> System.put_env(\"ERL_LIBS\", erl_libs) end
+Mix.start()"))
                 (for-each (lambda (program)
                             (wrap-program (string-append out "/bin/" program)
                               '("ERL_LIBS" prefix ("${GUIX_ELIXIR_LIBS}"))))

base-commit: cce7a6d2d2b18f51d1fcab67b02a38c11d6f4f2d
-- 
2.41.0





Information forwarded to guix-patches <at> gnu.org:
bug#68964; Package guix-patches. (Wed, 07 Feb 2024 08:16:02 GMT) Full text and rfc822 format available.

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

From: Andrew Tropin <andrew <at> trop.in>
To: guix-patches <at> gnu.org
Cc: Pierre-Henry Fröhring <contact <at> phfrohring.com>,
 Ivan Sokolov <ivan-p-sokolov <at> ya.ru>,
 Liliana Marie Prikler <liliana.prikler <at> gmail.com>,
 Andrew Tropin <andrew <at> trop.in>
Subject: [PATCH v2] gnu: elixir: Remove wrap for mix.
Date: Wed,  7 Feb 2024 11:13:06 +0300
* gnu/packages/elixir.scm (elixir)[#:phases]: Instead of wrapping mix into
shell script, which sets environment variables, we patch mix itself and set
environmnet variables via elixir code.

Change-Id: Ia4643e18fe927491242a0541938b7570bd56fca1

Co-authored-by: Ivan Sokolov <ivan-p-sokolov <at> ya.ru>
Change-Id: I29d2c61299a8a54125f0e15190c526a860d501da
---
Changes since v1: Added Ivan's copyright and co-authored-by.

 gnu/packages/elixir.scm | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/elixir.scm b/gnu/packages/elixir.scm
index ef8c39d0d7..2d11707711 100644
--- a/gnu/packages/elixir.scm
+++ b/gnu/packages/elixir.scm
@@ -7,6 +7,8 @@
 ;;; Copyright © 2018 Nikita <nikita <at> n0.is>
 ;;; Copyright © 2021 Oskar Köök <oskar <at> maatriks.ee>
 ;;; Copyright © 2021 Cees de Groot <cg <at> evrl.com>
+;;; Copyright © 2024 Andrew Tropin <andrew <at> trop.in>
+;;; Copyright © 2024 Ivan Sokolov <ivan-p-sokolov <at> ya.ru>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -101,7 +103,18 @@ (define-public elixir
           (add-after 'install 'wrap-programs
             (lambda* (#:key inputs outputs #:allow-other-keys)
               (let* ((out (assoc-ref outputs "out"))
-                     (programs '("elixir" "elixirc" "iex" "mix")))
+                     (programs '("elixir" "elixirc" "iex")))
+                ;; mix can be sourced as an elixir script by other elixir
+                ;; program, for example `iex -S mix`, so we should not wrap
+                ;; mix into shell script.
+                (substitute* (string-append out "/bin/mix")
+                  (("Mix.start\\(\\)") "\
+~w[GUIX_ELIXIR_LIBS ERL_LIBS]
+|> Enum.map(&System.get_env/1)
+|> Enum.reject(&is_nil/1)
+|> Enum.join(\":\")
+|> case do \"\" -> :ok; erl_libs -> System.put_env(\"ERL_LIBS\", erl_libs) end
+Mix.start()"))
                 (for-each (lambda (program)
                             (wrap-program (string-append out "/bin/" program)
                               '("ERL_LIBS" prefix ("${GUIX_ELIXIR_LIBS}"))))

base-commit: cce7a6d2d2b18f51d1fcab67b02a38c11d6f4f2d
-- 
2.41.0





Information forwarded to guix-patches <at> gnu.org:
bug#68964; Package guix-patches. (Wed, 07 Feb 2024 18:24:02 GMT) Full text and rfc822 format available.

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

From: Liliana Marie Prikler <liliana.prikler <at> gmail.com>
To: Andrew Tropin <andrew <at> trop.in>, 68964 <at> debbugs.gnu.org
Cc: Pierre-Henry Fröhring <contact <at> phfrohring.com>,
 Ivan Sokolov <ivan-p-sokolov <at> ya.ru>
Subject: Re: [PATCH v2] gnu: elixir: Remove wrap for mix.
Date: Wed, 07 Feb 2024 19:22:51 +0100
Am Mittwoch, dem 07.02.2024 um 11:13 +0300 schrieb Andrew Tropin:
> * gnu/packages/elixir.scm (elixir)[#:phases]: Instead of wrapping mix
> into
> shell script, which sets environment variables, we patch mix itself
> and set
> environmnet variables via elixir code.
> 
> Change-Id: Ia4643e18fe927491242a0541938b7570bd56fca1
> 
> Co-authored-by: Ivan Sokolov <ivan-p-sokolov <at> ya.ru>
> Change-Id: I29d2c61299a8a54125f0e15190c526a860d501da
> ---
> Changes since v1: Added Ivan's copyright and co-authored-by.
> 
>  gnu/packages/elixir.scm | 15 ++++++++++++++-
>  1 file changed, 14 insertions(+), 1 deletion(-)
> 
> diff --git a/gnu/packages/elixir.scm b/gnu/packages/elixir.scm
> index ef8c39d0d7..2d11707711 100644
> --- a/gnu/packages/elixir.scm
> +++ b/gnu/packages/elixir.scm
> @@ -7,6 +7,8 @@
>  ;;; Copyright © 2018 Nikita <nikita <at> n0.is>
>  ;;; Copyright © 2021 Oskar Köök <oskar <at> maatriks.ee>
>  ;;; Copyright © 2021 Cees de Groot <cg <at> evrl.com>
> +;;; Copyright © 2024 Andrew Tropin <andrew <at> trop.in>
> +;;; Copyright © 2024 Ivan Sokolov <ivan-p-sokolov <at> ya.ru>
>  ;;;
>  ;;; This file is part of GNU Guix.
>  ;;;
> @@ -101,7 +103,18 @@ (define-public elixir
>            (add-after 'install 'wrap-programs
>              (lambda* (#:key inputs outputs #:allow-other-keys)
>                (let* ((out (assoc-ref outputs "out"))
> -                     (programs '("elixir" "elixirc" "iex" "mix")))
> +                     (programs '("elixir" "elixirc" "iex")))
> +                ;; mix can be sourced as an elixir script by other
> elixir
> +                ;; program, for example `iex -S mix`, so we should
> not wrap
> +                ;; mix into shell script.
> +                (substitute* (string-append out "/bin/mix")
> +                  (("Mix.start\\(\\)") "\
> +~w[GUIX_ELIXIR_LIBS ERL_LIBS]
> +|> Enum.map(&System.get_env/1)
> +|> Enum.reject(&is_nil/1)
> +|> Enum.join(\":\")
> +|> case do \"\" -> :ok; erl_libs -> System.put_env(\"ERL_LIBS\",
> erl_libs) end
> +Mix.start()"))
You might want to make a patch for that.  I don't speak Elixir, but
from what I understand, this LGTM.

Cheers




Reply sent to Andrew Tropin <andrew <at> trop.in>:
You have taken responsibility. (Thu, 08 Feb 2024 09:40:02 GMT) Full text and rfc822 format available.

Notification sent to Andrew Tropin <andrew <at> trop.in>:
bug acknowledged by developer. (Thu, 08 Feb 2024 09:40:02 GMT) Full text and rfc822 format available.

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

From: Andrew Tropin <andrew <at> trop.in>
To: Liliana Marie Prikler <liliana.prikler <at> gmail.com>,
 68964-done <at> debbugs.gnu.org
Cc: Pierre-Henry Fröhring <contact <at> phfrohring.com>,
 Ivan Sokolov <ivan-p-sokolov <at> ya.ru>
Subject: Re: [PATCH v2] gnu: elixir: Remove wrap for mix.
Date: Thu, 08 Feb 2024 12:39:12 +0300
[Message part 1 (text/plain, inline)]
On 2024-02-07 19:22, Liliana Marie Prikler wrote:

> Am Mittwoch, dem 07.02.2024 um 11:13 +0300 schrieb Andrew Tropin:
>> * gnu/packages/elixir.scm (elixir)[#:phases]: Instead of wrapping mix
>> into
>> shell script, which sets environment variables, we patch mix itself
>> and set
>> environmnet variables via elixir code.
>> 
>> Change-Id: Ia4643e18fe927491242a0541938b7570bd56fca1
>> 
>> Co-authored-by: Ivan Sokolov <ivan-p-sokolov <at> ya.ru>
>> Change-Id: I29d2c61299a8a54125f0e15190c526a860d501da
>> ---
>> Changes since v1: Added Ivan's copyright and co-authored-by.
>> 
>>  gnu/packages/elixir.scm | 15 ++++++++++++++-
>>  1 file changed, 14 insertions(+), 1 deletion(-)
>> 
>> diff --git a/gnu/packages/elixir.scm b/gnu/packages/elixir.scm
>> index ef8c39d0d7..2d11707711 100644
>> --- a/gnu/packages/elixir.scm
>> +++ b/gnu/packages/elixir.scm
>> @@ -7,6 +7,8 @@
>>  ;;; Copyright © 2018 Nikita <nikita <at> n0.is>
>>  ;;; Copyright © 2021 Oskar Köök <oskar <at> maatriks.ee>
>>  ;;; Copyright © 2021 Cees de Groot <cg <at> evrl.com>
>> +;;; Copyright © 2024 Andrew Tropin <andrew <at> trop.in>
>> +;;; Copyright © 2024 Ivan Sokolov <ivan-p-sokolov <at> ya.ru>
>>  ;;;
>>  ;;; This file is part of GNU Guix.
>>  ;;;
>> @@ -101,7 +103,18 @@ (define-public elixir
>>            (add-after 'install 'wrap-programs
>>              (lambda* (#:key inputs outputs #:allow-other-keys)
>>                (let* ((out (assoc-ref outputs "out"))
>> -                     (programs '("elixir" "elixirc" "iex" "mix")))
>> +                     (programs '("elixir" "elixirc" "iex")))
>> +                ;; mix can be sourced as an elixir script by other
>> elixir
>> +                ;; program, for example `iex -S mix`, so we should
>> not wrap
>> +                ;; mix into shell script.
>> +                (substitute* (string-append out "/bin/mix")
>> +                  (("Mix.start\\(\\)") "\
>> +~w[GUIX_ELIXIR_LIBS ERL_LIBS]
>> +|> Enum.map(&System.get_env/1)
>> +|> Enum.reject(&is_nil/1)
>> +|> Enum.join(\":\")
>> +|> case do \"\" -> :ok; erl_libs -> System.put_env(\"ERL_LIBS\",
>> erl_libs) end
>> +Mix.start()"))
> You might want to make a patch for that.  I don't speak Elixir, but
> from what I understand, this LGTM.

Thank you for reply!  Patch make sense for the consistency with similiar
fixes for other applications, however, it is also reasonable to keep the
logic of adding support for GUIX_ELIXIR_LIBS to all elixir binaries in
one build phase.  Both options seems viable to me, I'll stick with
substitute solution for now.

Applied and pushed as
https://git.savannah.gnu.org/cgit/guix.git/commit/?id=a903558577

-- 
Best regards,
Andrew Tropin
[signature.asc (application/pgp-signature, inline)]

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

This bug report was last modified 1 year and 102 days ago.

Previous Next


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