guix-modular.scm 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2017 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. ;;;
  19. ;;; This file defines a continuous integration job to build the same modular
  20. ;;; Guix as 'guix pull', which is defined in (guix self).
  21. ;;;
  22. ;; Attempt to use our very own Guix modules.
  23. (eval-when (compile load eval)
  24. ;; Ignore any available .go, and force recompilation. This is because our
  25. ;; checkout in the store has mtime set to the epoch, and thus .go files look
  26. ;; newer, even though they may not correspond.
  27. (set! %fresh-auto-compile #t)
  28. (and=> (assoc-ref (current-source-location) 'filename)
  29. (lambda (file)
  30. (let ((dir (canonicalize-path
  31. (string-append (dirname file) "/../.."))))
  32. (format (current-error-port) "prepending ~s to the load path~%"
  33. dir)
  34. (set! %load-path (cons dir %load-path))))))
  35. (use-modules (guix store)
  36. (guix config)
  37. (guix utils)
  38. (guix grafts)
  39. ((guix packages) #:select (%hydra-supported-systems))
  40. (guix derivations)
  41. (guix monads)
  42. (guix gexp)
  43. (guix self)
  44. ((guix licenses) #:prefix license:)
  45. (srfi srfi-1)
  46. (srfi srfi-26)
  47. (ice-9 match))
  48. ;; XXX: Debugging hack: since `hydra-eval-guile-jobs' redirects the output
  49. ;; port to the bit bucket, let us write to the error port instead.
  50. (setvbuf (current-error-port) _IOLBF)
  51. (set-current-output-port (current-error-port))
  52. (define* (build-job store source version system)
  53. "Return a Hydra job a list building the modular Guix derivation from SOURCE
  54. for SYSTEM. Use VERSION as the version identifier."
  55. (lambda ()
  56. `((derivation . ,(derivation-file-name
  57. (parameterize ((%graft? #f))
  58. (run-with-store store
  59. (lower-object (compiled-guix source
  60. #:version version))))))
  61. (description . "Modular Guix")
  62. (long-description
  63. . "This is the modular Guix package as produced by 'guix pull'.")
  64. (license . ,license:gpl3+)
  65. (home-page . ,%guix-home-page-url)
  66. (maintainers . (,%guix-bug-report-address)))))
  67. (define (hydra-jobs store arguments)
  68. "Return Hydra jobs."
  69. (define systems
  70. (match (filter-map (match-lambda
  71. (('system . value) value)
  72. (_ #f))
  73. arguments)
  74. ((lst ..1)
  75. lst)
  76. (_
  77. (list (%current-system)))))
  78. (define guix-checkout
  79. (assq-ref arguments 'guix))
  80. (define version
  81. (or (assq-ref guix-checkout 'revision)
  82. "0.unknown"))
  83. (let ((file (assq-ref guix-checkout 'file-name)))
  84. (format (current-error-port) "using checkout ~s (~s)~%"
  85. guix-checkout file)
  86. (map (lambda (system)
  87. (let ((name (string->symbol
  88. (string-append "guix." system))))
  89. `(,name
  90. . ,(build-job store file version system))))
  91. %hydra-supported-systems)))