mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-11-15 03:15:09 -05:00
environment: Do not connect to the daemon when '--profile' is used.
This further speeds up the 'guix environment -p PROFILE' case. * guix/scripts/environment.scm (guix-environment*)[store-needed?]: New variable. [with-store/maybe]: New macro. Use it instead of 'with-store', and remove 'with-build-handler' form.
This commit is contained in:
parent
648a6eb03f
commit
99499a2037
1 changed files with 93 additions and 76 deletions
|
@ -691,6 +691,26 @@ (define (guix-environment* opts)
|
||||||
(mappings (pick-all opts 'file-system-mapping))
|
(mappings (pick-all opts 'file-system-mapping))
|
||||||
(white-list (pick-all opts 'inherit-regexp)))
|
(white-list (pick-all opts 'inherit-regexp)))
|
||||||
|
|
||||||
|
(define store-needed?
|
||||||
|
;; Whether connecting to the daemon is needed.
|
||||||
|
(or container? (not profile)))
|
||||||
|
|
||||||
|
(define-syntax-rule (with-store/maybe store exp ...)
|
||||||
|
;; Evaluate EXP... with STORE bound to a connection, unless
|
||||||
|
;; STORE-NEEDED? is false, in which case STORE is bound to #f.
|
||||||
|
(let ((proc (lambda (store) exp ...)))
|
||||||
|
(if store-needed?
|
||||||
|
(with-store s
|
||||||
|
(set-build-options-from-command-line s opts)
|
||||||
|
(with-build-handler (build-notifier #:use-substitutes?
|
||||||
|
(assoc-ref opts 'substitutes?)
|
||||||
|
#:verbosity
|
||||||
|
(assoc-ref opts 'verbosity)
|
||||||
|
#:dry-run?
|
||||||
|
(assoc-ref opts 'dry-run?))
|
||||||
|
(proc s)))
|
||||||
|
(proc #f))))
|
||||||
|
|
||||||
(when container? (assert-container-features))
|
(when container? (assert-container-features))
|
||||||
|
|
||||||
(when (and (not container?) link-prof?)
|
(when (and (not container?) link-prof?)
|
||||||
|
@ -701,88 +721,85 @@ (define (guix-environment* opts)
|
||||||
(leave (G_ "--no-cwd cannot be used without --container~%")))
|
(leave (G_ "--no-cwd cannot be used without --container~%")))
|
||||||
|
|
||||||
|
|
||||||
(with-store store
|
(with-store/maybe store
|
||||||
(with-build-handler (build-notifier #:use-substitutes?
|
(with-status-verbosity (assoc-ref opts 'verbosity)
|
||||||
(assoc-ref opts 'substitutes?)
|
(define manifest-from-opts
|
||||||
#:verbosity
|
(options/resolve-packages store opts))
|
||||||
(assoc-ref opts 'verbosity)
|
|
||||||
#:dry-run?
|
|
||||||
(assoc-ref opts 'dry-run?))
|
|
||||||
(with-status-verbosity (assoc-ref opts 'verbosity)
|
|
||||||
(define manifest-from-opts
|
|
||||||
(options/resolve-packages store opts))
|
|
||||||
|
|
||||||
(define manifest
|
(define manifest
|
||||||
(if profile
|
(if profile
|
||||||
(profile-manifest profile)
|
(profile-manifest profile)
|
||||||
manifest-from-opts))
|
manifest-from-opts))
|
||||||
|
|
||||||
(when (and profile
|
(when (and profile
|
||||||
(> (length (manifest-entries manifest-from-opts)) 0))
|
(> (length (manifest-entries manifest-from-opts)) 0))
|
||||||
(leave (G_ "'--profile' cannot be used with package options~%")))
|
(leave (G_ "'--profile' cannot be used with package options~%")))
|
||||||
|
|
||||||
(when (null? (manifest-entries manifest))
|
(when (null? (manifest-entries manifest))
|
||||||
(warning (G_ "no packages specified; creating an empty environment~%")))
|
(warning (G_ "no packages specified; creating an empty environment~%")))
|
||||||
|
|
||||||
(set-build-options-from-command-line store opts)
|
;; Use the bootstrap Guile when requested.
|
||||||
|
(parameterize ((%graft? (assoc-ref opts 'graft?))
|
||||||
|
(%guile-for-build
|
||||||
|
(and store-needed?
|
||||||
|
(package-derivation
|
||||||
|
store
|
||||||
|
(if bootstrap?
|
||||||
|
%bootstrap-guile
|
||||||
|
(default-guile))))))
|
||||||
|
(run-with-store store
|
||||||
|
;; Containers need a Bourne shell at /bin/sh.
|
||||||
|
(mlet* %store-monad ((bash (environment-bash container?
|
||||||
|
bootstrap?
|
||||||
|
system))
|
||||||
|
(prof-drv (if profile
|
||||||
|
(return #f)
|
||||||
|
(manifest->derivation
|
||||||
|
manifest system bootstrap?)))
|
||||||
|
(profile -> (if profile
|
||||||
|
(readlink* profile)
|
||||||
|
(derivation->output-path prof-drv)))
|
||||||
|
(gc-root -> (assoc-ref opts 'gc-root)))
|
||||||
|
|
||||||
;; Use the bootstrap Guile when requested.
|
;; First build the inputs. This is necessary even for
|
||||||
(parameterize ((%graft? (assoc-ref opts 'graft?))
|
;; --search-paths. Additionally, we might need to build bash for
|
||||||
(%guile-for-build
|
;; a container.
|
||||||
(and (or container? (not profile))
|
(mbegin %store-monad
|
||||||
(package-derivation
|
(mwhen store-needed?
|
||||||
store
|
|
||||||
(if bootstrap?
|
|
||||||
%bootstrap-guile
|
|
||||||
(default-guile))))))
|
|
||||||
(run-with-store store
|
|
||||||
;; Containers need a Bourne shell at /bin/sh.
|
|
||||||
(mlet* %store-monad ((bash (environment-bash container?
|
|
||||||
bootstrap?
|
|
||||||
system))
|
|
||||||
(prof-drv (if profile
|
|
||||||
(return #f)
|
|
||||||
(manifest->derivation
|
|
||||||
manifest system bootstrap?)))
|
|
||||||
(profile -> (if profile
|
|
||||||
(readlink* profile)
|
|
||||||
(derivation->output-path prof-drv)))
|
|
||||||
(gc-root -> (assoc-ref opts 'gc-root)))
|
|
||||||
|
|
||||||
;; First build the inputs. This is necessary even for
|
|
||||||
;; --search-paths. Additionally, we might need to build bash for
|
|
||||||
;; a container.
|
|
||||||
(mbegin %store-monad
|
|
||||||
(built-derivations (append
|
(built-derivations (append
|
||||||
(if prof-drv (list prof-drv) '())
|
(if prof-drv (list prof-drv) '())
|
||||||
(if (derivation? bash) (list bash) '())))
|
(if (derivation? bash) (list bash) '()))))
|
||||||
(mwhen gc-root
|
(mwhen gc-root
|
||||||
(register-gc-root profile gc-root))
|
(register-gc-root profile gc-root))
|
||||||
|
|
||||||
(cond
|
(cond
|
||||||
((assoc-ref opts 'search-paths)
|
((assoc-ref opts 'search-paths)
|
||||||
(show-search-paths profile manifest #:pure? pure?)
|
(show-search-paths profile manifest #:pure? pure?)
|
||||||
(return #t))
|
(return #t))
|
||||||
(container?
|
(container?
|
||||||
(let ((bash-binary
|
(let ((bash-binary
|
||||||
(if bootstrap?
|
(if bootstrap?
|
||||||
(derivation->output-path bash)
|
(derivation->output-path bash)
|
||||||
(string-append (derivation->output-path bash)
|
(string-append (derivation->output-path bash)
|
||||||
"/bin/sh"))))
|
"/bin/sh"))))
|
||||||
(launch-environment/container #:command command
|
(launch-environment/container #:command command
|
||||||
#:bash bash-binary
|
#:bash bash-binary
|
||||||
#:user user
|
#:user user
|
||||||
#:user-mappings mappings
|
#:user-mappings mappings
|
||||||
#:profile profile
|
#:profile profile
|
||||||
#:manifest manifest
|
#:manifest manifest
|
||||||
#:white-list white-list
|
#:white-list white-list
|
||||||
#:link-profile? link-prof?
|
#:link-profile? link-prof?
|
||||||
#:network? network?
|
#:network? network?
|
||||||
#:map-cwd? (not no-cwd?))))
|
#:map-cwd? (not no-cwd?))))
|
||||||
|
|
||||||
(else
|
(else
|
||||||
(return
|
(return
|
||||||
(exit/status
|
(exit/status
|
||||||
(launch-environment/fork command profile manifest
|
(launch-environment/fork command profile manifest
|
||||||
#:white-list white-list
|
#:white-list white-list
|
||||||
#:pure? pure?)))))))))))))))
|
#:pure? pure?))))))))))))))
|
||||||
|
|
||||||
|
;;; Local Variables:
|
||||||
|
;;; (put 'with-store/maybe 'scheme-indent-function 1)
|
||||||
|
;;; End:
|
||||||
|
|
Loading…
Reference in a new issue