emacs.scm 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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 gexp)
  26. #:use-module (guix monads)
  27. #:use-module (guix search-paths)
  28. #:use-module (guix build-system)
  29. #:use-module (guix build-system gnu)
  30. #:use-module (ice-9 match)
  31. #:use-module (srfi srfi-26)
  32. #:export (%emacs-build-system-modules
  33. emacs-build
  34. emacs-build-system)
  35. #:re-export (%default-include ;for convenience
  36. %default-exclude))
  37. ;; Commentary:
  38. ;;
  39. ;; Standard build procedure for Emacs packages. This is implemented as an
  40. ;; extension of 'gnu-build-system'.
  41. ;;
  42. ;; Code:
  43. (define %emacs-build-system-modules
  44. ;; Build-side modules imported by default.
  45. `((guix build emacs-build-system)
  46. (guix build emacs-utils)
  47. ,@%gnu-build-system-modules))
  48. (define (default-emacs)
  49. "Return the default Emacs package."
  50. ;; Lazily resolve the binding to avoid a circular dependency.
  51. (let ((emacs-mod (resolve-interface '(gnu packages emacs))))
  52. (module-ref emacs-mod 'emacs-minimal)))
  53. (define* (lower name
  54. #:key source inputs native-inputs outputs system target
  55. (emacs (default-emacs))
  56. #:allow-other-keys
  57. #:rest arguments)
  58. "Return a bag for NAME."
  59. (define private-keywords
  60. '(#:target #:emacs #:inputs #:native-inputs))
  61. (and (not target) ;XXX: no cross-compilation
  62. (bag
  63. (name name)
  64. (system system)
  65. (host-inputs `(,@(if source
  66. `(("source" ,source))
  67. '())
  68. ,@inputs
  69. ;; Keep the standard inputs of 'gnu-build-system'.
  70. ,@(standard-packages)))
  71. (build-inputs `(("emacs" ,emacs)
  72. ,@native-inputs))
  73. (outputs outputs)
  74. (build emacs-build)
  75. (arguments (strip-keyword-arguments private-keywords arguments)))))
  76. (define* (emacs-build name inputs
  77. #:key source
  78. (tests? #f)
  79. (parallel-tests? #t)
  80. (test-command ''("make" "check"))
  81. (phases '%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. (with-imported-modules imported-modules
  95. #~(begin
  96. (use-modules #$@(sexp->gexp modules))
  97. (emacs-build #:name #$name
  98. #:source #+source
  99. #:system #$system
  100. #:test-command #$test-command
  101. #:tests? #$tests?
  102. #:parallel-tests? #$parallel-tests?
  103. #:phases #$phases
  104. #:outputs #$(outputs->gexp outputs)
  105. #:include #$include
  106. #:exclude #$exclude
  107. #:search-paths '#$(sexp->gexp
  108. (map search-path-specification->sexp
  109. search-paths))
  110. #:inputs #$(input-tuples->gexp inputs)))))
  111. (mlet %store-monad ((guile (package->derivation (or guile (default-guile))
  112. system #:graft? #f)))
  113. (gexp->derivation name builder
  114. #:system system
  115. #:guile-for-build guile)))
  116. (define emacs-build-system
  117. (build-system
  118. (name 'emacs)
  119. (description "The build system for Emacs packages")
  120. (lower lower)))
  121. ;;; emacs.scm ends here