trivial.scm 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2012, 2013, 2014, 2015, 2018, 2021 Ludovic Courtès <ludo@gnu.org>
  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 trivial)
  19. #:use-module (guix store)
  20. #:use-module (guix utils)
  21. #:use-module (guix gexp)
  22. #:use-module (guix monads)
  23. #:use-module (guix packages)
  24. #:use-module (guix build-system)
  25. #:use-module (ice-9 match)
  26. #:export (trivial-build-system))
  27. (define* (lower name
  28. #:key source inputs native-inputs outputs system target
  29. guile builder (modules '()) allowed-references)
  30. "Return a bag for NAME."
  31. (bag
  32. (name name)
  33. (system system)
  34. (target target)
  35. (host-inputs `(,@(if source
  36. `(("source" ,source))
  37. '())
  38. ,@inputs))
  39. (build-inputs native-inputs)
  40. (outputs outputs)
  41. (build (if target trivial-cross-build trivial-build))
  42. (arguments `(#:guile ,guile
  43. #:builder ,builder
  44. #:modules ,modules
  45. #:allowed-references ,allowed-references))))
  46. (define* (trivial-build name inputs
  47. #:key
  48. outputs guile
  49. system builder (modules '())
  50. search-paths allowed-references)
  51. "Run build expression BUILDER, an expression, for SYSTEM. SOURCE is
  52. ignored."
  53. (mlet %store-monad ((guile (package->derivation (or guile (default-guile))
  54. system #:graft? #f))
  55. (builder -> (if (pair? builder)
  56. (sexp->gexp builder)
  57. builder)))
  58. (gexp->derivation name (with-build-variables inputs outputs builder)
  59. #:system system
  60. #:target #f
  61. #:graft? #f
  62. #:modules modules
  63. #:allowed-references allowed-references
  64. #:guile-for-build guile)))
  65. (define* (trivial-cross-build name
  66. #:key
  67. target
  68. source build-inputs target-inputs host-inputs
  69. outputs guile system builder (modules '())
  70. search-paths native-search-paths
  71. allowed-references)
  72. "Run build expression BUILDER, an expression, for SYSTEM. SOURCE is
  73. ignored."
  74. (mlet %store-monad ((guile (package->derivation (or guile (default-guile))
  75. system #:graft? #f))
  76. (builder -> (if (pair? builder)
  77. (sexp->gexp builder)
  78. builder)))
  79. (gexp->derivation name (with-build-variables
  80. (append build-inputs target-inputs host-inputs)
  81. outputs
  82. builder)
  83. #:system system
  84. #:target target
  85. #:graft? #f
  86. #:modules modules
  87. #:allowed-references allowed-references
  88. #:guile-for-build guile)))
  89. (define trivial-build-system
  90. (build-system
  91. (name 'trivial)
  92. (description
  93. "Trivial build system, to run arbitrary Scheme build expressions")
  94. (lower lower)))