diff mbox series

[bug#38612] Pass system and target arguments to gexp->file.

Message ID 878smvtr1b.fsf@gmail.com
State Accepted
Headers show
Series [bug#38612] Pass system and target arguments to gexp->file. | expand

Commit Message

Mathieu Othacehe Dec. 29, 2019, 9:33 a.m. UTC
Hey Ludo,

Then, here's a patch that set the default target to 'current in
lower-object, gexp->file and gexp->script. Then, (current-target-system)
is used at bind time if target is 'current (same way as gexp->derivation
and lower-gexp).

An additionnal patch is needed because lower-object is called without a
default target in lower-gexp, when lowering extensions.

WDYT?

Mathieu

Comments

Ludovic Courtès Dec. 29, 2019, 10:36 p.m. UTC | #1
Hi!

Mathieu Othacehe <m.othacehe@gmail.com> skribis:

> Then, here's a patch that set the default target to 'current in
> lower-object, gexp->file and gexp->script. Then, (current-target-system)
> is used at bind time if target is 'current (same way as gexp->derivation
> and lower-gexp).
>
> An additionnal patch is needed because lower-object is called without a
> default target in lower-gexp, when lowering extensions.
>
> WDYT?
>
> Mathieu
>
> From f5d773dc0a627ba6059f1025189d33a9e0d083b5 Mon Sep 17 00:00:00 2001
> From: Mathieu Othacehe <m.othacehe@gmail.com>
> Date: Sat, 28 Dec 2019 21:29:06 +0100
> Subject: [PATCH 1/2] gexp: Default to current target.
>
> * guix/gexp.scm (lower-object): Set target argument to 'current by default and
> look for the current target system at bind time if needed,
> (gexp->file): ditto,
> (gexp->script): ditto.

Uh, it’s “the right thing” but it’s getting ugly.  :-/

If we take a step back, what’s the minimal change that would solve the
problem you’re looking at?

Apologies for the back-and-forth, it’s a tricky area!

Thanks,
Ludo’.
Mathieu Othacehe Dec. 30, 2019, 8:40 a.m. UTC | #2
Hey,

> Uh, it’s “the right thing” but it’s getting ugly.  :-/
>
> If we take a step back, what’s the minimal change that would solve the
> problem you’re looking at?
>
> Apologies for the back-and-forth, it’s a tricky area!

I'm glad I can have your support on this topic :)

Here's a small recap of the situation. As you may know I'm trying to get
"guix system build install.scm --target=xxx" to work.

My board needs specific initrd kernel modules to boot. As target is not
passed to lower-object in system-derivation procedure of (gnu services),
raw-initrd will try to locate those (arm specific) modules in the host
x86 kernel, where they do not exist, and fail.

The same thing happens for operating-system-boot-parameters-file which
contains a gexp->file call.

Now, while this problem is quite specific, we need to find a generic
solution to those target issues. Forcing the user of (guix gexp) to pass
a target argument implies the use of monadic style to read
%current-target-system safely.

On the other hand, defaulting to the current target inside (guix gexp)
as proposed in my patch is kinda ugly as you noticed :p

Could %current-target-system be set outside of the monadic context so
that we can access it from wherever we want?

That would also solve the issue I have with canonical-package procedure[1],
that read %current-target-system outside of the monadic context, where
is is always #f.

Thanks for your help,

Mathieu
[1]: https://lists.gnu.org/archive/html/guix-devel/2019-12/msg00353.html
diff mbox series

Patch

From 21af4b796fb638c0c70a4b73d9add53ee2e9747e Mon Sep 17 00:00:00 2001
From: Mathieu Othacehe <m.othacehe@gmail.com>
Date: Sat, 28 Dec 2019 21:53:05 +0100
Subject: [PATCH 2/2] gexp: lower-gexp: Do not pass default target to
 lower-object.

Default target argument of lower-object is no longer #f but the current target
system. However, even if %current-target-system is set, we do not want to
cross-compile gexp extensions.

* guix/gexp.scm (lower-gexp): Make sure that extensions are not cross-built by
passing #f as target argument of lower-object.
---
 guix/gexp.scm | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/guix/gexp.scm b/guix/gexp.scm
index 11d4e86037..027701a201 100644
--- a/guix/gexp.scm
+++ b/guix/gexp.scm
@@ -756,7 +756,8 @@  derivations--e.g., code evaluated for its side effects."
                        (extensions -> (gexp-extensions exp))
                        (exts     (mapm %store-monad
                                        (lambda (obj)
-                                         (lower-object obj system))
+                                         (lower-object obj system
+                                                       #:target #f))
                                        extensions))
                        (modules+compiled (imported+compiled-modules
                                           %modules system
-- 
2.24.1