Subject: bug#36872: closed (Re: [bug#36872] [PATCH v2 2/2] remote: Remove '--system' argument.)

From: [email-masked] (GNU bug Tracking System)
Date: Wed, 14 Aug 2019 20:30:03 +0000

Your bug report

#36872: [PATCH 1/2] remote: Build derivations appropriate for the remote's architecture.

which was filed against the guix-patches package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
36872: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=36872
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: [bug#36872] [PATCH v2 2/2] remote: Remove '--system' argument.
From: Christopher Lemmer Webber <[email-masked]>
To: "Jakob L. Kreuze" <[email-masked]>
Cc: "Thompson, David" <[email-masked]>, [email-masked]
Date: Wed, 14 Aug 2019 16:29:49 -0400
List-Id: <debbugs-submit.debbugs.gnu.org>

Forgot to signal -done :)

Christopher Lemmer Webber writes:

> Looks good.  Merged & pushed!
>
> Jakob L. Kreuze writes:
>
>> * gnu/services.scm (activation-script): Return a <program-file> rather
>> than a <scheme-file>.
>> * gnu/deploy.scm (guix-deploy): Remove handling for '--system'.
>> (show-help): Remove documentation for '--system'.
>> (%default-options): Remove default setting for 'system'.
>> ---
>>  gnu/services.scm        | 56 ++++++++++++++++++++---------------------
>>  guix/scripts/deploy.scm |  8 ++----
>>  2 files changed, 30 insertions(+), 34 deletions(-)
>>
>> diff --git a/gnu/services.scm b/gnu/services.scm
>> index 7de78105ff..6ee05d4580 100644
>> --- a/gnu/services.scm
>> +++ b/gnu/services.scm
>> @@ -430,34 +430,34 @@ ACTIVATION-SCRIPT-TYPE."
>>  (define (activation-script gexps)
>>    "Return the system's activation script, which evaluates GEXPS."
>>    (define actions
>> -    (map (cut scheme-file "activate-service" <>) gexps))
>> -
>> -  (scheme-file "activate"
>> -               (with-imported-modules (source-module-closure
>> -                                       '((gnu build activation)
>> -                                         (guix build utils)))
>> -                 #~(begin
>> -                     (use-modules (gnu build activation)
>> -                                  (guix build utils))
>> -
>> -                     ;; Make sure the user accounting database exists.  If it
>> -                     ;; does not exist, 'setutxent' does not create it and
>> -                     ;; thus there is no accounting at all.
>> -                     (close-port (open-file "/var/run/utmpx" "a0"))
>> -
>> -                     ;; Same for 'wtmp', which is populated by mingetty et
>> -                     ;; al.
>> -                     (mkdir-p "/var/log")
>> -                     (close-port (open-file "/var/log/wtmp" "a0"))
>> -
>> -                     ;; Set up /run/current-system.  Among other things this
>> -                     ;; sets up locales, which the activation snippets
>> -                     ;; executed below may expect.
>> -                     (activate-current-system)
>> -
>> -                     ;; Run the services' activation snippets.
>> -                     ;; TODO: Use 'load-compiled'.
>> -                     (for-each primitive-load '#$actions)))))
>> +    (map (cut program-file "activate-service.scm" <>) gexps))
>> +
>> +  (program-file "activate.scm"
>> +                (with-imported-modules (source-module-closure
>> +                                        '((gnu build activation)
>> +                                          (guix build utils)))
>> +                  #~(begin
>> +                      (use-modules (gnu build activation)
>> +                                   (guix build utils))
>> +
>> +                      ;; Make sure the user accounting database exists.  If it
>> +                      ;; does not exist, 'setutxent' does not create it and
>> +                      ;; thus there is no accounting at all.
>> +                      (close-port (open-file "/var/run/utmpx" "a0"))
>> +
>> +                      ;; Same for 'wtmp', which is populated by mingetty et
>> +                      ;; al.
>> +                      (mkdir-p "/var/log")
>> +                      (close-port (open-file "/var/log/wtmp" "a0"))
>> +
>> +                      ;; Set up /run/current-system.  Among other things this
>> +                      ;; sets up locales, which the activation snippets
>> +                      ;; executed below may expect.
>> +                      (activate-current-system)
>> +
>> +                      ;; Run the services' activation snippets.
>> +                      ;; TODO: Use 'load-compiled'.
>> +                      (for-each primitive-load '#$actions)))))
>>  
>>  (define (gexps->activation-gexp gexps)
>>    "Return a gexp that runs the activation script containing GEXPS."
>> diff --git a/guix/scripts/deploy.scm b/guix/scripts/deploy.scm
>> index ebc99e52cc..81f2b33260 100644
>> --- a/guix/scripts/deploy.scm
>> +++ b/guix/scripts/deploy.scm
>> @@ -43,8 +43,6 @@
>>  (define (show-help)
>>    (display (G_ "Usage: guix deploy [OPTION] FILE...
>>  Perform the deployment specified by FILE.\n"))
>> -  (display (G_ "
>> -  -s, --system=SYSTEM    attempt to build for SYSTEM--e.g., \"i686-linux\""))
>>    (show-build-options-help)
>>    (newline)
>>    (display (G_ "
>> @@ -66,8 +64,7 @@ Perform the deployment specified by FILE.\n"))
>>           %standard-build-options))
>>  
>>  (define %default-options
>> -  `((system . ,(%current-system))
>> -    (substitutes? . #t)
>> +  `((substitutes? . #t)
>>      (build-hook? . #t)
>>      (graft? . #t)
>>      (debug . 0)
>> @@ -92,7 +89,6 @@ Perform the deployment specified by FILE.\n"))
>>        (set-build-options-from-command-line store opts)
>>        (for-each (lambda (machine)
>>                    (info (G_ "deploying to ~a...") (machine-display-name machine))
>> -                  (parameterize ((%current-system (assq-ref opts 'system))
>> -                                 (%graft? (assq-ref opts 'graft?)))
>> +                  (parameterize ((%graft? (assq-ref opts 'graft?)))
>>                      (run-with-store store (deploy-machine machine))))
>>                  machines))))

Subject: [PATCH 1/2] remote: Build derivations appropriate for the remote's architecture.
From: [email-masked] (Jakob L. Kreuze)
To: [email-masked]
Date: Wed, 31 Jul 2019 09:41:30 -0400
List-Id: <debbugs-submit.debbugs.gnu.org>

* guix/ssh.scm (remote-system): New variable.
* guix/remote.scm (remote-eval): Use result of 'remote-system' when
lowering the G-Expression.
(trampoline): Return a <program-file> rather than a <scheme-file>.
---
 guix/remote.scm | 13 ++++++++-----
 guix/ssh.scm    |  7 +++++++
 2 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/guix/remote.scm b/guix/remote.scm
index 853029c54f..d5738ebbfa 100644
--- a/guix/remote.scm
+++ b/guix/remote.scm
@@ -72,7 +72,7 @@ prerequisites of EXP are already available on the host at SESSION."
   "Return a \"trampoline\" gexp that evaluates EXP and writes the evaluation
 result to the current output port using the (guix repl) protocol."
   (define program
-    (scheme-file "remote-exp.scm" exp))
+    (program-file "remote-exp.scm" exp))
 
   (with-imported-modules (source-module-closure '((guix repl)))
     #~(begin
@@ -97,10 +97,13 @@ all the elements EXP refers to are built and deployed to 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."
-  (mlet %store-monad ((lowered (lower-gexp (trampoline exp)
-                                           #:module-path %load-path))
-                      (remote -> (connect-to-remote-daemon session
-                                                           socket-name)))
+  (mlet* %store-monad ((system -> (remote-system session))
+                       (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
--- 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 FILES is exported."
                              ,(object->string
                                (object->string export))))))
 
+(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-system))
+                        session))
+
 (define* (send-files local files remote
                      #:key
                      recursive?
-- 
2.22.0