* guix/store.scm (with-store): New macro.
(eval . (put 'manifest-entry 'scheme-indent-function 0))
(eval . (put 'manifest-pattern 'scheme-indent-function 0))
(eval . (put 'substitute-keyword-arguments 'scheme-indent-function 1))
+ (eval . (put 'with-store 'scheme-indent-function 1))
(eval . (put 'with-error-handling 'scheme-indent-function 0))
(eval . (put 'with-mutex 'scheme-indent-function 1))
(eval . (put 'with-atomic-file-output 'scheme-indent-function 1))
open-connection
close-connection
+ with-store
set-build-options
valid-path?
query-path-hash
"Close the connection to SERVER."
(close (nix-server-socket server)))
+(define-syntax-rule (with-store store exp ...)
+ "Bind STORE to an open connection to the store and evaluate EXPs;
+automatically close the store when the dynamic extent of EXP is left."
+ (let ((store (open-connection)))
+ (dynamic-wind
+ (const #f)
+ (lambda ()
+ exp ...)
+ (lambda ()
+ (false-if-exception (close-connection store))))))
+
(define current-build-output-port
;; The port where build output is sent.
(make-parameter (current-error-port)))