gnu-system.scm 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018 Ludovic Courtès <ludo@gnu.org>
  3. ;;; Copyright © 2017 Jan Nieuwenhuizen <janneke@gnu.org>
  4. ;;; Copyright © 2018 Clément Lassieur <clement@lassieur.org>
  5. ;;;
  6. ;;; This file is part of GNU Guix.
  7. ;;;
  8. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  9. ;;; under the terms of the GNU General Public License as published by
  10. ;;; the Free Software Foundation; either version 3 of the License, or (at
  11. ;;; your option) any later version.
  12. ;;;
  13. ;;; GNU Guix is distributed in the hope that it will be useful, but
  14. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  15. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. ;;; GNU General Public License for more details.
  17. ;;;
  18. ;;; You should have received a copy of the GNU General Public License
  19. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  20. ;;;
  21. ;;; This file defines build jobs for the Hydra continuation integration
  22. ;;; tool.
  23. ;;;
  24. (use-modules (guix inferior) (guix channels)
  25. (guix)
  26. (guix ui)
  27. (srfi srfi-1)
  28. (ice-9 match))
  29. ;; XXX: Debugging hack: since `hydra-eval-guile-jobs' redirects the output
  30. ;; port to the bit bucket, let us write to the error port instead.
  31. (setvbuf (current-error-port) _IOLBF)
  32. (set-current-output-port (current-error-port))
  33. (define (hydra-jobs store arguments)
  34. "Return a list of jobs where each job is a NAME/THUNK pair."
  35. (define checkout
  36. ;; Extract metadata about the 'guix' checkout. Its key in ARGUMENTS may
  37. ;; vary, so pick up the first one that's neither 'subset' nor 'systems'.
  38. (any (match-lambda
  39. ((key . value)
  40. (and (not (memq key '(systems subset)))
  41. value)))
  42. arguments))
  43. (define commit
  44. (assq-ref checkout 'revision))
  45. (define source
  46. (assq-ref checkout 'file-name))
  47. (define instance
  48. (checkout->channel-instance source #:commit commit))
  49. (define derivation
  50. ;; Compute the derivation of Guix for COMMIT.
  51. (run-with-store store
  52. (channel-instances->derivation (list instance))))
  53. (show-what-to-build store (list derivation))
  54. (build-derivations store (list derivation))
  55. ;; Open an inferior for the just-built Guix.
  56. (let ((inferior (open-inferior (derivation->output-path derivation))))
  57. (inferior-eval '(use-modules (gnu ci) (ice-9 match)) inferior)
  58. (map (match-lambda
  59. ((name . fields)
  60. ;; Hydra expects a thunk, so here it is.
  61. (cons name (lambda () fields))))
  62. (inferior-eval-with-store inferior store
  63. `(lambda (store)
  64. (map (match-lambda
  65. ((name . thunk)
  66. (cons name (thunk))))
  67. (hydra-jobs store ',arguments)))))))