diff mbox series

[bug#36738] guix deploy: Support '--no-grafts' and '--system'

Message ID 87a7d9l2hw.fsf@member.fsf.org
State Accepted
Headers show
Series [bug#36738] guix deploy: Support '--no-grafts' and '--system' | expand

Commit Message

宋文武 July 20, 2019, 5:05 a.m. UTC
Hello, this patch handle the '--no-grafts' command line option:
And '--system', so I can deploy a "i686-linux" from my "x86_64-linux":
Or better we can add a 'system' field to the <machine> record, so we can
deploy a list of machines with different 'system'.  Currently a
<machine> has 'system' as a field for the <operating-system>, so where
to put this machine/arch 'system'...

Comments

Jakob L. Kreuze July 22, 2019, 4:48 p.m. UTC | #1
Hello Wenwu,
iyzsong@member.fsf.org (宋文武) writes:

> Hello, this patch handle the '--no-grafts' command line option:
> ...
> And '--system', so I can deploy a "i686-linux" from my "x86_64-linux":

These patches look good to me, thank you!

Ludo, Dave, Chris, any additional comments?

> Or better we can add a 'system' field to the <machine> record, so we
> can deploy a list of machines with different 'system'. Currently a
> <machine> has 'system' as a field for the <operating-system>, so where
> to put this machine/arch 'system'...

Great idea. I think that continuing to call the machine's
<operating-system> 'system' would be confusing if we introduced the
notion of a target architecture, because we use "system" to refer to the
target architecture in the rest of Guix's command-line tools. Maybe it
would make sense to rename the <operating-system> field to 'os' or
something similar, and use the 'system' field to specify the target
architecture instead? Any thoughs?

Regards,
Jakob
Jakob L. Kreuze July 22, 2019, 10:46 p.m. UTC | #2
zerodaysfordays@sdf.lonestar.org (Jakob L. Kreuze) writes:

> Great idea. I think that continuing to call the machine's
> <operating-system> 'system' would be confusing if we introduced the
> notion of a target architecture, because we use "system" to refer to
> the target architecture in the rest of Guix's command-line tools.
> Maybe it would make sense to rename the <operating-system> field to
> 'os' or something similar, and use the 'system' field to specify the
> target architecture instead? Any thoughs?

Actually, I had a thought. Why should we make this explicit, when we
could take an implicit approach and identify the target's architecture
with 'remote-eval'? Ideally, we'll be probing the machines anyway to
implement safety checks on the <operating-system> declaration, so why
not just add this to our list of pre-deployment tests?

Regards,
Jakob
Christine Lemmer-Webber July 23, 2019, 4:44 p.m. UTC | #3
Jakob L. Kreuze writes:

> Hello Wenwu,
> iyzsong@member.fsf.org (宋文武) writes:
>
>> Hello, this patch handle the '--no-grafts' command line option:
>> ...
>> And '--system', so I can deploy a "i686-linux" from my "x86_64-linux":
>
> These patches look good to me, thank you!
>
> Ludo, Dave, Chris, any additional comments?
>
>> Or better we can add a 'system' field to the <machine> record, so we
>> can deploy a list of machines with different 'system'. Currently a
>> <machine> has 'system' as a field for the <operating-system>, so where
>> to put this machine/arch 'system'...
>
> Great idea. I think that continuing to call the machine's
> <operating-system> 'system' would be confusing if we introduced the
> notion of a target architecture, because we use "system" to refer to the
> target architecture in the rest of Guix's command-line tools. Maybe it
> would make sense to rename the <operating-system> field to 'os' or
> something similar, and use the 'system' field to specify the target
> architecture instead? Any thoughs?

I'm fine with a rename to "os"
Christine Lemmer-Webber July 23, 2019, 4:45 p.m. UTC | #4
Jakob L. Kreuze writes:

> zerodaysfordays@sdf.lonestar.org (Jakob L. Kreuze) writes:
>
>> Great idea. I think that continuing to call the machine's
>> <operating-system> 'system' would be confusing if we introduced the
>> notion of a target architecture, because we use "system" to refer to
>> the target architecture in the rest of Guix's command-line tools.
>> Maybe it would make sense to rename the <operating-system> field to
>> 'os' or something similar, and use the 'system' field to specify the
>> target architecture instead? Any thoughs?
>
> Actually, I had a thought. Why should we make this explicit, when we
> could take an implicit approach and identify the target's architecture
> with 'remote-eval'? Ideally, we'll be probing the machines anyway to
> implement safety checks on the <operating-system> declaration, so why
> not just add this to our list of pre-deployment tests?
>
> Regards,
> Jakob

Maybe a good idea... let me think.  Is there any case where we start
taking actions *before* we might probe a machine that we can think of?

How would we also probe it?  Is there a chance of our probing behaving
incorrectly?  That would also be bad, if so.

Another route is to have the user specify what architecture they think
the machine has, and instead the probing is a "safety check"?
Thompson, David July 23, 2019, 5:05 p.m. UTC | #5
On Mon, Jul 22, 2019 at 6:48 PM Jakob L. Kreuze
<zerodaysfordays@sdf.lonestar.org> wrote:
>
> zerodaysfordays@sdf.lonestar.org (Jakob L. Kreuze) writes:
>
> > Great idea. I think that continuing to call the machine's
> > <operating-system> 'system' would be confusing if we introduced the
> > notion of a target architecture, because we use "system" to refer to
> > the target architecture in the rest of Guix's command-line tools.
> > Maybe it would make sense to rename the <operating-system> field to
> > 'os' or something similar, and use the 'system' field to specify the
> > target architecture instead? Any thoughs?
>
> Actually, I had a thought. Why should we make this explicit, when we
> could take an implicit approach and identify the target's architecture
> with 'remote-eval'? Ideally, we'll be probing the machines anyway to
> implement safety checks on the <operating-system> declaration, so why
> not just add this to our list of pre-deployment tests?

I don't see a compelling reason for the architecture to be a part of
the machine data type at this time.  I'd like to avoid such low-level
details if possible because I don't think they will translate well to
more complex methods of deployment.

- Dave
Jakob L. Kreuze July 23, 2019, 7:33 p.m. UTC | #6
Hi Chris,

Christopher Lemmer Webber <cwebber@dustycloud.org> writes:

> Maybe a good idea... let me think. Is there any case where we start
> taking actions *before* we might probe a machine that we can think of?
>
> How would we also probe it? Is there a chance of our probing behaving
> incorrectly? That would also be bad, if so.

None that come to mind right now, and if there are any, I don't think
they would be affected by the probing -- aside from doing work that
would get thrown out when the script errors out.

As for the safety of probing, none of the tests I intend on implementing
are effectful. It would be equivalents for 'check-mapped-devices',
'check-file-system-availability', and 'check-initrd-modules', all of
which do little beyond looking at the devices available on the system,
and now a check that would read '%current-system'.

> Another route is to have the user specify what architecture they think
> the machine has, and instead the probing is a "safety check"?

That'd work too, but I feel it's better to avoid putting an unnecessary
burden on the user.

Regards,
Jakob
Jakob L. Kreuze July 23, 2019, 7:35 p.m. UTC | #7
"Thompson, David" <dthompson2@worcester.edu> writes:

> I don't see a compelling reason for the architecture to be a part of
> the machine data type at this time. I'd like to avoid such low-level
> details if possible because I don't think they will translate well to
> more complex methods of deployment.

A good point. I'll see about having this as an environment-specific
check.

Regards,
Jakob
Ludovic Courtès July 23, 2019, 9:29 p.m. UTC | #8
Hello,

zerodaysfordays@sdf.lonestar.org (Jakob L. Kreuze) skribis:

> Hello Wenwu,
> iyzsong@member.fsf.org (宋文武) writes:
>
>> Hello, this patch handle the '--no-grafts' command line option:
>> ...
>> And '--system', so I can deploy a "i686-linux" from my "x86_64-linux":
>
> These patches look good to me, thank you!
>
> Ludo, Dave, Chris, any additional comments?

Fine with me!

I agree with Dave that we should avoid adding a ‘system-type’ field to
<machine>, at least for now.  Instead, we should just honor
(%current-system).

Thanks,
Ludo’.
Ricardo Wurmus July 23, 2019, 9:59 p.m. UTC | #9
Christopher Lemmer Webber <cwebber@dustycloud.org> writes:

> Jakob L. Kreuze writes:
>
>> zerodaysfordays@sdf.lonestar.org (Jakob L. Kreuze) writes:
>>
>>> Great idea. I think that continuing to call the machine's
>>> <operating-system> 'system' would be confusing if we introduced the
>>> notion of a target architecture, because we use "system" to refer to
>>> the target architecture in the rest of Guix's command-line tools.
>>> Maybe it would make sense to rename the <operating-system> field to
>>> 'os' or something similar, and use the 'system' field to specify the
>>> target architecture instead? Any thoughs?
>>
>> Actually, I had a thought. Why should we make this explicit, when we
>> could take an implicit approach and identify the target's architecture
>> with 'remote-eval'? Ideally, we'll be probing the machines anyway to
>> implement safety checks on the <operating-system> declaration, so why
>> not just add this to our list of pre-deployment tests?
>>
>> Regards,
>> Jakob
>
> Maybe a good idea... let me think.  Is there any case where we start
> taking actions *before* we might probe a machine that we can think of?

I don’t know if this qualifies, but if “guix deploy” were to *create* a
machine (e.g. on EC2 via the Guile AWS library) it wouldn’t be able to
probe it first.  But in that case we would have full control over what
the target would be, so no probing would be required.

--
Ricardo
Jakob L. Kreuze July 24, 2019, 12:11 a.m. UTC | #10
Hi Ricardo,

Ricardo Wurmus <rekado@elephly.net> writes:

> I don’t know if this qualifies, but if “guix deploy” were to *create*
> a machine (e.g. on EC2 via the Guile AWS library) it wouldn’t be able
> to probe it first. But in that case we would have full control over
> what the target would be, so no probing would be required.

Ah, good point. I suppose didn't think about this all the way through in
my response -- we wouldn't be able to probe an unprovisioned machine.
But your point gives me even more confidence in the decision to deduce
target architecture at runtime and have that as an environment-specific
check.

Thanks for chiming in!

Regards,
Jakob
宋文武 July 24, 2019, 12:36 p.m. UTC | #11
Ludovic Courtès <ludo@gnu.org> writes:

> Hello,
>
> zerodaysfordays@sdf.lonestar.org (Jakob L. Kreuze) skribis:
>
>> Hello Wenwu,
>> iyzsong@member.fsf.org (宋文武) writes:
>>
>>> Hello, this patch handle the '--no-grafts' command line option:
>>> ...
>>> And '--system', so I can deploy a "i686-linux" from my "x86_64-linux":
>>
>> These patches look good to me, thank you!
>>
>> Ludo, Dave, Chris, any additional comments?
>
> Fine with me!
>
> I agree with Dave that we should avoid adding a ‘system-type’ field to
> <machine>, at least for now.  Instead, we should just honor
> (%current-system).
>
> Thanks,
> Ludo’.

Pushed, thanks for the reviews!
diff mbox series

Patch

From 192f96a3fa4342765db919006c35cdeb1774b62f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=AE=8B=E6=96=87=E6=AD=A6?= <iyzsong@member.fsf.org>
Date: Sat, 20 Jul 2019 12:51:45 +0800
Subject: [PATCH 2/2] deploy: Handle the '--system' command line option.

* guix/scripts/deploy.scm (show-help): Add help for '--system'.
(%options): Add '-s' and '--system'.
(guix-deploy): Parameterize %current-system.
---
 guix/scripts/deploy.scm | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/guix/scripts/deploy.scm b/guix/scripts/deploy.scm
index 3acd32eaa7..52bba3f3bf 100644
--- a/guix/scripts/deploy.scm
+++ b/guix/scripts/deploy.scm
@@ -23,6 +23,7 @@ 
   #:use-module (guix scripts build)
   #:use-module (guix store)
   #:use-module (guix ui)
+  #:use-module (guix utils)
   #:use-module (guix grafts)
   #:use-module (ice-9 format)
   #:use-module (srfi srfi-1)
@@ -41,6 +42,8 @@ 
 (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_ "
@@ -55,10 +58,14 @@  Perform the deployment specified by FILE.\n"))
                  (lambda args
                    (show-help)
                    (exit 0)))
+         (option '(#\s "system") #t #f
+                 (lambda (opt name arg result)
+                   (alist-cons 'system arg
+                               (alist-delete 'system result eq?))))
          %standard-build-options))
 
 (define %default-options
-  '((system . ,(%current-system))
+  `((system . ,(%current-system))
     (substitutes? . #t)
     (build-hook? . #t)
     (graft? . #t)
@@ -81,6 +88,7 @@  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 ((%graft? (assq-ref opts 'graft?)))
+                  (parameterize ((%current-system (assq-ref opts 'system))
+                                 (%graft? (assq-ref opts 'graft?)))
                     (run-with-store store (deploy-machine machine))))
                 machines))))
-- 
2.19.2