trivial.scm 4.0 KB

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