elixir.scm 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2016 Leo Famulari <leo@famulari.name>
  3. ;;; Copyright © 2016, 2017 Pjotr Prins <pjotr.guix@thebird.nl>
  4. ;;; Copyright © 2016 Ricardo Wurmus <rekado@elephly.net>
  5. ;;; Copyright © 2017 nee <nee.git@cock.li>
  6. ;;; Copyright © 2018, 2019, 2021 Tobias Geerinckx-Rice <me@tobias.gr>
  7. ;;; Copyright © 2018 Nikita <nikita@n0.is>
  8. ;;; Copyright © 2021 Oskar Köök <oskar@maatriks.ee>
  9. ;;; Copyright © 2021 Cees de Groot <cg@evrl.com>
  10. ;;;
  11. ;;; This file is part of GNU Guix.
  12. ;;;
  13. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  14. ;;; under the terms of the GNU General Public License as published by
  15. ;;; the Free Software Foundation; either version 3 of the License, or (at
  16. ;;; your option) any later version.
  17. ;;;
  18. ;;; GNU Guix is distributed in the hope that it will be useful, but
  19. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  20. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. ;;; GNU General Public License for more details.
  22. ;;;
  23. ;;; You should have received a copy of the GNU General Public License
  24. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  25. (define-module (gnu packages elixir)
  26. #:use-module ((guix licenses) #:prefix license:)
  27. #:use-module (guix build-system gnu)
  28. #:use-module (guix git-download)
  29. #:use-module (guix packages)
  30. #:use-module (gnu packages)
  31. #:use-module (gnu packages erlang)
  32. #:use-module (gnu packages version-control))
  33. (define-public elixir
  34. (package
  35. (name "elixir")
  36. (version "1.12.0")
  37. (source
  38. (origin
  39. (method git-fetch)
  40. (uri (git-reference
  41. (url "https://github.com/elixir-lang/elixir")
  42. (commit (string-append "v" version))))
  43. (file-name (git-file-name name version))
  44. (sha256
  45. (base32 "0nx0ajbpib0hxpxz33p1kr3rqgvf35vkx91sh427qcjqy7964z16"))
  46. (patches (search-patches "elixir-path-length.patch"))))
  47. (build-system gnu-build-system)
  48. (arguments
  49. `(#:test-target "test"
  50. #:parallel-tests? #f ;see <https://debbugs.gnu.org/cgi/bugreport.cgi?bug=32171#23>
  51. #:make-flags (list (string-append "PREFIX="
  52. (assoc-ref %outputs "out")))
  53. #:phases
  54. (modify-phases %standard-phases
  55. (add-after 'unpack 'make-git-checkout-writable
  56. (lambda _
  57. (for-each make-file-writable (find-files "."))
  58. #t))
  59. (add-after 'make-git-checkout-writable 'replace-paths
  60. (lambda* (#:key inputs outputs #:allow-other-keys)
  61. (let ((out (assoc-ref outputs "out")))
  62. (substitute* '("lib/elixir/lib/system.ex"
  63. "lib/mix/lib/mix/scm/git.ex")
  64. (("(cmd\\(['\"])git" _ prefix)
  65. (string-append prefix (which "git"))))
  66. (substitute* '("lib/mix/lib/mix/release.ex"
  67. "lib/mix/lib/mix/tasks/release.init.ex")
  68. (("#!/bin/sh")
  69. (string-append "#!" (which "sh"))))
  70. (substitute* "bin/elixir"
  71. (("ERTS_BIN=")
  72. (string-append
  73. "ERTS_BIN="
  74. ;; Elixir Releases will prepend to ERTS_BIN the path of a copy of erl.
  75. ;; We detect if a release is being generated by checking the initial ERTS_BIN
  76. ;; value: if it's empty, we are not in release mode and can point to the actual
  77. ;; erl binary in Guix store.
  78. "\nif [ -z \"$ERTS_BIN\" ]; then ERTS_BIN="
  79. (string-drop-right (which "erl") 3)
  80. "; fi")))
  81. (substitute* "bin/mix"
  82. (("#!/usr/bin/env elixir")
  83. (string-append "#!" out "/bin/elixir"))))
  84. #t))
  85. (add-before 'build 'make-current
  86. ;; The Elixir compiler checks whether or not to compile files by
  87. ;; inspecting their timestamps. When the timestamp is equal to the
  88. ;; epoch no compilation will be performed. Some tests fail when
  89. ;; files are older than Jan 1, 2000.
  90. (lambda _
  91. (for-each (lambda (file)
  92. (let ((recent 1400000000))
  93. (utime file recent recent 0 0)))
  94. (find-files "." ".*"))
  95. #t))
  96. (add-before 'check 'set-home
  97. (lambda* (#:key inputs #:allow-other-keys)
  98. ;; Some tests require access to a home directory.
  99. (setenv "HOME" "/tmp")
  100. #t))
  101. (delete 'configure))))
  102. (inputs
  103. `(("erlang" ,erlang)
  104. ("git" ,git)))
  105. (home-page "https://elixir-lang.org/")
  106. (synopsis "Elixir programming language")
  107. (description "Elixir is a dynamic, functional language used to build
  108. scalable and maintainable applications. Elixir leverages the Erlang VM, known
  109. for running low-latency, distributed and fault-tolerant systems, while also
  110. being successfully used in web development and the embedded software domain.")
  111. (license license:asl2.0)))