From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id sAL1JRFhlWByKgAAgWs5BA (envelope-from ) for ; Fri, 07 May 2021 17:47:29 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id GIWvIRFhlWCvNAAA1q6Kng (envelope-from ) for ; Fri, 07 May 2021 15:47:29 +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 0C5361EC8E for ; Fri, 7 May 2021 17:47:29 +0200 (CEST) Received: from localhost ([::1]:51272 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lf2hM-00025P-4i for larch@yhetil.org; Fri, 07 May 2021 11:47:28 -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 Content-Transfer-Encoding: 8bit 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+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1620402449; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=ICtQ51TRk4yfPn3oMuR0U9FsL3PtXzoYjxjK4T3THa0=; b=XUCopoFBpbxGXk/vgbkdmO1i0EZlp8i3EIDGJkR1WNAGE+0R4wqcX4gYm/Kc7Gw1NuR8J+ Nw9jGgAvhU9uay/+GHrAJiylTfSwC+EasannoszU+R2Qen0Dy/5t23nueuAur6VF2ws5t1 /axuXOqgWqq6rv7Ns18wgUvaoXhexvW6ujfX/hbmphIaxKXzGC0kw2Y4eiFoXZxIGFNUcN BQI01TAkQgSw6e1HTenTwiz7CXsfsAiOSQAbBLoeUIa0Qr5W+uijRQo6lr9PJAR2Hiwqi6 lHJzFL+Y/+1eay+J/ulqiHEWMzASKDFWvBPzPBTP89xepVx0C6et3QwGMeqoqg== ARC-Seal: i=2; s=key1; d=yhetil.org; t=1620402449; a=rsa-sha256; cv=fail; b=uW00iX3045OtCjWoAXEhp922PJ8xcosa8ZyETUmYyy/7Frg2sPUqKqtUDZN3hrFND8/ccY xBxgCz41/1vtmMK5Y1B2qEfofbmqr3ivBGPRu61qukcT2mz7Kc281QQLfUNFmZ3Num4m2l YWQ1c31p83wtEk4yFUM/KnRpySKmO2qQcq7v5tZLvn03qRLoU8tKXiiudxwnUcmcHm27Po PwneNY8pwATA8qaiVmXTR4VnuvOAqQv0wdsw5nXtL59C2CzO/16AH9Vg1OLvgkewF3k1X1 V78hyJAlYt8/ZWKK7ajZnOpxF5ae8aWoDgM7dhpjFBKLWOCwbh2YvvHbolAhUg== ARC-Authentication-Results: i=2; aspmx1.migadu.com; dkim=none ("invalid DKIM record") header.d=beaver-labs.com header.s=zoho header.b=KrxHQqgt; arc=reject ("signature check failed: fail, {[1] = sig:zohomail.com:reject}"); dmarc=none; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Spam-Score: 6.05 Authentication-Results: aspmx1.migadu.com; dkim=none ("invalid DKIM record") header.d=beaver-labs.com header.s=zoho header.b=KrxHQqgt; arc=reject ("signature check failed: fail, {[1] = sig:zohomail.com:reject}"); dmarc=none; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Queue-Id: 0C5361EC8E X-Spam-Score: 6.05 X-Migadu-Scanner: scn0.migadu.com X-TUID: Qg6qQF8Dd7kR 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. -- 2.31.1