From 366d5a94b07a879abf4d85dc11ef7bf3b3369aae Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Mon, 28 Oct 2024 22:25:14 +0000 Subject: command-line-tool: Allow processing manifest objects without a file. * ravanan/command-line-tool.scm (manifest->environment): New function. (manifest-file->environment)[build-derivation]: Delete function. Call manifest->environment. --- ravanan/command-line-tool.scm | 50 ++++++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 22 deletions(-) diff --git a/ravanan/command-line-tool.scm b/ravanan/command-line-tool.scm index 83dec50..6f95b88 100644 --- a/ravanan/command-line-tool.scm +++ b/ravanan/command-line-tool.scm @@ -573,17 +573,6 @@ Close @var{inferior} when done, even if @var{proc} exits non-locally." variables to set to use the built profile. Connect to the Guix daemon specified by @var{guix-daemon-socket}. If @var{channels} is not @code{#f}, build manifest in a Guix inferior with @var{channels}." - (define (build-derivation drv guix-daemon-socket) - (if guix-daemon-socket - (parameterize ((%daemon-socket-uri guix-daemon-socket)) - (build-derivation drv #f)) - (with-store store - (run-with-store store - (mlet %store-monad ((drv drv)) - (mbegin %store-monad - (built-derivations (list drv)) - (return (derivation->output-path drv)))))))) - (if channels (call-with-inferior (inferior-for-channels channels) (cut inferior-eval @@ -620,17 +609,34 @@ in a Guix inferior with @var{channels}." #:allow-collisions? #t) ,guix-daemon-socket)))))) <>)) - (let ((manifest (load-manifest manifest-file))) - (map (match-lambda - ((specification . value) - (cons (search-path-specification-variable specification) - value))) - (evaluate-search-paths - (manifest-search-paths manifest) - (list (build-derivation - (profile-derivation manifest - #:allow-collisions? #t) - guix-daemon-socket))))))) + (manifest->environment (load-manifest manifest-file) + guix-daemon-socket))) + +(define (manifest->environment manifest guix-daemon-socket) + "Build @var{manifest} and return an association list of environment +variables to set to use the built profile. Connect to the Guix daemon specified +by @var{guix-daemon-socket}." + (define (build-derivation drv guix-daemon-socket) + (if guix-daemon-socket + (parameterize ((%daemon-socket-uri guix-daemon-socket)) + (build-derivation drv #f)) + (with-store store + (run-with-store store + (mlet %store-monad ((drv drv)) + (mbegin %store-monad + (built-derivations (list drv)) + (return (derivation->output-path drv)))))))) + + (map (match-lambda + ((specification . value) + (cons (search-path-specification-variable specification) + value))) + (evaluate-search-paths + (manifest-search-paths manifest) + (list (build-derivation + (profile-derivation manifest + #:allow-collisions? #t) + guix-daemon-socket))))) (define (build-command-line-tool-script name manifest-file channels cwl inputs scratch store batch-system -- cgit v1.2.3