Start computing channel instance derivations for multiple systems

These aren't stored yet, but this is a start.
This commit is contained in:
Christopher Baines 2020-02-09 21:03:05 +00:00
parent beab4babac
commit 13b0ebe561

View file

@ -714,14 +714,14 @@ WHERE job_id = $1"
(build-derivations store (list derivation))))
(derivation->output-path derivation)))
(define (channel->derivation-file-name store channel)
(define (channel->derivation-file-names-by-system store channel)
(define use-container? (defined?
'open-inferior/container
(resolve-module '(guix inferior))))
(define inferior-code
(define (inferior-code channel-instance systems)
`(lambda (store)
(let ((instances
(let* ((instances
(list
(channel-instance
(channel (name ',(channel-name channel))
@ -730,12 +730,70 @@ WHERE job_id = $1"
(commit ,(channel-commit channel)))
,(channel-instance-commit channel-instance)
,(channel-instance-checkout channel-instance)))))
(map
(lambda (system)
(log-time
(simple-format
#f "computing the derivation-file-name for ~A"
system)
(lambda ()
(with-store store
((set-current-system system) store)
(let ((manifest
(catch #t
(lambda ()
((channel-instances->manifest instances) store))
(lambda (key . args)
(simple-format
(current-error-port)
"error: while computing manifest entry derivation for ~A\n"
system)
(simple-format
(current-error-port)
"error ~A: ~A\n" key args)
#f))))
`(,system
.
((manifest-entry-item
. ,(and manifest
(derivation-file-name
(manifest-entry-item
(first
(manifest-entries manifest))))))
(profile
. ,(catch #t
(lambda ()
(and manifest
(derivation-file-name
(run-with-store store
(mlet* %store-monad ((manifest (channel-instances->manifest
instances))
(derv (profile-derivation manifest)))
(mbegin %store-monad
(return (derivation-file-name derv))))))))
(profile-derivation
manifest
#:hooks %channel-profile-hooks)))))
(lambda (key . args)
(simple-format
(current-error-port)
"error: while computing profile derivation for ~A\n"
system)
(simple-format
(current-error-port)
"error ~A: ~A\n" key args)
#f))))))))))
(list ,@systems)))))
(let ((inferior
(if use-container?
(open-inferior/container
store
(guix-store-path store)
#:extra-shared-directories
'("/gnu/store")
#:extra-environment-variables
(list (string-append
"SSL_CERT_DIR=" (nss-certs-store-path store))))
(begin
(simple-format #t "debug: using open-inferior\n")
(open-inferior (guix-store-path store)
#:error-port (real-error-port))))))
(define (start-inferior-and-return-derivation-file-names)
;; /etc is only missing if open-inferior/container has been used
@ -756,38 +814,30 @@ WHERE job_id = $1"
(first
(latest-channel-instances store
(list channel)))))
(inferior-eval '(use-modules (guix channels)
(inferior-eval '(use-modules (srfi srfi-1)
(guix channels)
(guix grafts)
(guix profiles))
inferior)
(inferior-eval '(when (defined? '%graft?) (%graft? #f))
inferior)
(inferior-eval '(define channel-instance
(@@ (guix channels) channel-instance))
inferior)
(let ((result
(let* ((systems
(inferior-eval '(@ (guix packages) %supported-systems)
inferior))
(result
(inferior-eval-with-store
inferior
store
inferior-code)))
(inferior-code channel-instance systems))))
(close-inferior inferior)
result)))
(let ((inferior
(if use-container?
(open-inferior/container
store
(guix-store-path store)
#:extra-shared-directories
'("/gnu/store")
#:extra-environment-variables
(list (string-append
"SSL_CERT_DIR=" (nss-certs-store-path store))))
(begin
(simple-format #t "debug: using open-inferior\n")
(open-inferior (guix-store-path store)
#:error-port (real-error-port))))))
(catch
#t
(lambda ()
@ -797,14 +847,14 @@ WHERE job_id = $1"
(display (backtrace) (current-error-port))
(display "\n" (current-error-port))
(simple-format (current-error-port)
"error: channel->derivation-file-name: ~A: ~A\n"
"error: channel->derivation-file-names-by-system: ~A: ~A\n"
key parameters))))
(lambda args
(close-inferior inferior)
#f))))
(define (channel->manifest-store-item conn store channel)
(let* ((manifest-store-item-derivation-file-name
(let* ((derivation-file-names-by-system
(log-time
"computing the channel derivation"
(lambda ()
@ -814,12 +864,20 @@ WHERE job_id = $1"
conn
'channel->manifest-store-item
(lambda ()
(channel->derivation-file-name store channel))))))
(channel->derivation-file-names-by-system store channel))))))
(derivation
(read-derivation-from-file manifest-store-item-derivation-file-name)))
(read-derivation-from-file (assoc-ref
(assoc-ref derivation-file-names-by-system
(%current-system))
'profile))))
(for-each
(match-lambda
((system . derivation-file-name)
(simple-format (current-error-port)
"debug: channel dervation: ~A\n"
manifest-store-item-derivation-file-name)
"debug: ~A: channel dervation: ~A\n"
system
derivation-file-name)))
derivation-file-names-by-system)
(log-time
"building the channel derivation"
(lambda ()