mirror of
https://git.savannah.gnu.org/git/guix.git
synced 2025-01-18 21:46:35 +01:00
ssh: Decompose 'connect-to-remote-daemon'.
* guix/ssh.scm (remote-daemon-channel): New procedure. (connect-to-remote-daemon): Implement in terms of it.
This commit is contained in:
parent
615c5298f7
commit
e537833726
1 changed files with 20 additions and 12 deletions
32
guix/ssh.scm
32
guix/ssh.scm
|
@ -33,6 +33,7 @@ (define-module (guix ssh)
|
||||||
#:use-module (ice-9 match)
|
#:use-module (ice-9 match)
|
||||||
#:use-module (ice-9 binary-ports)
|
#:use-module (ice-9 binary-ports)
|
||||||
#:export (open-ssh-session
|
#:export (open-ssh-session
|
||||||
|
remote-daemon-channel
|
||||||
connect-to-remote-daemon
|
connect-to-remote-daemon
|
||||||
send-files
|
send-files
|
||||||
retrieve-files
|
retrieve-files
|
||||||
|
@ -88,11 +89,11 @@ (define* (open-ssh-session host #:key user port
|
||||||
(message (format #f (_ "SSH connection to '~a' failed: ~a~%")
|
(message (format #f (_ "SSH connection to '~a' failed: ~a~%")
|
||||||
host (get-error session))))))))))
|
host (get-error session))))))))))
|
||||||
|
|
||||||
(define* (connect-to-remote-daemon session
|
(define* (remote-daemon-channel session
|
||||||
#:optional
|
#:optional
|
||||||
(socket-name "/var/guix/daemon-socket/socket"))
|
(socket-name
|
||||||
"Connect to the remote build daemon listening on SOCKET-NAME over SESSION,
|
"/var/guix/daemon-socket/socket"))
|
||||||
an SSH session. Return a <nix-server> object."
|
"Return an input/output port (an SSH channel) to the daemon at SESSION."
|
||||||
(define redirect
|
(define redirect
|
||||||
;; Code run in SESSION to redirect the remote process' stdin/stdout to the
|
;; Code run in SESSION to redirect the remote process' stdin/stdout to the
|
||||||
;; daemon's socket, à la socat. The SSH protocol supports forwarding to
|
;; daemon's socket, à la socat. The SSH protocol supports forwarding to
|
||||||
|
@ -127,13 +128,20 @@ (define redirect
|
||||||
(_
|
(_
|
||||||
(primitive-exit 1)))))))
|
(primitive-exit 1)))))))
|
||||||
|
|
||||||
(let ((channel
|
(open-remote-pipe* session OPEN_BOTH
|
||||||
(open-remote-pipe* session OPEN_BOTH
|
;; Sort-of shell-quote REDIRECT.
|
||||||
;; Sort-of shell-quote REDIRECT.
|
"guile" "-c"
|
||||||
"guile" "-c"
|
(object->string
|
||||||
(object->string
|
(object->string redirect))))
|
||||||
(object->string redirect)))))
|
|
||||||
(open-connection #:port channel)))
|
(define* (connect-to-remote-daemon session
|
||||||
|
#:optional
|
||||||
|
(socket-name
|
||||||
|
"/var/guix/daemon-socket/socket"))
|
||||||
|
"Connect to the remote build daemon listening on SOCKET-NAME over SESSION,
|
||||||
|
an SSH session. Return a <nix-server> object."
|
||||||
|
(open-connection #:port (remote-daemon-channel session)))
|
||||||
|
|
||||||
|
|
||||||
(define (store-import-channel session)
|
(define (store-import-channel session)
|
||||||
"Return an output port to which archives to be exported to SESSION's store
|
"Return an output port to which archives to be exported to SESSION's store
|
||||||
|
|
Loading…
Reference in a new issue