all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [bug#48277] [PATCH 0/1] New wrap-in-search-paths function
@ 2021-05-07 15:42 Edouard Klein
  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
  0 siblings, 2 replies; 4+ messages in thread
From: Edouard Klein @ 2021-05-07 15:42 UTC (permalink / raw)
  To: 48277; +Cc: Edouard Klein

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





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-05-09 19:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-05-07 15:42 [bug#48277] [PATCH 0/1] New wrap-in-search-paths function Edouard Klein
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

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.