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: Edouard Klein <edk@beaver-labs.com>
Subject: [bug#48277] [PATCH 0/1] New wrap-in-search-paths function
Date: Fri,  7 May 2021 17:42:08 +0200	[thread overview]
Message-ID: <20210507154208.123628-1-edk@beaver-labs.com> (raw)

This patch adds the wrap-in-search-paths function.

This function takes an executable and a list of packages as arguments, and wrap the executable in the search-paths needed by the list of packages.

Two use-cases have pushed me to create this function, but I suspect it may be useful in other cases.

First, when running on a foreign distro, guix packages (especially python packages) can break the foreign distribution by putting Guix's python interpreter before the host's in the PATH. Scripts that rely on a #!/usr/bin/env python shebang then breaks. This for example breaks gdm on the latest Ubuntu when you install any package for which python is a propagated input.

This new function solves this problem by allowing one to write a G-exp that wraps the needed execs in the search paths for their packages, without putting them in the default profile, therefore avoiding masking the host's command.

A second use case is when defining operating-system-services, the system profile is not available to the environment where the command is launched, so if this command has any dynamically loaded part (as most executable today do), they won't be found despite being installed and present in the system profile.

This new function solves the problem by allowing one to wrap the service executable with an activation-service, to that the sheperd-service can launch it wihtout having to source the system profile.

See this thread on help-guix to see an example of the problem:
https://lists.gnu.org/archive/html/help-guix/2021-04/msg00100.html

Here is an example that can be built with guix build -f and demonstrate the use of the function. The (quite useless) resulting script will output the current version of flask, despite the flask binary not being in the current profile's PATH:


(use-modules (gnu packages python-web)
             (gnu packages bash)
             (guix gexp)
             (guix modules)
             (guix search-paths)
             (gnu packages guile)
             (gnu packages gnupg))


(with-extensions
 (list guile-zlib guile-gcrypt)
 (with-imported-modules
     (source-module-closure
      '((guix build utils)
        (guix search-paths)
        ))
   #~(begin
       (use-modules (guix build utils)
                    (guix search-paths))
       (mkdir-p (string-append #$output "/bin/"))
       (with-output-to-file (string-append #$output "/bin/flask-version")
         (lambda _
           (display (string-append "#!" #$bash "/bin/bash\n"))
           (display "flask --version\n")))
       (chmod  (string-append #$output "/bin/flask-version") #o755)
       (set-path-environment-variable "PATH" '("bin") (list #$bash))
       #$(wrap-in-search-paths #~(string-append #$output "/bin/flask-version") (list python-flask)))))


Edouard Klein (1):
  guix: search-paths: Add wrap-in-search-paths

 guix/search-paths.scm | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

-- 
2.31.1





             reply	other threads:[~2021-05-07 16:10 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-07 15:42 Edouard Klein [this message]
2021-05-07 15:45 ` [bug#48277] [PATCH 1/1] guix: search-paths: Add wrap-in-search-paths Edouard Klein
2021-05-09 18:15 ` [bug#48277] [PATCH 0/1] New wrap-in-search-paths function 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=20210507154208.123628-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).