From patchwork Fri May 7 15:42:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Edouard Klein X-Patchwork-Id: 100 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id AEC3A27BC82; Fri, 7 May 2021 16:43:22 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS, T_DKIM_INVALID,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 41C1527BC81 for ; Fri, 7 May 2021 16:43:22 +0100 (BST) Received: from localhost ([::1]:49406 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lf2dN-0000st-DM for patchwork@mira.cbaines.net; Fri, 07 May 2021 11:43:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52416) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lf2d4-0000qU-Lk for guix-patches@gnu.org; Fri, 07 May 2021 11:43:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:33049) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lf2d4-0004FK-E9 for guix-patches@gnu.org; Fri, 07 May 2021 11:43:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lf2d4-000892-C9 for guix-patches@gnu.org; Fri, 07 May 2021 11:43:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#48277] [PATCH 0/1] New wrap-in-search-paths function Resent-From: Edouard Klein Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 07 May 2021 15:43:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 48277 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 48277@debbugs.gnu.org Cc: Edouard Klein X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.162040217631300 (code B ref -1); Fri, 07 May 2021 15:43:02 +0000 Received: (at submit) by debbugs.gnu.org; 7 May 2021 15:42:56 +0000 Received: from localhost ([127.0.0.1]:44595 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lf2cy-00088m-4E for submit@debbugs.gnu.org; Fri, 07 May 2021 11:42:56 -0400 Received: from lists.gnu.org ([209.51.188.17]:50770) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lf2cw-00088g-SV for submit@debbugs.gnu.org; Fri, 07 May 2021 11:42:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52392) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lf2cw-0000ig-LO for guix-patches@gnu.org; Fri, 07 May 2021 11:42:54 -0400 Received: from sender4-op-o11.zoho.com ([136.143.188.11]:17159) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lf2cu-00042q-Di for guix-patches@gnu.org; Fri, 07 May 2021 11:42:54 -0400 ARC-Seal: i=1; a=rsa-sha256; t=1620402166; cv=none; d=zohomail.com; s=zohoarc; b=GoxsFITMtI9ZUdxOdoJvMXvN9KNUOpmZtEYgufulJzmw5s/8wo6dfNbfMkpJgAeWt56kHO7tJezmRGBfAxxaiFHjiuFtrmOCUcVj3FhLCA3U1Y8rO1bpwqD88Q/YxQXSycBqjLOlWA0EANUnb918GOtAG7DFcZJtKJMNnyAmwAk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620402166; h=Content-Transfer-Encoding:Cc:Date:From:MIME-Version:Message-ID:Subject:To; bh=Ft04r6IviiHYiBxfX9DVAkJOPTB+d2ySb0JC4iXAKdU=; b=gbkY+zhen1CH0JFaJSWiTyH36+Ukfv5SmFCdF3su+81eZkBIhP/CDyrZCEsFBTlxmAdZUQ1VqSLy/G03PnMJxIVtVs3KbfcxilHbjqmvYWzhkv55UZ/NFTUNYPNqqG/C4RcqF5Nuen6CaKBLtN5hj3uaagJVGb82YUFdwc8aBHU= 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=1620402166; 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=Ft04r6IviiHYiBxfX9DVAkJOPTB+d2ySb0JC4iXAKdU=; b=FUOFhncXrcBQ2RmD/BeJPQ28GudXpnIMXcKPGS6AO6WZjvaK+WSaSGV66MYq3PIb gcQoWrZsrlBqLGWCorVZGcczv9EQzb0wVL1ibSD38fraNPd1shmQrT5b6Qht0p1caKq 87MGm96DNGDm9invJiW/ArXGeodEMmN4rPryPVW4= 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 1620402162999986.6860700940545; Fri, 7 May 2021 08:42:42 -0700 (PDT) From: Edouard Klein Date: Fri, 7 May 2021 17:42:08 +0200 Message-Id: <20210507154208.123628-1-edk@beaver-labs.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-ZohoMailClient: External Received-SPF: pass client-ip=136.143.188.11; envelope-from=edk@beaver-labs.com; helo=sender4-op-o11.zoho.com X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action 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+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches 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(+)