trivial.scm 3.9 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 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. #:modules modules
  62. #:allowed-references allowed-references
  63. #:guile-for-build guile)))
  64. (define* (trivial-cross-build name
  65. #:key
  66. target
  67. source build-inputs target-inputs host-inputs
  68. outputs guile system builder (modules '())
  69. search-paths native-search-paths
  70. allowed-references)
  71. "Run build expression BUILDER, an expression, for SYSTEM. SOURCE is
  72. ignored."
  73. (mlet %store-monad ((guile (package->derivation (or guile (default-guile))
  74. system #:graft? #f))
  75. (builder -> (if (pair? builder)
  76. (sexp->gexp builder)
  77. builder)))
  78. (gexp->derivation name (with-build-variables
  79. (append build-inputs target-inputs)
  80. outputs
  81. builder)
  82. #:system system
  83. #:target target
  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)))