copy.scm 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2019 Julien Lepiller <julien@lepiller.eu>
  3. ;;; Copyright © 2020 Pierre Neidhardt <mail@ambrevar.xyz>
  4. ;;; Copyright © 2021, 2022 Ludovic Courtès <ludo@gnu.org>
  5. ;;; Copyright © 2023 Jonathan Brielmaier <jonathan.brielmaier@web.de>
  6. ;;;
  7. ;;; This file is part of GNU Guix.
  8. ;;;
  9. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  10. ;;; under the terms of the GNU General Public License as published by
  11. ;;; the Free Software Foundation; either version 3 of the License, or (at
  12. ;;; your option) any later version.
  13. ;;;
  14. ;;; GNU Guix is distributed in the hope that it will be useful, but
  15. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  16. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. ;;; GNU General Public License for more details.
  18. ;;;
  19. ;;; You should have received a copy of the GNU General Public License
  20. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  21. (define-module (guix build-system copy)
  22. #:use-module (guix store)
  23. #:use-module (guix utils)
  24. #:use-module (guix gexp)
  25. #:use-module (guix monads)
  26. #:use-module (guix search-paths)
  27. #:use-module (guix build-system)
  28. #:use-module (guix build-system gnu)
  29. #:use-module (guix packages)
  30. #:use-module (srfi srfi-1)
  31. #:export (%copy-build-system-modules
  32. default-glibc
  33. lower
  34. copy-build
  35. copy-build-system))
  36. ;; Commentary:
  37. ;;
  38. ;; Standard build procedure for simple packages that don't require much
  39. ;; compilation, mostly just copying files around. This is implemented as an
  40. ;; extension of `gnu-build-system'.
  41. ;;
  42. ;; Code:
  43. (define %copy-build-system-modules
  44. ;; Build-side modules imported by default.
  45. `((guix build copy-build-system)
  46. ,@%gnu-build-system-modules))
  47. (define (default-glibc)
  48. "Return the default glibc package."
  49. ;; Do not use `@' to avoid introducing circular dependencies.
  50. (let ((module (resolve-interface '(gnu packages base))))
  51. (module-ref module 'glibc)))
  52. (define* (lower name
  53. #:key source inputs native-inputs outputs system target
  54. (glibc (default-glibc))
  55. #:allow-other-keys
  56. #:rest arguments)
  57. "Return a bag for NAME from the given arguments."
  58. (define private-keywords
  59. '(#:target #:inputs #:native-inputs))
  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 native-inputs)
  70. (outputs outputs)
  71. (build copy-build)
  72. (arguments (strip-keyword-arguments private-keywords arguments))))
  73. (define* (copy-build name inputs
  74. #:key
  75. guile source
  76. (outputs '("out"))
  77. (install-plan ''(("." "./")))
  78. (search-paths '())
  79. (out-of-source? #t)
  80. (tests? #t)
  81. (validate-runpath? #t)
  82. (patch-shebangs? #t)
  83. (strip-binaries? #t)
  84. (strip-flags %strip-flags)
  85. (strip-directories %strip-directories)
  86. (phases '(@ (guix build copy-build-system)
  87. %standard-phases))
  88. (system (%current-system))
  89. (target #f)
  90. (substitutable? #t)
  91. (imported-modules %copy-build-system-modules)
  92. (modules '((guix build copy-build-system)
  93. (guix build utils))))
  94. "Build SOURCE using INSTALL-PLAN, and with INPUTS."
  95. (define builder
  96. (with-imported-modules imported-modules
  97. #~(begin
  98. (use-modules #$@modules)
  99. #$(with-build-variables inputs outputs
  100. #~(copy-build #:source #+source
  101. #:system #$system
  102. #:outputs %outputs
  103. #:inputs %build-inputs
  104. #:install-plan #$(if (pair? install-plan)
  105. (sexp->gexp install-plan)
  106. install-plan)
  107. #:search-paths '#$(sexp->gexp
  108. (map search-path-specification->sexp
  109. search-paths))
  110. #:phases #$(if (pair? phases)
  111. (sexp->gexp phases)
  112. phases)
  113. #:out-of-source? #$out-of-source?
  114. #:tests? #$tests?
  115. #:validate-runpath? #$validate-runpath?
  116. #:patch-shebangs? #$patch-shebangs?
  117. #:strip-binaries? #$strip-binaries?
  118. #:strip-flags #$strip-flags
  119. #:strip-directories #$strip-directories)))))
  120. (mlet %store-monad ((guile (package->derivation (or guile (default-guile))
  121. system #:graft? #f)))
  122. (gexp->derivation name builder
  123. #:system system
  124. #:target #f
  125. #:substitutable? substitutable?
  126. #:graft? #f
  127. #:guile-for-build guile)))
  128. (define copy-build-system
  129. (build-system
  130. (name 'copy)
  131. (description "The standard copy build system")
  132. (lower lower)))
  133. ;;; copy.scm ends here