From patchwork Sat Apr 24 08:14:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christopher Baines X-Patchwork-Id: 28843 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 22BE427BC7D; Sat, 24 Apr 2021 09:15:28 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-5.2 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS, UNPARSEABLE_RELAY autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 6C51E27BC7C for ; Sat, 24 Apr 2021 09:15:27 +0100 (BST) Received: from localhost ([::1]:36822 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1laDRm-00072y-La for patchwork@mira.cbaines.net; Sat, 24 Apr 2021 04:15:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59122) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1laDRO-00072r-Rt for guix-patches@gnu.org; Sat, 24 Apr 2021 04:15:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:56088) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1laDRO-0007b3-L1 for guix-patches@gnu.org; Sat, 24 Apr 2021 04:15:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1laDRO-0007WN-Fs for guix-patches@gnu.org; Sat, 24 Apr 2021 04:15:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#47989] [PATCH] channels: Add a #:system argument to channel-instances->manifest. Resent-From: Christopher Baines Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 24 Apr 2021 08:15:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 47989 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 47989@debbugs.gnu.org X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.161925204928833 (code B ref -1); Sat, 24 Apr 2021 08:15:02 +0000 Received: (at submit) by debbugs.gnu.org; 24 Apr 2021 08:14:09 +0000 Received: from localhost ([127.0.0.1]:39401 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1laDQW-0007Uz-Ln for submit@debbugs.gnu.org; Sat, 24 Apr 2021 04:14:09 -0400 Received: from lists.gnu.org ([209.51.188.17]:38390) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1laDQV-0007Up-3D for submit@debbugs.gnu.org; Sat, 24 Apr 2021 04:14:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58962) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1laDQU-0006zN-Sy for guix-patches@gnu.org; Sat, 24 Apr 2021 04:14:06 -0400 Received: from mira.cbaines.net ([212.71.252.8]:44906) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1laDQT-0006wk-1L for guix-patches@gnu.org; Sat, 24 Apr 2021 04:14:06 -0400 Received: from localhost (unknown [IPv6:2a02:8010:68c1:0:8ac0:b4c7:f5c8:7caa]) by mira.cbaines.net (Postfix) with ESMTPSA id 9CA1027BC7C for ; Sat, 24 Apr 2021 09:14:03 +0100 (BST) Received: from localhost (localhost [local]) by localhost (OpenSMTPD) with ESMTPA id a510ae54 for ; Sat, 24 Apr 2021 08:14:02 +0000 (UTC) From: Christopher Baines Date: Sat, 24 Apr 2021 09:14:02 +0100 Message-Id: <20210424081402.26742-1-mail@cbaines.net> X-Mailer: git-send-email 2.30.1 MIME-Version: 1.0 Received-SPF: pass client-ip=212.71.252.8; envelope-from=mail@cbaines.net; helo=mira.cbaines.net X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches This allows computing a manifest for a specific system. Previously this was possible, but only through changing %current-system, which caused the derivation to be computed using that system as well (so computing a derivation for aarch64-linux on x86_64-linux would require running aarch64-linux code). This new argument adds the possibility of computing derivations for non-native systems, without having to run non-native code. I'm looking at this as it will enable the Guix Data Service to compute channel instance derivations without relying on QEMU emulation for non-native systems (it should be faster as well). * guix/channels.scm (build-from-source): Add #:system argument and pass to build. (build-channel-instance): Add system argument and pass to build-from-source. (channel-instance-derivations): Add #:system argument and pass to build-channel-instance, also rename system to current-system-value. (channel-instances->manifest): Add #:system argument and pass to channel-instance-derivations. --- guix/channels.scm | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/guix/channels.scm b/guix/channels.scm index c40fc0c507..70a09e74ff 100644 --- a/guix/channels.scm +++ b/guix/channels.scm @@ -657,7 +657,7 @@ that unconditionally resumes the continuation." store)))) (define* (build-from-source instance - #:key core verbose? (dependencies '())) + #:key core verbose? (dependencies '()) system) "Return a derivation to build Guix from INSTANCE, using the self-build script contained therein. When CORE is true, build package modules under SOURCE using CORE, an instance of Guix." @@ -700,20 +700,22 @@ SOURCE using CORE, an instance of Guix." (with-trivial-build-handler (build source #:verbose? verbose? #:version commit + #:system system #:channel-metadata (channel-instance->sexp instance) #:pull-version %pull-version)))) ;; Build a set of modules that extend Guix using the standard method. (standard-module-derivation name source core dependencies))) -(define* (build-channel-instance instance +(define* (build-channel-instance instance system #:optional core (dependencies '())) "Return, as a monadic value, the derivation for INSTANCE, a channel instance. DEPENDENCIES is a list of extensions providing Guile modules that INSTANCE depends on." (build-from-source instance #:core core - #:dependencies dependencies)) + #:dependencies dependencies + #:system system)) (define (resolve-dependencies instances) "Return a procedure that, given one of the elements of INSTANCES, returns @@ -743,7 +745,7 @@ list of instances it depends on." (lambda (instance) (vhash-foldq* cons '() instance edges))) -(define (channel-instance-derivations instances) +(define* (channel-instance-derivations instances #:key system) "Return the list of derivations to build INSTANCES, in the same order as INSTANCES." (define core-instance @@ -757,14 +759,15 @@ INSTANCES." (resolve-dependencies instances)) (define (instance->derivation instance) - (mlet %store-monad ((system (current-system))) + (mlet %store-monad ((current-system-value (current-system))) (mcached (if (eq? instance core-instance) - (build-channel-instance instance) + (build-channel-instance instance system) (mlet %store-monad ((core (instance->derivation core-instance)) (deps (mapm %store-monad instance->derivation (edges instance)))) - (build-channel-instance instance core deps))) + (build-channel-instance instance system core deps))) instance + current-system-value system))) (unless core-instance @@ -865,7 +868,7 @@ derivation." intro)))))) '())))) -(define (channel-instances->manifest instances) +(define* (channel-instances->manifest instances #:key system) "Return a profile manifest with entries for all of INSTANCES, a list of channel instances." (define (instance->entry instance drv) @@ -883,7 +886,8 @@ channel instances." (properties `((source ,(channel-instance->sexp instance))))))) - (mlet* %store-monad ((derivations (channel-instance-derivations instances)) + (mlet* %store-monad ((derivations (channel-instance-derivations instances + #:system system)) (entries -> (map instance->entry instances derivations))) (return (manifest entries))))