summaryrefslogtreecommitdiff
path: root/gnu/packages/elixir.scm
diff options
context:
space:
mode:
authorIgor Goryachev via Guix-patches via <guix-patches@gnu.org>2024-06-13 09:17:55 +0300
committerAndrew Tropin <andrew@trop.in>2024-06-20 16:26:14 +0400
commit70a316c8848915a1cdcee3427b8692ac82c221e2 (patch)
tree921da8902a6458e39912d634b1a2cc6514030414 /gnu/packages/elixir.scm
parent58ebd2402f0c84c264b5fc974a3cf866865037fb (diff)
gnu: elixir: Add src output, metas correction, lint warnings fix.
* gnu/packages/elixir.scm (elixir): Add src output, metas correction, lint warnings fix. Change-Id: I93ae35239168de9a8d8d99ca83950edfce735bc2 Co-authored-by: Andrew Tropin <andrew@trop.in> Signed-off-by: Andrew Tropin <andrew@trop.in> Change-Id: Ibc9a72aa21e62cec6fc1121b6b21e12a5a967fed
Diffstat (limited to 'gnu/packages/elixir.scm')
-rw-r--r--gnu/packages/elixir.scm152
1 files changed, 91 insertions, 61 deletions
diff --git a/gnu/packages/elixir.scm b/gnu/packages/elixir.scm
index 7675b38ffb8..e3051a8275b 100644
--- a/gnu/packages/elixir.scm
+++ b/gnu/packages/elixir.scm
@@ -34,6 +34,7 @@
34 #:use-module (guix git-download) 34 #:use-module (guix git-download)
35 #:use-module (guix packages) 35 #:use-module (guix packages)
36 #:use-module (gnu packages) 36 #:use-module (gnu packages)
37 #:use-module (gnu packages bash)
37 #:use-module (gnu packages erlang) 38 #:use-module (gnu packages erlang)
38 #:use-module (gnu packages version-control)) 39 #:use-module (gnu packages version-control))
39 40
@@ -58,59 +59,85 @@
58 #:parallel-tests? #f ;see <https://debbugs.gnu.org/cgi/bugreport.cgi?bug=32171#23> 59 #:parallel-tests? #f ;see <https://debbugs.gnu.org/cgi/bugreport.cgi?bug=32171#23>
59 #:make-flags #~(list (string-append "PREFIX=" #$output)) 60 #:make-flags #~(list (string-append "PREFIX=" #$output))
60 #:phases 61 #:phases
61 #~(modify-phases %standard-phases 62 #~(let* ((compiler-path "lib/elixir/src/elixir_erl_compiler.erl")
62 (add-after 'unpack 'make-git-checkout-writable 63 (compiler-path-orig (string-append compiler-path ".orig")))
63 (lambda _ 64 (modify-phases %standard-phases
64 (for-each make-file-writable (find-files ".")))) 65 (add-after 'unpack 'make-git-checkout-writable
65 (add-after 'make-git-checkout-writable 'replace-paths 66 (lambda _
66 (lambda* (#:key inputs #:allow-other-keys) 67 (for-each make-file-writable (find-files "."))))
67 ;; Note: references end up obfuscated in binary BEAM files where 68 (add-after 'make-git-checkout-writable 'replace-paths
68 ;; they may be invisible to the GC and graft code: 69 (lambda* (#:key inputs #:allow-other-keys)
69 ;; <https://issues.guix.gnu.org/54304#11>. 70 ;; Note: references end up obfuscated in binary BEAM files
70 (substitute* '("lib/mix/lib/mix/release.ex" 71 ;; where they may be invisible to the GC and graft code:
71 "lib/mix/lib/mix/tasks/release.init.ex") 72 ;; <https://issues.guix.gnu.org/54304#11>.
72 (("#!/bin/sh") 73 (substitute* '("lib/mix/lib/mix/release.ex"
73 (string-append "#!" (search-input-file inputs "/bin/sh")))) 74 "lib/mix/lib/mix/tasks/release.init.ex")
74 (substitute* "bin/elixir" 75 (("#!/bin/sh")
75 (("ERTS_BIN=\n") 76 (string-append "#!" (search-input-file inputs "/bin/sh"))))
76 (string-append 77 (substitute* "bin/elixir"
77 "ERTS_BIN=" 78 (("ERTS_BIN=\n")
78 ;; Elixir Releases will prepend to ERTS_BIN the path of 79 (string-append
79 ;; a copy of erl. We detect if a release is being generated 80 "ERTS_BIN="
80 ;; by checking the initial ERTS_BIN value: if it's empty, we 81 ;; Elixir Releases will prepend to ERTS_BIN the path of
81 ;; are not in release mode and can point to the actual erl 82 ;; a copy of erl. We detect if a release is being
82 ;; binary in Guix store. 83 ;; generated by checking the initial ERTS_BIN value: if
83 "\nif [ -z \"$ERTS_BIN\" ]; then ERTS_BIN=" 84 ;; it's empty, we are not in release mode and can point
84 (string-drop-right (search-input-file inputs "/bin/erl") 3) 85 ;; to the actual erl binary in Guix store.
85 "; fi\n"))) 86 "\nif [ -z \"$ERTS_BIN\" ]; then ERTS_BIN="
86 (substitute* "bin/mix" 87 (string-drop-right
87 (("#!/usr/bin/env elixir") 88 (search-input-file inputs "/bin/erl") 3)
88 (string-append "#!" #$output "/bin/elixir"))))) 89 "; fi\n")))
89 (add-before 'build 'make-current 90 (substitute* "bin/mix"
90 ;; The Elixir compiler checks whether or not to compile files by 91 (("#!/usr/bin/env elixir")
91 ;; inspecting their timestamps. When the timestamp is equal to the 92 (string-append "#!" #$output "/bin/elixir")))))
92 ;; epoch no compilation will be performed. Some tests fail when 93 (add-after 'replace-paths 'pre-install-source
93 ;; files are older than Jan 1, 2000. 94 (lambda* (#:key outputs #:allow-other-keys)
94 (lambda _ 95 (copy-recursively
95 (for-each (lambda (file) 96 "lib"
96 (let ((recent 1400000000)) 97 (string-append (assoc-ref outputs "src") "/source/lib"))))
97 (utime file recent recent 0 0))) 98 ;; Temporarily patch the compiler to place correct source
98 (find-files "." ".*")))) 99 ;; locations into module info instead of build directory.
99 (add-before 'check 'set-home 100 (add-after 'pre-install-source 'patch-elixir-compiler
100 (lambda* (#:key inputs #:allow-other-keys) 101 (lambda* (#:key outputs #:allow-other-keys)
101 ;; Some tests require access to a home directory. 102 (copy-recursively compiler-path compiler-path-orig)
102 (setenv "HOME" "/tmp"))) 103 (let ((source (string-append "/tmp/guix-build-" #$name "-"
103 (delete 'configure) 104 #$version ".drv-0"))
104 (add-after 'install 'wrap-programs 105 (destination (assoc-ref outputs "src")))
105 (lambda* (#:key inputs outputs #:allow-other-keys) 106 (substitute* compiler-path
106 (let* ((out (assoc-ref outputs "out")) 107 (("source, Source")
107 (programs '("elixir" "elixirc" "iex"))) 108 (string-append "source, string:replace(Source, \""
108 ;; mix can be sourced as an elixir script by other elixir 109 source "\", \"" destination "\")"))))))
109 ;; program, for example `iex -S mix`, so we should not wrap 110 (add-before 'build 'make-current
110 ;; mix into shell script. 111 ;; The Elixir compiler checks whether or not to compile files
111 (substitute* (string-append out "/bin/mix") 112 ;; by inspecting their timestamps. When the timestamp is
112 (("Mix.start\\(\\)") 113 ;; equal to the epoch no compilation will be performed. Some
113 (format #f "\ 114 ;; tests fail when files are older than Jan 1, 2000.
115 (lambda _
116 (for-each (lambda (file)
117 (let ((recent 1400000000))
118 (utime file recent recent 0 0)))
119 (find-files "." ".*"))))
120 ;; Unpatch the compiler and recompile it.
121 (add-after 'build 'restore-and-recompile
122 (lambda _
123 (copy-recursively compiler-path-orig compiler-path)
124 (delete-file compiler-path-orig)
125 (invoke "make")))
126 (add-before 'check 'set-home
127 (lambda* (#:key inputs #:allow-other-keys)
128 ;; Some tests require access to a home directory.
129 (setenv "HOME" "/tmp")))
130 (delete 'configure)
131 (add-after 'install 'wrap-programs
132 (lambda* (#:key inputs outputs #:allow-other-keys)
133 (let* ((out (assoc-ref outputs "out"))
134 (programs '("elixir" "elixirc" "iex")))
135 ;; mix can be sourced as an elixir script by other elixir
136 ;; program, for example `iex -S mix`, so we should not wrap
137 ;; mix into shell script.
138 (substitute* (string-append out "/bin/mix")
139 (("Mix.start\\(\\)")
140 (format #f "\
114~~w[GUIX_ELIXIR_LIBS ERL_LIBS] 141~~w[GUIX_ELIXIR_LIBS ERL_LIBS]
115|> Enum.map(&System.get_env/1) 142|> Enum.map(&System.get_env/1)
116|> Enum.reject(&is_nil/1) 143|> Enum.reject(&is_nil/1)
@@ -118,18 +145,21 @@
118|> case do \"\" -> :ok; erl_libs -> System.put_env(\"ERL_LIBS\", erl_libs) end 145|> case do \"\" -> :ok; erl_libs -> System.put_env(\"ERL_LIBS\", erl_libs) end
119System.put_env(\"MIX_REBAR3\", System.get_env(\"MIX_REBAR3\", \"~a\")) 146System.put_env(\"MIX_REBAR3\", System.get_env(\"MIX_REBAR3\", \"~a\"))
120Mix.start()" 147Mix.start()"
121 (search-input-file inputs "/bin/rebar3")))) 148 (search-input-file inputs "/bin/rebar3"))))
122 (for-each (lambda (program) 149 (for-each
123 (wrap-program (string-append out "/bin/" program) 150 (lambda (program)
124 '("ERL_LIBS" prefix ("${GUIX_ELIXIR_LIBS}")))) 151 (wrap-program (string-append out "/bin/" program)
125 programs))))))) 152 '("ERL_LIBS" prefix ("${GUIX_ELIXIR_LIBS}"))))
126 (inputs (list erlang rebar3 git)) 153 programs))))))))
154 (outputs '("out" "src"))
155 (inputs (list bash-minimal erlang rebar3 git))
127 (native-search-paths 156 (native-search-paths
128 (list (search-path-specification 157 (list (search-path-specification
129 (variable "GUIX_ELIXIR_LIBS") 158 (variable "GUIX_ELIXIR_LIBS")
130 (files (list (string-append "lib/elixir/" (version-major+minor version))))))) 159 (files (list (string-append "lib/elixir/" (version-major+minor
160 version)))))))
131 (home-page "https://elixir-lang.org/") 161 (home-page "https://elixir-lang.org/")
132 (synopsis "Elixir programming language") 162 (synopsis "Functional meta-programming aware language")
133 (description "Elixir is a dynamic, functional language used to build 163 (description "Elixir is a dynamic, functional language used to build
134scalable and maintainable applications. Elixir leverages the Erlang VM, known 164scalable and maintainable applications. Elixir leverages the Erlang VM, known
135for running low-latency, distributed and fault-tolerant systems, while also 165for running low-latency, distributed and fault-tolerant systems, while also