channel.scm 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2019-2022 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 channel)
  19. #:use-module ((guix store) #:select (%store-monad store-lift))
  20. #:use-module ((guix gexp) #:select (lower-object))
  21. #:use-module (guix monads)
  22. #:use-module (guix channels)
  23. #:use-module (guix build-system)
  24. #:export (channel-build-system))
  25. ;;; Commentary:
  26. ;;;
  27. ;;; The "channel" build system lets you build Guix instances from channel
  28. ;;; specifications, similar to how 'guix time-machine' would do it, as regular
  29. ;;; packages.
  30. ;;;
  31. ;;; Code:
  32. (define latest-channel-instances*
  33. (store-lift latest-channel-instances))
  34. (define* (build-channels name inputs
  35. #:key source system commit
  36. (authenticate? #t)
  37. #:allow-other-keys)
  38. (mlet* %store-monad ((instances
  39. (cond ((channel-instance? source)
  40. (return (list source)))
  41. ((channel? source)
  42. (latest-channel-instances*
  43. (list source)
  44. #:authenticate? authenticate?))
  45. ((string? source)
  46. ;; If SOURCE is a store file name, as is the
  47. ;; case when called from (gnu ci), return it as
  48. ;; is.
  49. (return
  50. (list (checkout->channel-instance
  51. source #:commit commit))))
  52. (else
  53. (mlet %store-monad ((source
  54. (lower-object source)))
  55. (return
  56. (list (checkout->channel-instance
  57. source #:commit commit))))))))
  58. (channel-instances->derivation instances)))
  59. (define channel-build-system
  60. ;; Build system used to "convert" a channel instance to a package.
  61. (let ((lower (lambda* (name #:key system source commit (authenticate? #t)
  62. #:allow-other-keys)
  63. (bag
  64. (name name)
  65. (system system)
  66. (build build-channels)
  67. (arguments `(#:source ,source
  68. #:authenticate? ,authenticate?
  69. #:commit ,commit))))))
  70. (build-system (name 'channel)
  71. (description "Turn a channel instance into a package.")
  72. (lower lower))))