From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id IJBfGH9mlWB2MwAAgWs5BA (envelope-from ) for ; Fri, 07 May 2021 18:10:39 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id wBz7E39mlWCpVAAAbx9fmQ (envelope-from ) for ; Fri, 07 May 2021 16:10:39 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id D94181804D for ; Fri, 7 May 2021 18:10:38 +0200 (CEST) Received: from localhost ([::1]:49406 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lf2dR-0000st-HS for larch@yhetil.org; Fri, 07 May 2021 11:43:25 -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 Content-Transfer-Encoding: 8bit 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+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1620403839; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=Ft04r6IviiHYiBxfX9DVAkJOPTB+d2ySb0JC4iXAKdU=; b=ARZeskFBL+iNfexOUFZh6MvT/hhMdyayTqszF5Yq45juk+vuc2bsC+xt39E6sQb0/KpI8Y Hlt4kAgYEauLkm8B4u9GUt0Q74zOtcXwZ7/A2mWg6jAz60EdtsqV9xi/QFlVPsvbnFbhN1 4tUpDWQqrULE3GAYgEVGUeCJdDDhTPDhna1ABFUsiBpSrGHz0UDkCHRZJCxLm6wsV6gWgW HDIDd0mBdYrO7djPcaQg1aHDB1KvLk+whUcOv6QLe/mMM+65/Ufuw54/7vwcwinbHZtFEQ pEqCrb09dMlSFCuL8lFx203ENSPVuQtwIulP2IAhEoe8Rwfo1tjNFd9TRpW6eA== ARC-Seal: i=2; s=key1; d=yhetil.org; t=1620403839; a=rsa-sha256; cv=fail; b=lJ5MXnmhLeFmn9WQx+TffLO6c0BAb7SHUQ2T9KoSUv1CfmHY3fdJvi7TEpk3/N1A7/JBVP Em+mfVErlhyio0bXB3haILzpfHwgnXRWSysDyw80+9MxnkVMh5DhAmmndu3DEmfznUQ7XG eMpfjaxotYOnbw28BtfEZnAA+6smir1+pUhc/3gn7kzEPY75CA5vcPTSiwgspD5/vY7t6Q 2CmMc9CWAKx62C62Ib44FK+hMRtm3cLbcA/exs+0PMyeGvFIr2bLAwE7ebIksTsab2fPxX y3xUUtue4j1HU8H5Iusu1CqIfT/ThASLCzzNALbVTrrcolvw69Oo81+8+lFwOw== ARC-Authentication-Results: i=2; aspmx1.migadu.com; dkim=none ("invalid DKIM record") header.d=beaver-labs.com header.s=zoho header.b=FUOFhncX; arc=reject ("signature check failed: fail, {[1] = sig:zohomail.com:reject}"); dmarc=none; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Spam-Score: 6.05 Authentication-Results: aspmx1.migadu.com; dkim=none ("invalid DKIM record") header.d=beaver-labs.com header.s=zoho header.b=FUOFhncX; arc=reject ("signature check failed: fail, {[1] = sig:zohomail.com:reject}"); dmarc=none; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Queue-Id: D94181804D X-Spam-Score: 6.05 X-Migadu-Scanner: scn0.migadu.com X-TUID: APBuB3Rnh7K1 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