From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id gNqwCC3AuV4DUQAA0tVLHw (envelope-from ) for ; Mon, 11 May 2020 21:14:21 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id MF0zDTvAuV6GfAAAbx9fmQ (envelope-from ) for ; Mon, 11 May 2020 21:14:35 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id C96059400AB for ; Mon, 11 May 2020 21:14:32 +0000 (UTC) Received: from localhost ([::1]:39424 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jYFku-0005ZX-9i for larch@yhetil.org; Mon, 11 May 2020 17:14:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39718) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jYFkR-000525-7j for bug-guix@gnu.org; Mon, 11 May 2020 17:14:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:41936) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jYFkP-0006Cf-Op for bug-guix@gnu.org; Mon, 11 May 2020 17:14:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jYFkP-0003Vg-Ji for bug-guix@gnu.org; Mon, 11 May 2020 17:14:01 -0400 X-Loop: help-debbugs@gnu.org Subject: bug#41182: Profile hooks ignore system and target Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Mon, 11 May 2020 21:14:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 41182 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: 41182@debbugs.gnu.org Received: via spool by 41182-submit@debbugs.gnu.org id=B41182.158923159513428 (code B ref 41182); Mon, 11 May 2020 21:14:01 +0000 Received: (at 41182) by debbugs.gnu.org; 11 May 2020 21:13:15 +0000 Received: from localhost ([127.0.0.1]:53482 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jYFje-0003UW-To for submit@debbugs.gnu.org; Mon, 11 May 2020 17:13:15 -0400 Received: from eggs.gnu.org ([209.51.188.92]:36636) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jYFjd-0003UK-EL for 41182@debbugs.gnu.org; Mon, 11 May 2020 17:13:13 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:54064) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jYFjY-00065r-6H; Mon, 11 May 2020 17:13:08 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=39330 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1jYFjS-0004yb-E8; Mon, 11 May 2020 17:13:06 -0400 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= References: <87a72f8qzi.fsf@inria.fr> Date: Mon, 11 May 2020 23:13:00 +0200 In-Reply-To: <87a72f8qzi.fsf@inria.fr> ("Ludovic \=\?utf-8\?Q\?Court\=C3\=A8s\=22\?\= \=\?utf-8\?Q\?'s\?\= message of "Sun, 10 May 2020 22:38:57 +0200") Message-ID: <87k11idvkz.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-Spam-Score: -3.3 (---) X-BeenThere: bug-guix@gnu.org List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mathieu Othacehe Errors-To: bug-guix-bounces+larch=yhetil.org@gnu.org Sender: "bug-Guix" X-Scanner: scn0 X-Spam-Score: -1.01 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of bug-guix-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=bug-guix-bounces@gnu.org X-Scan-Result: default: False [-1.01 / 13.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; GENERIC_REPUTATION(0.00)[-0.5401123721036]; TO_DN_SOME(0.00)[]; R_SPF_ALLOW(-0.20)[+ip4:209.51.188.0/24:c]; IP_REPUTATION_HAM(0.00)[asn: 22989(0.07), country: US(-0.00), ip: 209.51.188.17(-0.54)]; DWL_DNSWL_FAIL(0.00)[209.51.188.17:server fail]; MX_GOOD(-0.50)[cached: eggs.gnu.org]; RCPT_COUNT_TWO(0.00)[2]; MAILLIST(-0.20)[mailman]; FORGED_RECIPIENTS_MAILLIST(0.00)[]; RCVD_TLS_LAST(0.00)[]; R_DKIM_NA(0.00)[]; ASN(0.00)[asn:22989, ipnet:209.51.188.0/24, country:US]; TAGGED_FROM(0.00)[larch=yhetil.org]; ARC_NA(0.00)[]; FROM_NEQ_ENVFROM(0.00)[ludo@gnu.org,bug-guix-bounces@gnu.org]; FROM_HAS_DN(0.00)[]; URIBL_BLOCKED(0.00)[gnu.org:email]; MID_RHS_MATCH_FROM(0.00)[]; TAGGED_RCPT(0.00)[]; MIME_GOOD(-0.10)[multipart/mixed,text/plain,text/x-patch]; DMARC_NA(0.00)[gnu.org]; HAS_LIST_UNSUB(-0.01)[]; DNSWL_BLOCKED(0.00)[209.51.188.17:from]; MIME_TRACE(0.00)[0:+,1:+,2:+]; RWL_MAILSPIKE_POSSIBLE(0.00)[209.51.188.17:from]; FREEMAIL_CC(0.00)[gmail.com]; RCVD_COUNT_SEVEN(0.00)[9]; FORGED_SENDER_MAILLIST(0.00)[] X-TUID: /8RZuciDitA/ --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi, Ludovic Court=C3=A8s skribis: > Actually all the profile hooks refer to the native derivation. I=E2=80=99ve looked at it and this problem is surprisingly tricky to addres= s. I=E2=80=99ve tried to address it in an API-compatible way, which meant sett= ing the =E2=80=98%current-system=E2=80=99 and =E2=80=98%current-target-system= =E2=80=99 parameters around the hook calls, but that is ugly, hard to get right (dynamic binding and monadic code really don=E2=80=99t go together well :-/), and actually raises another issue (=E2=80=98mapm/accumulate-builds=E2=80=99 appears to ignore t= he initial dynamic bindings for these two parameters). Hacky patch attached to illustrate. So I=E2=80=99m very much tempted to instead require each hook to take =E2= =80=98system=E2=80=99 and =E2=80=98#:target=E2=80=99 arguments and pass them to =E2=80=98gexp->de= rivation=E2=80=99. It=E2=80=99ll break the API, in case someone out there has custom profile hooks (unlikely given that it=E2=80=99s not really documented), but I=E2=80=99d s= ay that=E2=80=99s OK. Thoughts? Ludo=E2=80=99. --=-=-= Content-Type: text/x-patch Content-Disposition: inline diff --git a/gnu/packages/commencement.scm b/gnu/packages/commencement.scm index 59ef5d078b..4f90e9e41d 100644 --- a/gnu/packages/commencement.scm +++ b/gnu/packages/commencement.scm @@ -3013,9 +3013,10 @@ memoized as a function of '%current-system'." '/memoized)))) #'(begin (define memoized - (mlambda (system) exp)) + (mlambda (system target) exp)) (define-syntax identifier - (identifier-syntax (memoized (%current-system)))))))))) + (identifier-syntax (memoized (%current-system) + (%current-target-system)))))))))) (define/system-dependent linux-libre-headers-boot0 ;; Note: this is wrapped in a thunk to nicely handle circular dependencies diff --git a/guix/profiles.scm b/guix/profiles.scm index 25ff146bdf..58d7e0e450 100644 --- a/guix/profiles.scm +++ b/guix/profiles.scm @@ -1580,6 +1580,18 @@ This is one of the things to do for the result to be relocatable. When TARGET is true, it must be a GNU triplet, and the packages in MANIFEST are cross-built for TARGET." + (define (call-with-system+target system target thunk) + (mlet* %store-monad ((system0 (set-current-system system)) + (target0 (set-current-target (pk 'set-target target))) + (result (thunk))) + (mbegin %store-monad + (set-current-system system0) + (set-current-target target0) + (return result)))) + + (define-syntax-rule (with-system+target system target exp) + (call-with-system+target system target (lambda () exp))) + (mlet* %store-monad ((system (if system (return system) (current-system))) @@ -1592,9 +1604,12 @@ are cross-built for TARGET." #:target target))) (extras (if (null? (manifest-entries manifest)) (return '()) - (mapm/accumulate-builds (lambda (hook) - (hook manifest)) - hooks)))) + (with-system+target + system + target + (mapm/accumulate-builds (lambda (hook) + (hook manifest)) + hooks))))) (define inputs (append (filter-map (lambda (drv) (and (derivation? drv) @@ -1689,6 +1704,8 @@ are cross-built for TARGET." (match profile (($ name manifest hooks locales? allow-collisions? relative-symlinks?) + (pk 'prof-c system target (%current-target-system)) + ;; (display-backtrace (make-stack #t) (current-error-port) #f 80) (profile-derivation manifest #:name name #:hooks hooks diff --git a/guix/store.scm b/guix/store.scm index 6c7c07fd2d..92158bd658 100644 --- a/guix/store.scm +++ b/guix/store.scm @@ -1899,7 +1899,10 @@ coalesce them into a single call." (values (map/accumulate-builds store (lambda (obj) (run-with-store store - (mproc obj))) + (mproc obj) + ;; #:system (%current-system) + ;; #:target (%current-target-system) + )) lst) store))) --=-=-=--