Subject: [PATCH v3 02/15] gnu: elixir: Wrap binaries.

From: Pierre-Henry Fröhring <[email-masked]>
Date: Fri, 8 Dec 2023 15:27:24 +0100

* gnu/packages/elixir.scm (elixir)[arguments]: Phase `wrap-programs' added.
* gnu/packages/elixir.scm (elixir)[native-search-paths]: Variable
`GUIX_ELIXIR_LIBS' added.

Change-Id: I75bdde3aeedc1d495ea5fc2c5fc3fcdc5dc3fad2
---
 gnu/packages/elixir.scm | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/gnu/packages/elixir.scm b/gnu/packages/elixir.scm
index 724b42512..15cbdbdfc 100644
--- a/gnu/packages/elixir.scm
+++ b/gnu/packages/elixir.scm
@@ -27,6 +27,7 @@ (define-module (gnu packages elixir)
   #:use-module ((guix licenses) #:prefix license:)
   #:use-module (guix build-system gnu)
   #:use-module (guix gexp)
+  #:use-module (guix utils)
   #:use-module (guix git-download)
   #:use-module (guix packages)
   #:use-module (gnu packages)
@@ -96,9 +97,20 @@ (define-public elixir
             (lambda* (#:key inputs #:allow-other-keys)
               ;; Some tests require access to a home directory.
               (setenv "HOME" "/tmp")))
-          (delete 'configure))))
-    (inputs
-     (list erlang git))
+          (delete 'configure)
+          (add-after 'install 'wrap-programs
+            (lambda* (#:key inputs outputs #:allow-other-keys)
+              (let* ((out (assoc-ref outputs "out"))
+                     (programs '("elixir" "elixirc" "iex" "mix")))
+                (for-each (lambda (program)
+                            (wrap-program (string-append out "/bin/" program)
+                              '("ERL_LIBS" prefix ("${GUIX_ELIXIR_LIBS}"))))
+                          programs)))))))
+    (inputs (list erlang git))
+    (native-search-paths
+     (list (search-path-specification
+            (variable "GUIX_ELIXIR_LIBS")
+            (files (list (string-append "lib/elixir/" (version-major+minor version)))))))
     (home-page "https://elixir-lang.org/")
     (synopsis "Elixir programming language")
     (description "Elixir is a dynamic, functional language used to build
-- 
2.41.0