font.scm 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2017, 2022 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 gexp)
  20. #:use-module (guix store)
  21. #:use-module (guix monads)
  22. #:use-module (guix utils)
  23. #:use-module (guix packages)
  24. #:use-module (guix search-paths)
  25. #:use-module (guix build-system)
  26. #:use-module (guix build-system gnu)
  27. #:use-module (ice-9 match)
  28. #:export (%font-build-system-modules
  29. font-build
  30. font-build-system))
  31. ;; Commentary:
  32. ;;
  33. ;; Standard build procedure for fonts. This is implemented as an extension of
  34. ;; 'gnu-build-system'.
  35. ;;
  36. ;; Code:
  37. (define %font-build-system-modules
  38. ;; Build-side modules imported by default.
  39. `((guix build font-build-system)
  40. ,@%gnu-build-system-modules))
  41. (define* (lower name
  42. #:key source inputs native-inputs outputs system target
  43. #:allow-other-keys
  44. #:rest arguments)
  45. "Return a bag for NAME."
  46. (define private-keywords
  47. '(#:target #:inputs #:native-inputs))
  48. (bag
  49. (name name)
  50. (system system)
  51. (host-inputs inputs)
  52. (build-inputs `(,@(if source
  53. `(("source" ,source))
  54. '())
  55. ,@native-inputs
  56. ,(list "tar" (module-ref (resolve-interface '(gnu packages base)) 'tar))
  57. ,@(let ((compression (resolve-interface '(gnu packages compression))))
  58. (map (match-lambda
  59. ((name package)
  60. (list name (module-ref compression package))))
  61. `(("gzip" gzip)
  62. ("bzip2" bzip2)
  63. ("unzip" unzip)
  64. ("xz" xz))))))
  65. (outputs outputs)
  66. (build font-build)
  67. (arguments (strip-keyword-arguments private-keywords arguments))))
  68. (define* (font-build name inputs
  69. #:key source
  70. (tests? #t)
  71. (test-target "test")
  72. (configure-flags ''())
  73. (phases '%standard-phases)
  74. (outputs '("out"))
  75. (search-paths '())
  76. (system (%current-system))
  77. (guile #f)
  78. (imported-modules %font-build-system-modules)
  79. (modules '((guix build font-build-system)
  80. (guix build utils))))
  81. "Build SOURCE with INPUTS."
  82. (define builder
  83. (with-imported-modules imported-modules
  84. #~(begin
  85. (use-modules #$@modules)
  86. #$(with-build-variables inputs outputs
  87. #~(font-build #:name #$name
  88. #:source #+source
  89. #:configure-flags #$configure-flags
  90. #:system #$system
  91. #:test-target #$test-target
  92. #:tests? #$tests?
  93. #:phases #$(if (pair? phases)
  94. (sexp->gexp phases)
  95. phases)
  96. #:outputs %outputs
  97. #:search-paths '#$(sexp->gexp
  98. (map search-path-specification->sexp
  99. search-paths))
  100. #:inputs %build-inputs)))))
  101. (mlet %store-monad ((guile (package->derivation (or guile (default-guile))
  102. system #:graft? #f)))
  103. (gexp->derivation name builder
  104. #:system system
  105. #:target #f
  106. #:graft? #f
  107. #:guile-for-build guile)))
  108. (define font-build-system
  109. (build-system
  110. (name 'font)
  111. (description "The build system for font packages")
  112. (lower lower)))
  113. ;;; font.scm ends here