font.scm 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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 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 derivations)
  25. #:use-module (guix search-paths)
  26. #:use-module (guix build-system)
  27. #:use-module (guix build-system gnu)
  28. #:use-module (ice-9 match)
  29. #:export (%font-build-system-modules
  30. font-build
  31. font-build-system))
  32. ;; Commentary:
  33. ;;
  34. ;; Standard build procedure for fonts. This is implemented as an extension of
  35. ;; 'gnu-build-system'.
  36. ;;
  37. ;; Code:
  38. (define %font-build-system-modules
  39. ;; Build-side modules imported by default.
  40. `((guix build font-build-system)
  41. ,@%gnu-build-system-modules))
  42. (define* (lower name
  43. #:key source inputs native-inputs outputs system target
  44. #:allow-other-keys
  45. #:rest arguments)
  46. "Return a bag for NAME."
  47. (define private-keywords
  48. '(#:target #:inputs #:native-inputs))
  49. (bag
  50. (name name)
  51. (system system)
  52. (host-inputs `(,@(if source
  53. `(("source" ,source))
  54. '())
  55. ,@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. (build-inputs native-inputs)
  66. (outputs outputs)
  67. (build font-build)
  68. (arguments (strip-keyword-arguments private-keywords arguments))))
  69. (define* (font-build name inputs
  70. #:key source
  71. (tests? #t)
  72. (test-target "test")
  73. (configure-flags ''())
  74. (phases '%standard-phases)
  75. (outputs '("out"))
  76. (search-paths '())
  77. (system (%current-system))
  78. (guile #f)
  79. (imported-modules %font-build-system-modules)
  80. (modules '((guix build font-build-system)
  81. (guix build utils))))
  82. "Build SOURCE with INPUTS."
  83. (define builder
  84. (with-imported-modules imported-modules
  85. #~(begin
  86. (use-modules #$@modules)
  87. #$(with-build-variables inputs outputs
  88. #~(font-build #:name #$name
  89. #:source #+source
  90. #:configure-flags #$configure-flags
  91. #:system #$system
  92. #:test-target #$test-target
  93. #:tests? #$tests?
  94. #:phases #$(if (pair? phases)
  95. (sexp->gexp phases)
  96. phases)
  97. #:outputs %outputs
  98. #:search-paths '#$(sexp->gexp
  99. (map search-path-specification->sexp
  100. search-paths))
  101. #:inputs %build-inputs)))))
  102. (mlet %store-monad ((guile (package->derivation (or guile (default-guile))
  103. system #:graft? #f)))
  104. (gexp->derivation name builder
  105. #:system system
  106. #:target #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