gnu: Properly credit Konrad Hinsen.
[jackhill/guix/guix.git] / guix / remote.scm
index d8124e4..f6adb22 100644 (file)
@@ -1,5 +1,5 @@
 ;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2019 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2019, 2020 Ludovic Courtès <ludo@gnu.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -19,6 +19,8 @@
 (define-module (guix remote)
   #:use-module (guix ssh)
   #:use-module (guix gexp)
+  #:use-module (guix i18n)
+  #:use-module ((guix diagnostics) #:select (formatted-message))
   #:use-module (guix inferior)
   #:use-module (guix store)
   #:use-module (guix monads)
   #:use-module (guix derivations)
   #:use-module (guix utils)
   #:use-module (ssh popen)
+  #:use-module (ssh channel)
   #:use-module (srfi srfi-1)
   #:use-module (srfi srfi-34)
   #:use-module (srfi srfi-35)
+  #:use-module (ice-9 format)
   #:use-module (ice-9 match)
   #:export (remote-eval))
 
@@ -67,10 +71,11 @@ BECOME-COMMAND is given, use that to invoke the remote Guile REPL."
 
   (let ((pipe (apply open-remote-pipe* session OPEN_READ repl-command)))
     (when (eof-object? (peek-char pipe))
-      (raise (condition
-              (&message
-               (message (format #f (G_ "failed to run '~{~a~^ ~}'")
-                                repl-command))))))
+      (let ((status (channel-get-exit-status pipe)))
+        (close-port pipe)
+        (raise (formatted-message (G_ "remote command '~{~a~^ ~}' failed \
+with status ~a")
+                                  repl-command status))))
     pipe))
 
 (define* (%remote-eval lowered session #:optional become-command)
@@ -106,7 +111,7 @@ result to the current output port using the (guix repl) protocol."
                       (build-locally? #t)
                       (system (%current-system))
                       (module-path %load-path)
-                      (socket-name "/var/guix/daemon-socket/socket")
+                      (socket-name (%daemon-socket-uri))
                       (become-command #f))
   "Evaluate EXP, a gexp, on the host at SESSION, an SSH session.  Ensure that
 all the elements EXP refers to are built and deployed to SESSION beforehand.