mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-11-07 23:46:13 -05:00
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
This commit is contained in:
parent
58ebd2402f
commit
70a316c884
1 changed files with 91 additions and 61 deletions
|
@ -34,6 +34,7 @@ (define-module (gnu packages elixir)
|
||||||
#:use-module (guix git-download)
|
#:use-module (guix git-download)
|
||||||
#:use-module (guix packages)
|
#:use-module (guix packages)
|
||||||
#:use-module (gnu packages)
|
#:use-module (gnu packages)
|
||||||
|
#:use-module (gnu packages bash)
|
||||||
#:use-module (gnu packages erlang)
|
#:use-module (gnu packages erlang)
|
||||||
#:use-module (gnu packages version-control))
|
#:use-module (gnu packages version-control))
|
||||||
|
|
||||||
|
@ -58,59 +59,85 @@ (define-public elixir
|
||||||
#:parallel-tests? #f ;see <https://debbugs.gnu.org/cgi/bugreport.cgi?bug=32171#23>
|
#:parallel-tests? #f ;see <https://debbugs.gnu.org/cgi/bugreport.cgi?bug=32171#23>
|
||||||
#:make-flags #~(list (string-append "PREFIX=" #$output))
|
#:make-flags #~(list (string-append "PREFIX=" #$output))
|
||||||
#:phases
|
#:phases
|
||||||
#~(modify-phases %standard-phases
|
#~(let* ((compiler-path "lib/elixir/src/elixir_erl_compiler.erl")
|
||||||
(add-after 'unpack 'make-git-checkout-writable
|
(compiler-path-orig (string-append compiler-path ".orig")))
|
||||||
(lambda _
|
(modify-phases %standard-phases
|
||||||
(for-each make-file-writable (find-files "."))))
|
(add-after 'unpack 'make-git-checkout-writable
|
||||||
(add-after 'make-git-checkout-writable 'replace-paths
|
(lambda _
|
||||||
(lambda* (#:key inputs #:allow-other-keys)
|
(for-each make-file-writable (find-files "."))))
|
||||||
;; Note: references end up obfuscated in binary BEAM files where
|
(add-after 'make-git-checkout-writable 'replace-paths
|
||||||
;; they may be invisible to the GC and graft code:
|
(lambda* (#:key inputs #:allow-other-keys)
|
||||||
;; <https://issues.guix.gnu.org/54304#11>.
|
;; Note: references end up obfuscated in binary BEAM files
|
||||||
(substitute* '("lib/mix/lib/mix/release.ex"
|
;; where they may be invisible to the GC and graft code:
|
||||||
"lib/mix/lib/mix/tasks/release.init.ex")
|
;; <https://issues.guix.gnu.org/54304#11>.
|
||||||
(("#!/bin/sh")
|
(substitute* '("lib/mix/lib/mix/release.ex"
|
||||||
(string-append "#!" (search-input-file inputs "/bin/sh"))))
|
"lib/mix/lib/mix/tasks/release.init.ex")
|
||||||
(substitute* "bin/elixir"
|
(("#!/bin/sh")
|
||||||
(("ERTS_BIN=\n")
|
(string-append "#!" (search-input-file inputs "/bin/sh"))))
|
||||||
(string-append
|
(substitute* "bin/elixir"
|
||||||
"ERTS_BIN="
|
(("ERTS_BIN=\n")
|
||||||
;; Elixir Releases will prepend to ERTS_BIN the path of
|
(string-append
|
||||||
;; a copy of erl. We detect if a release is being generated
|
"ERTS_BIN="
|
||||||
;; by checking the initial ERTS_BIN value: if it's empty, we
|
;; Elixir Releases will prepend to ERTS_BIN the path of
|
||||||
;; are not in release mode and can point to the actual erl
|
;; a copy of erl. We detect if a release is being
|
||||||
;; binary in Guix store.
|
;; generated by checking the initial ERTS_BIN value: if
|
||||||
"\nif [ -z \"$ERTS_BIN\" ]; then ERTS_BIN="
|
;; it's empty, we are not in release mode and can point
|
||||||
(string-drop-right (search-input-file inputs "/bin/erl") 3)
|
;; to the actual erl binary in Guix store.
|
||||||
"; fi\n")))
|
"\nif [ -z \"$ERTS_BIN\" ]; then ERTS_BIN="
|
||||||
(substitute* "bin/mix"
|
(string-drop-right
|
||||||
(("#!/usr/bin/env elixir")
|
(search-input-file inputs "/bin/erl") 3)
|
||||||
(string-append "#!" #$output "/bin/elixir")))))
|
"; fi\n")))
|
||||||
(add-before 'build 'make-current
|
(substitute* "bin/mix"
|
||||||
;; The Elixir compiler checks whether or not to compile files by
|
(("#!/usr/bin/env elixir")
|
||||||
;; inspecting their timestamps. When the timestamp is equal to the
|
(string-append "#!" #$output "/bin/elixir")))))
|
||||||
;; epoch no compilation will be performed. Some tests fail when
|
(add-after 'replace-paths 'pre-install-source
|
||||||
;; files are older than Jan 1, 2000.
|
(lambda* (#:key outputs #:allow-other-keys)
|
||||||
(lambda _
|
(copy-recursively
|
||||||
(for-each (lambda (file)
|
"lib"
|
||||||
(let ((recent 1400000000))
|
(string-append (assoc-ref outputs "src") "/source/lib"))))
|
||||||
(utime file recent recent 0 0)))
|
;; Temporarily patch the compiler to place correct source
|
||||||
(find-files "." ".*"))))
|
;; locations into module info instead of build directory.
|
||||||
(add-before 'check 'set-home
|
(add-after 'pre-install-source 'patch-elixir-compiler
|
||||||
(lambda* (#:key inputs #:allow-other-keys)
|
(lambda* (#:key outputs #:allow-other-keys)
|
||||||
;; Some tests require access to a home directory.
|
(copy-recursively compiler-path compiler-path-orig)
|
||||||
(setenv "HOME" "/tmp")))
|
(let ((source (string-append "/tmp/guix-build-" #$name "-"
|
||||||
(delete 'configure)
|
#$version ".drv-0"))
|
||||||
(add-after 'install 'wrap-programs
|
(destination (assoc-ref outputs "src")))
|
||||||
(lambda* (#:key inputs outputs #:allow-other-keys)
|
(substitute* compiler-path
|
||||||
(let* ((out (assoc-ref outputs "out"))
|
(("source, Source")
|
||||||
(programs '("elixir" "elixirc" "iex")))
|
(string-append "source, string:replace(Source, \""
|
||||||
;; mix can be sourced as an elixir script by other elixir
|
source "\", \"" destination "\")"))))))
|
||||||
;; program, for example `iex -S mix`, so we should not wrap
|
(add-before 'build 'make-current
|
||||||
;; mix into shell script.
|
;; The Elixir compiler checks whether or not to compile files
|
||||||
(substitute* (string-append out "/bin/mix")
|
;; by inspecting their timestamps. When the timestamp is
|
||||||
(("Mix.start\\(\\)")
|
;; equal to the epoch no compilation will be performed. Some
|
||||||
(format #f "\
|
;; tests fail when files are older than Jan 1, 2000.
|
||||||
|
(lambda _
|
||||||
|
(for-each (lambda (file)
|
||||||
|
(let ((recent 1400000000))
|
||||||
|
(utime file recent recent 0 0)))
|
||||||
|
(find-files "." ".*"))))
|
||||||
|
;; Unpatch the compiler and recompile it.
|
||||||
|
(add-after 'build 'restore-and-recompile
|
||||||
|
(lambda _
|
||||||
|
(copy-recursively compiler-path-orig compiler-path)
|
||||||
|
(delete-file compiler-path-orig)
|
||||||
|
(invoke "make")))
|
||||||
|
(add-before 'check 'set-home
|
||||||
|
(lambda* (#:key inputs #:allow-other-keys)
|
||||||
|
;; Some tests require access to a home directory.
|
||||||
|
(setenv "HOME" "/tmp")))
|
||||||
|
(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 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\\(\\)")
|
||||||
|
(format #f "\
|
||||||
~~w[GUIX_ELIXIR_LIBS ERL_LIBS]
|
~~w[GUIX_ELIXIR_LIBS ERL_LIBS]
|
||||||
|> Enum.map(&System.get_env/1)
|
|> Enum.map(&System.get_env/1)
|
||||||
|> Enum.reject(&is_nil/1)
|
|> Enum.reject(&is_nil/1)
|
||||||
|
@ -118,18 +145,21 @@ (define-public elixir
|
||||||
|> case do \"\" -> :ok; erl_libs -> System.put_env(\"ERL_LIBS\", erl_libs) end
|
|> case do \"\" -> :ok; erl_libs -> System.put_env(\"ERL_LIBS\", erl_libs) end
|
||||||
System.put_env(\"MIX_REBAR3\", System.get_env(\"MIX_REBAR3\", \"~a\"))
|
System.put_env(\"MIX_REBAR3\", System.get_env(\"MIX_REBAR3\", \"~a\"))
|
||||||
Mix.start()"
|
Mix.start()"
|
||||||
(search-input-file inputs "/bin/rebar3"))))
|
(search-input-file inputs "/bin/rebar3"))))
|
||||||
(for-each (lambda (program)
|
(for-each
|
||||||
(wrap-program (string-append out "/bin/" program)
|
(lambda (program)
|
||||||
'("ERL_LIBS" prefix ("${GUIX_ELIXIR_LIBS}"))))
|
(wrap-program (string-append out "/bin/" program)
|
||||||
programs)))))))
|
'("ERL_LIBS" prefix ("${GUIX_ELIXIR_LIBS}"))))
|
||||||
(inputs (list erlang rebar3 git))
|
programs))))))))
|
||||||
|
(outputs '("out" "src"))
|
||||||
|
(inputs (list bash-minimal erlang rebar3 git))
|
||||||
(native-search-paths
|
(native-search-paths
|
||||||
(list (search-path-specification
|
(list (search-path-specification
|
||||||
(variable "GUIX_ELIXIR_LIBS")
|
(variable "GUIX_ELIXIR_LIBS")
|
||||||
(files (list (string-append "lib/elixir/" (version-major+minor version)))))))
|
(files (list (string-append "lib/elixir/" (version-major+minor
|
||||||
|
version)))))))
|
||||||
(home-page "https://elixir-lang.org/")
|
(home-page "https://elixir-lang.org/")
|
||||||
(synopsis "Elixir programming language")
|
(synopsis "Functional meta-programming aware language")
|
||||||
(description "Elixir is a dynamic, functional language used to build
|
(description "Elixir is a dynamic, functional language used to build
|
||||||
scalable and maintainable applications. Elixir leverages the Erlang VM, known
|
scalable and maintainable applications. Elixir leverages the Erlang VM, known
|
||||||
for running low-latency, distributed and fault-tolerant systems, while also
|
for running low-latency, distributed and fault-tolerant systems, while also
|
||||||
|
|
Loading…
Reference in a new issue