From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:470:142:3::10]:50750) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ipGVr-0000IR-7Y for guix-patches@gnu.org; Wed, 08 Jan 2020 13:57:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ipGVp-0002kr-Tv for guix-patches@gnu.org; Wed, 08 Jan 2020 13:57:03 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:45337) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ipGVp-0002kV-Mv for guix-patches@gnu.org; Wed, 08 Jan 2020 13:57:01 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ipGVp-0006W3-Mz for guix-patches@gnu.org; Wed, 08 Jan 2020 13:57:01 -0500 Subject: [bug#38678] [PATCH v2 1/4] graph: Add '--load-path' option. References: <20191219210958.8807-1-zimon.toutoune@gmail.com> In-Reply-To: <20191219210958.8807-1-zimon.toutoune@gmail.com> Resent-Message-ID: From: zimoun Date: Wed, 8 Jan 2020 19:56:21 +0100 Message-Id: <20200108185624.8609-1-zimon.toutoune@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: 38678@debbugs.gnu.org Cc: zimoun * guix/scripts/graph.scm (%option): Add '--load-path' option. * doc/guix.texi: Document it. * tests/guix-graph.sh: Test it. --- doc/guix.texi | 9 +++++++++ guix/scripts/graph.scm | 8 ++++++++ tests/guix-graph.sh | 27 +++++++++++++++++++++++++-- 3 files changed, 42 insertions(+), 2 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index bb0ef17ddd..37218eb847 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -69,6 +69,7 @@ Copyright @copyright{} 2019 Jakob L. Kreuze@* Copyright @copyright{} 2019 Kyle Andrews@* Copyright @copyright{} 2019 Alex Griffin@* Copyright @copyright{} 2019 Guillaume Le Vaillant@* +Copyright @copyright{} 2019 Simon Tournier@* Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or @@ -10037,6 +10038,14 @@ Display the graph for @var{system}---e.g., @code{i686-linux}. The package dependency graph is largely architecture-independent, but there are some architecture-dependent bits that this option allows you to visualize. + +@item --load-path=@var{directory} +@itemx -L @var{directory} +Add @var{directory} to the front of the package module search path +(@pxref{Package Modules}). + +This allows users to define their own packages and make them visible to +the command-line tools. @end table On top of that, @command{guix graph} supports all the usual package diff --git a/guix/scripts/graph.scm b/guix/scripts/graph.scm index 7558cb1e85..53f407b2fc 100644 --- a/guix/scripts/graph.scm +++ b/guix/scripts/graph.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2015, 2016, 2017, 2018, 2019 Ludovic Courtès +;;; Copyright © 2019 Simon Tournier ;;; ;;; This file is part of GNU Guix. ;;; @@ -35,6 +36,7 @@ #:use-module ((guix scripts build) #:select (show-transformation-options-help options->transformation + %standard-build-options %transformation-options)) #:use-module (srfi srfi-1) #:use-module (srfi srfi-26) @@ -473,6 +475,9 @@ package modules, while attempting to retain user package modules." (lambda (opt name arg result) (alist-cons 'system arg (alist-delete 'system result eq?)))) + (find (lambda (option) + (member "load-path" (option-names option))) + %standard-build-options) (option '(#\h "help") #f #f (lambda args (show-help) @@ -501,6 +506,9 @@ Emit a representation of the dependency graph of PACKAGE...\n")) (display (G_ " -s, --system=SYSTEM consider the graph for SYSTEM--e.g., \"i686-linux\"")) (newline) + (display (G_ " + -L, --load-path=DIR prepend DIR to the package module search path")) + (newline) (show-transformation-options-help) (newline) (display (G_ " diff --git a/tests/guix-graph.sh b/tests/guix-graph.sh index 2d4b3fac3f..4c37b61b38 100644 --- a/tests/guix-graph.sh +++ b/tests/guix-graph.sh @@ -1,5 +1,6 @@ # GNU Guix --- Functional package management for GNU # Copyright © 2015, 2016, 2019 Ludovic Courtès +# Copyright © 2019 Simon Tournier # # This file is part of GNU Guix. # @@ -20,10 +21,29 @@ # Test the 'guix graph' command-line utility. # -tmpfile1="t-guix-graph1-$$" -tmpfile2="t-guix-graph2-$$" +module_dir="t-guix-graph-$$" +mkdir "$module_dir" +trap "rm -rf $module_dir" EXIT + +tmpfile1="$module_dir/t-guix-graph1-$$" +tmpfile2="$module_dir/t-guix-graph2-$$" trap 'rm -f "$tmpfile1" "$tmpfile2"' EXIT + +cat > "$module_dir/foo.scm"<