font.scm 4.9 KB

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