From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:470:142:3::10]:47972) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hw9aV-00062H-Qv for guix-patches@gnu.org; Fri, 09 Aug 2019 14:26:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hw9aU-0007NB-Ak for guix-patches@gnu.org; Fri, 09 Aug 2019 14:26:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:34440) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hw9aU-0007N5-6t for guix-patches@gnu.org; Fri, 09 Aug 2019 14:26:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hw9aU-0008MX-1l for guix-patches@gnu.org; Fri, 09 Aug 2019 14:26:02 -0400 Subject: [bug#36872] [PATCH v2 1/2] remote: Build derivations appropriate for the remote's Resent-Message-ID: From: zerodaysfordays@sdf.lonestar.org (Jakob L. Kreuze) In-Reply-To: <87sgqclnz0.fsf@sdf.lonestar.org> (Jakob L. Kreuze's message of "Wed, 07 Aug 2019 16:28:19 -0400") References: <87lfwee2yd.fsf@sdf.lonestar.org> <87h872e2v2.fsf@sdf.lonestar.org> <87ef1yovur.fsf@dustycloud.org> <877e7qvv75.fsf@sdf.lonestar.org> <87a7ckq129.fsf@dustycloud.org> <87sgqclnz0.fsf@sdf.lonestar.org> Date: Fri, 09 Aug 2019 14:24:57 -0400 Message-ID: <8736ianqme.fsf_-_@sdf.lonestar.org> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: "Thompson, David" Cc: 36872@debbugs.gnu.org --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable * gnu/machine/ssh.scm (machine-ssh-configuration): Add 'system' field. (managed-host-remote-eval): Pass 'system' field to 'remote-eval'. (machine-check-building-for-appropriate-system): New variable. (check-deployment-sanity): Add call to 'machine-check-building-for-appropriate-system'. * doc/guix.texi (Invoking guix deploy): Describe new 'system' field. * guix/ssh.scm (remote-system): New variable. * guix/remote.scm (remote-eval): Use result of 'remote-system' when lowering the G-Expression. (remote-eval): Add 'system' keyword argument. (trampoline): Return a rather than a . =2D-- doc/guix.texi | 3 +++ gnu/machine/ssh.scm | 31 +++++++++++++++++++++++++++---- guix/remote.scm | 14 +++++++++----- guix/ssh.scm | 7 +++++++ 4 files changed, 46 insertions(+), 9 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 734206a4b2..a7facf4701 100644 =2D-- a/doc/guix.texi +++ b/doc/guix.texi @@ -25573,6 +25573,9 @@ with an @code{environment} of @code{managed-host-en= vironment-type}. =20 @table @asis @item @code{host-name} +@item @code{system} +The Nix system type describing the architecture of the machine being deplo= yed +to. This should look something like ``x86_64-linux''. @item @code{port} (default: @code{22}) @item @code{user} (default: @code{"root"}) @item @code{identity} (default: @code{#f}) diff --git a/gnu/machine/ssh.scm b/gnu/machine/ssh.scm index ba3e33c922..670990a633 100644 =2D-- a/gnu/machine/ssh.scm +++ b/gnu/machine/ssh.scm @@ -36,6 +36,7 @@ #:use-module (ice-9 match) #:use-module (srfi srfi-19) #:use-module (srfi srfi-26) + #:use-module (srfi srfi-34) #:use-module (srfi srfi-35) #:export (managed-host-environment-type =20 @@ -68,6 +69,7 @@ machine-ssh-configuration? this-machine-ssh-configuration (host-name machine-ssh-configuration-host-name) ; string + (system machine-ssh-configuration-system) ; string (build-locally? machine-ssh-configuration-build-locally? (default #t)) (port machine-ssh-configuration-port ; integer @@ -103,10 +105,12 @@ one from the configuration's parameters if one was no= t provided." "Internal implementation of 'machine-remote-eval' for MACHINE instances = with an environment type of 'managed-host." (maybe-raise-unsupported-configuration-error machine) =2D (remote-eval exp (machine-ssh-session machine) =2D #:build-locally? =2D (machine-ssh-configuration-build-locally? =2D (machine-configuration machine)))) + (let ((config (machine-configuration machine))) + (remote-eval exp (machine-ssh-session machine) + #:build-locally? + (machine-ssh-configuration-build-locally? config) + #:system + (machine-ssh-configuration-system config)))) =20 ;;; @@ -240,10 +244,29 @@ MACHINE's 'system' declaration do not exist on the ma= chine." device) (return #t))) =20 +(define (machine-check-building-for-appropriate-system machine) + "Raise a '&message' error condition if MACHINE is configured to be built +locally and the 'system' field does not match the '%current-system' report= ed +by MACHINE." + (let ((config (machine-configuration machine)) + (system (remote-system (machine-ssh-session machine)))) + (when (and (machine-ssh-configuration-build-locally? config) + (not (string=3D system (machine-ssh-configuration-system co= nfig)))) + (raise (condition + (&message + (message (format #f (G_ "incorrect target system \ +('~a' was given, while the system reports that it is '~a')~%") + (machine-ssh-configuration-system config) + system))))))) + (with-monad %store-monad (return #t))) + (define (check-deployment-sanity machine) "Raise a '&message' error condition if it is clear that deploying MACHIN= E's 'system' declaration would fail." + ;; Order is important here -- an incorrect value for 'system' will cause + ;; invocations of 'remote-eval' to fail. (mbegin %store-monad + (machine-check-building-for-appropriate-system machine) (machine-check-file-system-availability machine) (machine-check-initrd-modules machine))) =20 diff --git a/guix/remote.scm b/guix/remote.scm index 5fecd954e9..bcac64ea7a 100644 =2D-- a/guix/remote.scm +++ b/guix/remote.scm @@ -24,6 +24,7 @@ #:use-module (guix monads) #:use-module (guix modules) #:use-module (guix derivations) + #:use-module (guix utils) #:use-module (ssh popen) #:use-module (srfi srfi-1) #:use-module (ice-9 match) @@ -71,7 +72,7 @@ prerequisites of EXP are already available on the host at= SESSION." "Return a \"trampoline\" gexp that evaluates EXP and writes the evaluati= on result to the current output port using the (guix repl) protocol." (define program =2D (scheme-file "remote-exp.scm" exp)) + (program-file "remote-exp.scm" exp)) =20 (with-imported-modules (source-module-closure '((guix repl))) #~(begin @@ -89,6 +90,7 @@ result to the current output port using the (guix repl) p= rotocol." (define* (remote-eval exp session #:key (build-locally? #t) + (system (%current-system)) (module-path %load-path) (socket-name "/var/guix/daemon-socket/socket")) "Evaluate EXP, a gexp, on the host at SESSION, an SSH session. Ensure t= hat @@ -96,10 +98,12 @@ all the elements EXP refers to are built and deployed t= o SESSION beforehand. When BUILD-LOCALLY? is true, said dependencies are built locally and sent = to the remote store afterwards; otherwise, dependencies are built directly on= the remote store." =2D (mlet %store-monad ((lowered (lower-gexp (trampoline exp) =2D #:module-path %load-path)) =2D (remote -> (connect-to-remote-daemon session =2D socket-name))) + (mlet* %store-monad ((lowered (lower-gexp (trampoline exp) + #:system system + #:guile-for-build #f + #:module-path %load-path)) + (remote -> (connect-to-remote-daemon session + socket-name))) (define inputs (cons (lowered-gexp-guile lowered) (lowered-gexp-inputs lowered))) diff --git a/guix/ssh.scm b/guix/ssh.scm index ede00133c8..9b5ca68894 100644 =2D-- a/guix/ssh.scm +++ b/guix/ssh.scm @@ -39,6 +39,7 @@ remote-inferior remote-daemon-channel connect-to-remote-daemon + remote-system send-files retrieve-files retrieve-files* @@ -282,6 +283,12 @@ be read. When RECURSIVE? is true, the closure of FILE= S is exported." ,(object->string (object->string export)))))) =20 +(define (remote-system session) + "Return the system type as expected by Nix, usually ARCHITECTURE-KERNEL,= of +the machine on the other end of SESSION." + (inferior-remote-eval '(begin (use-modules (guix utils)) (%current-syste= m)) + session)) + (define* (send-files local files remote #:key recursive? =2D-=20 2.22.0 --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEa1VJLOiXAjQ2BGSm9Qb9Fp2P2VoFAl1NunsACgkQ9Qb9Fp2P 2Vo2NRAAqq0C2TeM/rHZzh+4nNS4AfOqqQ2Wp+TiLFaq+PfrCVZuBZycnl5+g8nV +FH51VUhkmIvOYpJtDJg68uwVP5wgJ1/waTZtBTsZgR0zpp5YHt2JVMxUzzimbx6 O9wvo3RLlDLhKyuvLPPaOCvfopwxyEcJHXNXw70yb60297ZwHFHD6b69uxlIpqWW aAjk+WE+fIIX7C+EUnXUHAlqrtRoaWO3L3rzpqZLQVJR7LuAzX0yAyT5er4jfEZ7 8THPj3Xrbfm9wgPuCqV83nBX9mJIn39SSyLfWP0/lsK08JEMjXSDiuV4So+UknoK 7rI0MZO0DO0gtq+efDlTYbkde6D5kdEuo/QK13h+imDckoMWk/1pi1Dk5J6zR4YE qapp/SLFAQ4Svoph1bvOUxo74QIitdufwNCIeu1nTSaiGIg3XeVY3iPMarKJay0W td0RgHBTUkn/8TxIF4M96D1Vc0bnQzguj9SUvgcMOMUiFoNtkCttv2aJ/05pzDX2 wi2vRMmrpq5BmG6khFjc+21SD1hL4tHAwU2ywR+lIj8iRBvUWHMkZiAzyOsylFDE o5cBt38y43folUo6nsVOkT2iJCK/ZlkF9TkDfmTG5qj6AfMP3Bn5R/J1SGCdb6YF S3CdxrBfTkYnqJ/Kh8I/zxXajQMJWzvuUozgB/3LVD6iZILLShY= =Ksmr -----END PGP SIGNATURE----- --=-=-=--