gnu-system.scm 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2020 Ludovic Courtès <ludo@gnu.org>
  3. ;;; Copyright © 2017 Jan Nieuwenhuizen <janneke@gnu.org>
  4. ;;; Copyright © 2018, 2019 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) 'line)
  32. (set-current-output-port (current-error-port))
  33. (define (find-current-checkout arguments)
  34. "Find the first checkout of ARGUMENTS that provided the current file.
  35. Return #f if no such checkout is found."
  36. (let ((current-root
  37. (canonicalize-path
  38. (string-append (dirname (current-filename)) "/../.."))))
  39. (find (lambda (argument)
  40. (and=> (assq-ref argument 'file-name)
  41. (lambda (name)
  42. (string=? name current-root)))) arguments)))
  43. (define (hydra-jobs store arguments)
  44. "Return a list of jobs where each job is a NAME/THUNK pair."
  45. (define checkout
  46. (find-current-checkout arguments))
  47. (define commit
  48. (assq-ref checkout 'revision))
  49. (define source
  50. (assq-ref checkout 'file-name))
  51. (define instance
  52. (checkout->channel-instance source #:commit commit))
  53. (define derivation
  54. ;; Compute the derivation of Guix for COMMIT.
  55. (run-with-store store
  56. (channel-instances->derivation (list instance))))
  57. ;; TODO: Remove 'show-what-to-build' call when Cuirass' 'evaluate' scripts
  58. ;; uses 'with-build-handler'.
  59. (show-what-to-build store (list derivation))
  60. (build-derivations store (list derivation))
  61. ;; Open an inferior for the just-built Guix.
  62. (let ((inferior (open-inferior (derivation->output-path derivation))))
  63. (inferior-eval '(use-modules (gnu ci) (ice-9 match)) inferior)
  64. (map (match-lambda
  65. ((name . fields)
  66. ;; Hydra expects a thunk, so here it is.
  67. (cons name (lambda () fields))))
  68. (inferior-eval-with-store
  69. inferior store
  70. `(lambda (store)
  71. (map (match-lambda
  72. ((name . thunk)
  73. (cons name (thunk))))
  74. (hydra-jobs store '((superior-guix-checkout . ,checkout)
  75. ,@arguments))))))))