EEdouard Klein wrote on 7 May 2021 17:42
(address . email@example.com)(name . Edouard Klein)(address . firstname.lastname@example.org)
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:
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)
(gnu packages guile)
(gnu packages gnupg))
(list guile-zlib guile-gcrypt)
'((guix build utils)
(use-modules (guix build utils)
(mkdir-p (string-append #$output "/bin/"))
(with-output-to-file (string-append #$output "/bin/flask-version")
(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(+)