diff options
Diffstat (limited to 'guix/ssh.scm')
-rw-r--r-- | guix/ssh.scm | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/guix/ssh.scm b/guix/ssh.scm index 457d1890f9..232b6bfe94 100644 --- a/guix/ssh.scm +++ b/guix/ssh.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2016, 2017, 2018, 2019, 2020 Ludovic Courtès <ludo@gnu.org> +;;; Copyright © 2016, 2017, 2018, 2019, 2020, 2021, 2021 Ludovic Courtès <ludo@gnu.org> ;;; ;;; This file is part of GNU Guix. ;;; @@ -253,7 +253,22 @@ EXP never returns or calls 'primitive-exit' when it's done." (use-modules (ice-9 match) (rnrs io ports) (rnrs bytevectors)) - (let ((sock (socket AF_UNIX SOCK_STREAM 0)) + (define connect-to-daemon + ;; XXX: 'connect-to-daemon' used to be private and before that it + ;; didn't even exist, hence these shenanigans. + (let ((connect-to-daemon + (false-if-exception (module-ref (resolve-module '(guix store)) + 'connect-to-daemon)))) + (lambda (uri) + (if connect-to-daemon + (connect-to-daemon uri) + (let ((sock (socket AF_UNIX SOCK_STREAM 0))) + (connect sock AF_UNIX ,socket-name) + sock))))) + + ;; Use 'connect-to-daemon' to honor GUIX_DAEMON_SOCKET. + (let ((sock (connect-to-daemon (or (getenv "GUIX_DAEMON_SOCKET") + ,socket-name))) (stdin (current-input-port)) (stdout (current-output-port)) (select* (lambda (read write except) @@ -272,8 +287,6 @@ EXP never returns or calls 'primitive-exit' when it's done." (setvbuf stdin 'block 65536) (setvbuf sock 'block 65536) - (connect sock AF_UNIX ,socket-name) - (let loop () (match (select* (list stdin sock) '() '()) ((reads () ()) @@ -302,8 +315,13 @@ EXP never returns or calls 'primitive-exit' when it's done." "/var/guix/daemon-socket/socket")) "Connect to the remote build daemon listening on SOCKET-NAME over SESSION, an SSH session. Return a <store-connection> object." - (open-connection #:port (remote-daemon-channel session socket-name))) - + (guard (c ((store-connection-error? c) + ;; Raise a more focused error condition. + (raise (formatted-message + (G_ "failed to connect over SSH to daemon at '~a', socket ~a") + (session-get session 'host) + socket-name)))) + (open-connection #:port (remote-daemon-channel session socket-name)))) (define (store-import-channel session) "Return an output port to which archives to be exported to SESSION's store |