emacs.scm 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2015 Federico Beffa <beffa@fbengineering.ch>
  3. ;;; Copyright © 2020 Morgan Smith <Morgan.J.Smith@outlook.com>
  4. ;;;
  5. ;;; This file is part of GNU Guix.
  6. ;;;
  7. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  8. ;;; under the terms of the GNU General Public License as published by
  9. ;;; the Free Software Foundation; either version 3 of the License, or (at
  10. ;;; your option) any later version.
  11. ;;;
  12. ;;; GNU Guix is distributed in the hope that it will be useful, but
  13. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  14. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. ;;; GNU General Public License for more details.
  16. ;;;
  17. ;;; You should have received a copy of the GNU General Public License
  18. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  19. (define-module (guix build-system emacs)
  20. #:use-module ((guix build emacs-build-system)
  21. #:select (%default-include %default-exclude))
  22. #:use-module (guix store)
  23. #:use-module (guix utils)
  24. #:use-module (guix packages)
  25. #:use-module (guix derivations)
  26. #:use-module (guix search-paths)
  27. #:use-module (guix build-system)
  28. #:use-module (guix build-system gnu)
  29. #:use-module (ice-9 match)
  30. #:use-module (srfi srfi-26)
  31. #:export (%emacs-build-system-modules
  32. emacs-build
  33. emacs-build-system)
  34. #:re-export (%default-include ;for convenience
  35. %default-exclude))
  36. ;; Commentary:
  37. ;;
  38. ;; Standard build procedure for Emacs packages. This is implemented as an
  39. ;; extension of 'gnu-build-system'.
  40. ;;
  41. ;; Code:
  42. (define %emacs-build-system-modules
  43. ;; Build-side modules imported by default.
  44. `((guix build emacs-build-system)
  45. (guix build emacs-utils)
  46. ,@%gnu-build-system-modules))
  47. (define (default-emacs)
  48. "Return the default Emacs package."
  49. ;; Lazily resolve the binding to avoid a circular dependency.
  50. (let ((emacs-mod (resolve-interface '(gnu packages emacs))))
  51. (module-ref emacs-mod 'emacs-minimal)))
  52. (define* (lower name
  53. #:key source inputs native-inputs outputs system target
  54. (emacs (default-emacs))
  55. #:allow-other-keys
  56. #:rest arguments)
  57. "Return a bag for NAME."
  58. (define private-keywords
  59. '(#:target #:emacs #:inputs #:native-inputs))
  60. (and (not target) ;XXX: no cross-compilation
  61. (bag
  62. (name name)
  63. (system system)
  64. (host-inputs `(,@(if source
  65. `(("source" ,source))
  66. '())
  67. ,@inputs
  68. ;; Keep the standard inputs of 'gnu-build-system'.
  69. ,@(standard-packages)))
  70. (build-inputs `(("emacs" ,emacs)
  71. ,@native-inputs))
  72. (outputs outputs)
  73. (build emacs-build)
  74. (arguments (strip-keyword-arguments private-keywords arguments)))))
  75. (define* (emacs-build store name inputs
  76. #:key source
  77. (tests? #f)
  78. (parallel-tests? #t)
  79. (test-command ''("make" "check"))
  80. (phases '(@ (guix build emacs-build-system)
  81. %standard-phases))
  82. (outputs '("out"))
  83. (include (quote %default-include))
  84. (exclude (quote %default-exclude))
  85. (search-paths '())
  86. (system (%current-system))
  87. (guile #f)
  88. (imported-modules %emacs-build-system-modules)
  89. (modules '((guix build emacs-build-system)
  90. (guix build utils)
  91. (guix build emacs-utils))))
  92. "Build SOURCE using EMACS, and with INPUTS."
  93. (define builder
  94. `(begin
  95. (use-modules ,@modules)
  96. (emacs-build #:name ,name
  97. #:source ,(match (assoc-ref inputs "source")
  98. (((? derivation? source))
  99. (derivation->output-path source))
  100. ((source)
  101. source)
  102. (source
  103. source))
  104. #:system ,system
  105. #:test-command ,test-command
  106. #:tests? ,tests?
  107. #:parallel-tests? ,parallel-tests?
  108. #:phases ,phases
  109. #:outputs %outputs
  110. #:include ,include
  111. #:exclude ,exclude
  112. #:search-paths ',(map search-path-specification->sexp
  113. search-paths)
  114. #:inputs %build-inputs)))
  115. (define guile-for-build
  116. (match guile
  117. ((? package?)
  118. (package-derivation store guile system #:graft? #f))
  119. (#f ; the default
  120. (let* ((distro (resolve-interface '(gnu packages commencement)))
  121. (guile (module-ref distro 'guile-final)))
  122. (package-derivation store guile system #:graft? #f)))))
  123. (build-expression->derivation store name builder
  124. #:inputs inputs
  125. #:system system
  126. #:modules imported-modules
  127. #:outputs outputs
  128. #:guile-for-build guile-for-build))
  129. (define emacs-build-system
  130. (build-system
  131. (name 'emacs)
  132. (description "The build system for Emacs packages")
  133. (lower lower)))
  134. ;;; emacs.scm ends here