unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Edouard Klein <edk@beaver-labs.com>
To: 48277@debbugs.gnu.org
Cc: edk@beaver-labs.com
Subject: [bug#48277] [PATCH 1/1] guix: search-paths: Add wrap-in-search-paths
Date: Fri,  7 May 2021 17:45:05 +0200	[thread overview]
Message-ID: <20210507154503.124177-1-edk@beaver-labs.com> (raw)
In-Reply-To: <20210507154208.123628-1-edk@beaver-labs.com>

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 <search-path-specification> 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





  reply	other threads:[~2021-05-07 15:47 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-07 15:42 [bug#48277] [PATCH 0/1] New wrap-in-search-paths function Edouard Klein
2021-05-07 15:45 ` Edouard Klein [this message]
2021-05-09 18:15 ` Maxime Devos
2021-05-09 19:56   ` Edouard Klein

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210507154503.124177-1-edk@beaver-labs.com \
    --to=edk@beaver-labs.com \
    --cc=48277@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).