From patchwork Fri May 7 15:45:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Edouard Klein X-Patchwork-Id: 29161 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 7EE1527BC82; Fri, 7 May 2021 16:47: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=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS, T_DKIM_INVALID,URIBL_BLOCKED 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 4688227BC81 for ; Fri, 7 May 2021 16:47:28 +0100 (BST) Received: from localhost ([::1]:51272 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lf2hL-00025P-Ht for patchwork@mira.cbaines.net; Fri, 07 May 2021 11:47:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53562) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lf2gw-00025D-Ow for guix-patches@gnu.org; Fri, 07 May 2021 11:47:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:33068) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lf2gw-0006o7-HZ for guix-patches@gnu.org; Fri, 07 May 2021 11:47:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lf2gw-0008CD-Er for guix-patches@gnu.org; Fri, 07 May 2021 11:47:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#48277] [PATCH 1/1] guix: search-paths: Add wrap-in-search-paths References: <20210507154208.123628-1-edk@beaver-labs.com> In-Reply-To: <20210507154208.123628-1-edk@beaver-labs.com> Resent-From: Edouard Klein Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 07 May 2021 15:47:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 48277 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 48277@debbugs.gnu.org Cc: edk@beaver-labs.com Received: via spool by 48277-submit@debbugs.gnu.org id=B48277.162040239231496 (code B ref 48277); Fri, 07 May 2021 15:47:02 +0000 Received: (at 48277) by debbugs.gnu.org; 7 May 2021 15:46:32 +0000 Received: from localhost ([127.0.0.1]:44613 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lf2gR-0008Bw-NG for submit@debbugs.gnu.org; Fri, 07 May 2021 11:46:31 -0400 Received: from sender4-op-o11.zoho.com ([136.143.188.11]:17127) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lf2gP-0008Bq-T8 for 48277@debbugs.gnu.org; Fri, 07 May 2021 11:46:30 -0400 ARC-Seal: i=1; a=rsa-sha256; t=1620402387; cv=none; d=zohomail.com; s=zohoarc; b=YKDSQ6bjZ8FOAI7KKIoxvuvJVg84gdQZ5E4kDnhZ95njv8K2lZjVkU7bKjMn8NeC7lAFBpyp5pKqfN2a9lcQ90y7GcvBuF6eeuYc4eXqtBX5r6L9bxkFK467GIvqFCp5Yb0bmwpPM1X10dFz6Alfq60qbliw8aMZOdznDytzpEs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620402387; h=Content-Transfer-Encoding:Cc:Date:From:MIME-Version:Message-ID:Subject:To; bh=ICtQ51TRk4yfPn3oMuR0U9FsL3PtXzoYjxjK4T3THa0=; b=H6uOy89vfPN/NN4+qldOlGkTa6gG1LIIiHNuX0rGdsw5nEn3mHGKilqEcmR1/5s3dySyKauuDC2hD8REQiYDIqdR0sKnPSIcpLR8m7Pgw+/eqHsIyxdN+iGAqaks/RwKkb83A5OkxuyP3Lg2Gut5K57e+9Mgd/8Tw/45pxxdCps= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=beaver-labs.com; spf=pass smtp.mailfrom=edk@beaver-labs.com; dmarc=pass header.from= header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1620402387; s=zoho; d=beaver-labs.com; i=edk@beaver-labs.com; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version:Content-Transfer-Encoding; bh=ICtQ51TRk4yfPn3oMuR0U9FsL3PtXzoYjxjK4T3THa0=; b=KrxHQqgtSPupgPUff4L2AsHACFnJ0NCKmaaNAw7eFU0aVKb/+Kc0wA1rp/3+BaMk 0puB66fxcViQmTMyjTRSFoQdNQj3XkxQzZOCSBiWafc0bCKGrYz/fz80II6ToR4VWkQ S1RjsgA/vvs7SZemPIfdf0b7aSmFcnXzLnH33m1w= Received: from Rasoir.home (lfbn-idf3-1-808-29.w90-3.abo.wanadoo.fr [90.3.133.29]) by mx.zohomail.com with SMTPS id 1620402381114373.7891932316927; Fri, 7 May 2021 08:46:21 -0700 (PDT) From: Edouard Klein Date: Fri, 7 May 2021 17:45:05 +0200 Message-Id: <20210507154503.124177-1-edk@beaver-labs.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-ZohoMailClient: External 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 From: edk@beaver-labs.com --- guix/search-paths.scm | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/guix/search-paths.scm b/guix/search-paths.scm index 002e6342bb..34a632077c 100644 --- a/guix/search-paths.scm +++ b/guix/search-paths.scm @@ -18,6 +18,8 @@ (define-module (guix search-paths) #:use-module (guix records) + #:use-module (guix profiles) + #:use-module (guix gexp) #:use-module (guix build utils) #:use-module (srfi srfi-1) #:use-module (srfi srfi-26) @@ -35,6 +37,8 @@ search-path-specification->sexp sexp->search-path-specification + esps->wrap-sexp + wrap-in-search-paths string-tokenize* evaluate-search-paths environment-variable-definition @@ -96,6 +100,37 @@ a object." (with-error-to-port (%make-void-port "w") (lambda () exp))) +(define (esps->wrap-sexp esps) + "Return a list '(VARIABLE POSITION (STRING)) as expected by wrap-program, converted from the evaluated search-path-specification ESPS. + + An evaluated search-path-specification is the type of things returned in a list by evaluate-search-paths: (sps . string) couples. + + We do abuse wrap-program a bit, because it expects a list of directories, and the string we return is already a concatenation of the relevant directories. There would be no point in splitting it again and then having wrap-program joining it again, so we just pass it as is." + (match esps + ((sps . str) `(,(search-path-specification-variable sps) = (,str))))) + +(define (wrap-in-search-paths exec packages) + "Wrap EXEC in a script that will set the search paths to the values needed by the list of package PACKAGES." + (define (reconstruct-sps sps) + "Return a G-exp that evaluates, on the build strata, to the search-path-specification SPS." + #~(search-path-specification + (variable #$(search-path-specification-variable sps)) + (files (list #$@(search-path-specification-files sps))) + (separator #$(search-path-specification-separator sps)) + (file-type (quote #$(search-path-specification-file-type sps))) + (file-pattern #$(search-path-specification-file-pattern sps)))) + + (define (reconstruct-sps-list spsl) + "Return a G-exp that evaluates, on the build strata, to the list of search-path-specifications SPSL." + #~(list #$@(map reconstruct-sps spsl))) + + (let ((manifest (packages->manifest packages))) + #~(apply wrap-program #$exec + (map esps->wrap-sexp + (evaluate-search-paths + #$(reconstruct-sps-list (manifest-search-paths manifest)) + (list #$@(map manifest-entry-item (manifest-transitive-entries manifest)))))))) + ;; XXX: This procedure used to be in (guix utils) but since we want to be able ;; to use (guix search-paths) on the build side, we want to avoid the ;; dependency on (guix utils), and so this procedure is back here for now.