emacs.scm 4.9 KB

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