From fc4419098213673f713181d75f98df30255bd62c Mon Sep 17 00:00:00 2001 From: Maxime Devos Date: Sun, 18 Apr 2021 13:15:08 +0200 Subject: [PATCH 2/7] =?UTF-8?q?doc:=20Document=20new=20functionality=20of?= =?UTF-8?q?=20=E2=80=98which=E2=80=99.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * doc/guix.texi (File Search)[which]: Document the optional 'inputs' argument, and give an example on how to use the procedure. --- doc/guix.texi | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index a89701dd68..e8a9a31e1a 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -8679,11 +8679,25 @@ the root of the Guix source tree: @result{} ("./libformat.a" "./libstore.a" @dots{}) @end lisp -@deffn {Scheme Procedure} which @var{program} +@deffn {Scheme Procedure} which @var{program} [@var{inputs}=#false] Return the complete file name for @var{program} as found in -@code{$PATH}, or @code{#f} if @var{program} could not be found. +@code{$PATH}, or @code{#false} if @var{program} could not be found. +If @var{INPUTS} is not @code{#false}, instead look in the +@file{/bin} and @file{/sbin} subdirectories of @var{INPUTS}. +@var{inputs} is an alist; its keys are ignored. @end deffn +Here is an example using the @code{which} procedure in a build phase: + +@lisp +(lambda* (#:key outputs inputs #:allow-other-keys) + (let ((growpart (string-append (assoc-ref outputs "out") + "/bin/growpart"))) + (wrap-program growpart + `("PATH" ":" prefix (,(dirname (which "sfdisk" inputs)) + ,(dirname (which "readlink" inputs))))))) +@end lisp + @subsection Build Phases @cindex build phases -- 2.31.1