summaryrefslogtreecommitdiff
path: root/guix/store.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2018-06-25 18:40:10 +0200
committerLudovic Courtès <ludo@gnu.org>2018-06-26 14:27:57 +0200
commit2f608c14893a025b471bcd993096f92331a45a12 (patch)
tree56302f7e19a55b87923dc4a4ff5831fa38cd1100 /guix/store.scm
parent7c7323e432620a42f896056f076020a748c1fd6d (diff)
downloadgnu-guix-2f608c14893a025b471bcd993096f92331a45a12.tar
gnu-guix-2f608c14893a025b471bcd993096f92331a45a12.tar.gz
store: Add 'port->connection'.
* guix/store.scm (port->connection): New procedure.
Diffstat (limited to 'guix/store.scm')
-rw-r--r--guix/store.scm18
1 files changed, 18 insertions, 0 deletions
diff --git a/guix/store.scm b/guix/store.scm
index 773d53e82b..3bf56573bf 100644
--- a/guix/store.scm
+++ b/guix/store.scm
@@ -65,6 +65,7 @@
build-mode
open-connection
+ port->connection
close-connection
with-store
set-build-options
@@ -517,6 +518,23 @@ for this connection will be pinned. Return a server object."
(or done? (process-stderr conn)))
conn)))))))))
+(define* (port->connection port
+ #:key (version %protocol-version))
+ "Assimilate PORT, an input/output port, and return a connection to the
+daemon, assuming the given protocol VERSION.
+
+Warning: this procedure assumes that the initial handshake with the daemon has
+already taken place on PORT and that we're just continuing on this established
+connection. Use with care."
+ (let-values (((output flush)
+ (buffering-output-port port (make-bytevector 8192))))
+ (%make-nix-server port
+ (protocol-major version)
+ (protocol-minor version)
+ output flush
+ (make-hash-table 100)
+ (make-hash-table 100))))
+
(define (write-buffered-output server)
"Flush SERVER's output port."
(force-output (nix-server-output-port server))