unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
* [bug#38678] [PATCH 0/2] Add '--load-path' to subcommands
@ 2019-12-19 21:09 zimoun
  2019-12-19 21:13 ` [bug#38678] [PATCH 1/2] graph: Add '--load-path' option zimoun
                   ` (7 more replies)
  0 siblings, 8 replies; 24+ messages in thread
From: zimoun @ 2019-12-19 21:09 UTC (permalink / raw)
  To: 38678; +Cc: zimoun

Dear,

Here [1] has been discussed the addition of '--load-path' to the commands that
need it. What come in mind is:

 + guix graph
 + guix size

Done by these 2 patches.


Note that "guix size -L" is not tested because the file "tests/guix-size.sh"
does exist and does the option "--load-path" needs to be tested at the Scheme
level?


Then, what about:

 - guix refresh: -L already means --list-updaters
   Only --load-path? Nothing?

 - guix edit: I am not convinced it is useful because if you apply -L
   path/to/your/modules then it is easy to find the correct file to open.
   What do you think?


Thanks
simon

[1] https://lists.gnu.org/archive/html/guix-devel/2019-12/msg00281.html


zimoun (2):
  graph: Add '--load-path' option.
  size: Add '--load-path' option.

 doc/guix.texi          | 15 +++++++++++++++
 guix/scripts/graph.scm | 10 +++++++++-
 guix/scripts/size.scm  |  8 ++++++++
 tests/guix-graph.sh    | 27 +++++++++++++++++++++++++--
 4 files changed, 57 insertions(+), 3 deletions(-)

-- 
2.23.0

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [bug#38678] [PATCH 1/2] graph: Add '--load-path' option.
  2019-12-19 21:09 [bug#38678] [PATCH 0/2] Add '--load-path' to subcommands zimoun
@ 2019-12-19 21:13 ` zimoun
  2019-12-19 21:14 ` [bug#38678] [PATCH 2/2] size: " zimoun
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 24+ messages in thread
From: zimoun @ 2019-12-19 21:13 UTC (permalink / raw)
  To: 38678; +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 | 10 +++++++++-
 tests/guix-graph.sh    | 27 +++++++++++++++++++++++++--
 3 files changed, 43 insertions(+), 3 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 7fa1eca097..02f7cf5b39 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..9bbb867147 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 <ludo@gnu.org>
+;;; Copyright © 2019 Simon Tournier <zimon.toutoune@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -35,7 +36,8 @@
   #:use-module ((guix scripts build)
                 #:select (show-transformation-options-help
                           options->transformation
-                          %transformation-options))
+                          %transformation-options
+                          %standard-build-options))
   #:use-module (srfi srfi-1)
   #:use-module (srfi srfi-26)
   #:use-module (srfi srfi-34)
@@ -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 <ludo@gnu.org>
+# Copyright © 2019 Simon Tournier <zimon.toutoune@gmail.com>
 #
 # 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"<<EOF
+(define-module (foo)
+  #:use-module (guix packages)
+  #:use-module (gnu packages base))
+
+(define-public dummy
+  (package (inherit hello)
+    (name "dummy")
+    (version "42")
+    (synopsis "dummy package")
+    (description "dummy package. Only used for testing purposes.")))
+EOF
+
+
 guix graph --version
 
 for package in guile-bootstrap coreutils python
@@ -59,3 +79,6 @@ guix graph git | grep 'label = "openssl'
 guix graph git --with-input=openssl=libressl | grep 'label = "libressl'
 if guix graph git --with-input=openssl=libressl | grep 'label = "openssl'
 then false; else true; fi
+
+# Try --load-path
+guix graph -L $module_dir dummy | grep 'label = "dummy'
-- 
2.23.0

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [bug#38678] [PATCH 2/2] size: Add '--load-path' option.
  2019-12-19 21:09 [bug#38678] [PATCH 0/2] Add '--load-path' to subcommands zimoun
  2019-12-19 21:13 ` [bug#38678] [PATCH 1/2] graph: Add '--load-path' option zimoun
@ 2019-12-19 21:14 ` zimoun
  2019-12-19 21:35   ` Pierre Neidhardt
  2020-01-08 18:53 ` [bug#38678] [PATCH v2 0/4] Add '--load-path' to subcommands zimoun
                   ` (5 subsequent siblings)
  7 siblings, 1 reply; 24+ messages in thread
From: zimoun @ 2019-12-19 21:14 UTC (permalink / raw)
  To: 38678; +Cc: zimoun

* guix/scripts/size.scm (%option): Add '--load-path' option.
* doc/guix.texi: Document it.
---
 doc/guix.texi         | 8 +++++++-
 guix/scripts/size.scm | 8 ++++++++
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 02f7cf5b39..c0fa6a3cab 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -69,7 +69,6 @@ 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
@@ -9837,6 +9836,13 @@ the case, @command{guix size} fails as it tries to load it.
 @itemx -s @var{system}
 Consider packages for @var{system}---e.g., @code{x86_64-linux}.
 
+@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
 
 @node Invoking guix graph
diff --git a/guix/scripts/size.scm b/guix/scripts/size.scm
index f549ce05b8..2446b84587 100644
--- a/guix/scripts/size.scm
+++ b/guix/scripts/size.scm
@@ -1,5 +1,6 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2015, 2016, 2017, 2018, 2019 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2019 Simon Tournier <zimon.toutoune@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -19,6 +20,7 @@
 (define-module (guix scripts size)
   #:use-module (guix ui)
   #:use-module (guix scripts)
+  #:use-module (guix scripts build)
   #:use-module (guix store)
   #:use-module (guix monads)
   #:use-module (guix combinators)
@@ -242,6 +244,9 @@ Report the size of PACKAGE and its dependencies.\n"))
   -m, --map-file=FILE    write to FILE a graphical map of disk usage"))
   (newline)
   (display (G_ "
+  -L, --load-path=DIR    prepend DIR to the package module search path"))
+  (newline)
+  (display (G_ "
   -h, --help             display this help and exit"))
   (display (G_ "
   -V, --version          display version information and exit"))
@@ -273,6 +278,9 @@ Report the size of PACKAGE and its dependencies.\n"))
         (option '(#\m "map-file") #t #f
                 (lambda (opt name arg result)
                   (alist-cons 'map-file arg result)))
+        (find (lambda (option)
+                (member "load-path" (option-names option)))
+              %standard-build-options)
         (option '(#\h "help") #f #f
                 (lambda args
                   (show-help)
-- 
2.23.0

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [bug#38678] [PATCH 2/2] size: Add '--load-path' option.
  2019-12-19 21:14 ` [bug#38678] [PATCH 2/2] size: " zimoun
@ 2019-12-19 21:35   ` Pierre Neidhardt
  2019-12-19 21:43     ` zimoun
  0 siblings, 1 reply; 24+ messages in thread
From: Pierre Neidhardt @ 2019-12-19 21:35 UTC (permalink / raw)
  To: zimoun; +Cc: 38678

[-- Attachment #1: Type: text/plain, Size: 564 bytes --]

I haven't tested, but otherwise looks good to me!
Comments below:

> diff --git a/doc/guix.texi b/doc/guix.texi
> index 02f7cf5b39..c0fa6a3cab 100644
> --- a/doc/guix.texi
> +++ b/doc/guix.texi
> @@ -69,7 +69,6 @@ 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@*

Did you remove the copyright line by mistake?

-- 
Pierre Neidhardt
https://ambrevar.xyz/

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [bug#38678] [PATCH 2/2] size: Add '--load-path' option.
  2019-12-19 21:35   ` Pierre Neidhardt
@ 2019-12-19 21:43     ` zimoun
  2019-12-19 21:48       ` Pierre Neidhardt
  0 siblings, 1 reply; 24+ messages in thread
From: zimoun @ 2019-12-19 21:43 UTC (permalink / raw)
  To: Pierre Neidhardt; +Cc: 38678

On Thu, 19 Dec 2019 at 22:35, Pierre Neidhardt <mail@ambrevar.xyz> wrote:

> I haven't tested, but otherwise looks good to me!

What do you think about the missing test?

Could also comment the cover letter (guix refresh, guix edit, etc.)?
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=38678#5


> > diff --git a/doc/guix.texi b/doc/guix.texi
> > index 02f7cf5b39..c0fa6a3cab 100644
> > --- a/doc/guix.texi
> > +++ b/doc/guix.texi
> > @@ -69,7 +69,6 @@ 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@*
>
> Did you remove the copyright line by mistake?

Maybe. :-)


Cheers,
simon

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [bug#38678] [PATCH 2/2] size: Add '--load-path' option.
  2019-12-19 21:43     ` zimoun
@ 2019-12-19 21:48       ` Pierre Neidhardt
  0 siblings, 0 replies; 24+ messages in thread
From: Pierre Neidhardt @ 2019-12-19 21:48 UTC (permalink / raw)
  To: zimoun; +Cc: 38678

[-- Attachment #1: Type: text/plain, Size: 388 bytes --]

> - guix refresh: -L already means --list-updaters
>   Only --load-path? Nothing?

Yes, --load-path is good enough.

> - guix edit: I am not convinced it is useful because if you apply -L
>   path/to/your/modules then it is easy to find the correct file to open.
>   What do you think?

Makes sense, then it's OK to leave it out.

-- 
Pierre Neidhardt
https://ambrevar.xyz/

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [bug#38678] [PATCH v2 0/4] Add '--load-path' to subcommands
  2019-12-19 21:09 [bug#38678] [PATCH 0/2] Add '--load-path' to subcommands zimoun
  2019-12-19 21:13 ` [bug#38678] [PATCH 1/2] graph: Add '--load-path' option zimoun
  2019-12-19 21:14 ` [bug#38678] [PATCH 2/2] size: " zimoun
@ 2020-01-08 18:53 ` zimoun
  2020-01-08 19:12   ` [bug#38678] [PATCH v3] better filter in 'refresh' zimoun
  2020-01-08 18:56 ` [bug#38678] [PATCH v2 1/4] graph: Add '--load-path' option zimoun
                   ` (4 subsequent siblings)
  7 siblings, 1 reply; 24+ messages in thread
From: zimoun @ 2020-01-08 18:53 UTC (permalink / raw)
  To: 38678; +Cc: Pierre Neidhardt

Dear,

Please find the amended patches about 'graph' and 'size'.

On Thu, 19 Dec 2019 at 22:10, zimoun <zimon.toutoune@gmail.com> wrote:

>  - guix refresh: -L already means --list-updaters
>    Only --load-path? Nothing?

The short option '-L' is dropped of the %standard-build-options.

Note that if I read correctly, nothing of the sucommand 'resfresh' is tested.

>  - guix edit: I am not convinced it is useful because if you apply -L
>    path/to/your/modules then it is easy to find the correct file to open.
>    What do you think?

Even it is easy to find the correct file to open, it adds consistency
with the other subcommands and it can help when using local channels.

Nothing about the subcommand 'edit' is tested neither.



All the best,
simon

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [bug#38678] [PATCH v2 1/4] graph: Add '--load-path' option.
  2019-12-19 21:09 [bug#38678] [PATCH 0/2] Add '--load-path' to subcommands zimoun
                   ` (2 preceding siblings ...)
  2020-01-08 18:53 ` [bug#38678] [PATCH v2 0/4] Add '--load-path' to subcommands zimoun
@ 2020-01-08 18:56 ` zimoun
  2020-01-08 18:56   ` [bug#38678] [PATCH v2 2/4] size: " zimoun
                     ` (2 more replies)
  2020-01-08 19:12 ` [bug#38678] [PATCH v3] refresh: " zimoun
                   ` (3 subsequent siblings)
  7 siblings, 3 replies; 24+ messages in thread
From: zimoun @ 2020-01-08 18:56 UTC (permalink / raw)
  To: 38678; +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 <ludo@gnu.org>
+;;; Copyright © 2019 Simon Tournier <zimon.toutoune@gmail.com>
 ;;;
 ;;; 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 <ludo@gnu.org>
+# Copyright © 2019 Simon Tournier <zimon.toutoune@gmail.com>
 #
 # 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"<<EOF
+(define-module (foo)
+  #:use-module (guix packages)
+  #:use-module (gnu packages base))
+
+(define-public dummy
+  (package (inherit hello)
+    (name "dummy")
+    (version "42")
+    (synopsis "dummy package")
+    (description "dummy package. Only used for testing purposes.")))
+EOF
+
+
 guix graph --version
 
 for package in guile-bootstrap coreutils python
@@ -59,3 +79,6 @@ guix graph git | grep 'label = "openssl'
 guix graph git --with-input=openssl=libressl | grep 'label = "libressl'
 if guix graph git --with-input=openssl=libressl | grep 'label = "openssl'
 then false; else true; fi
+
+# Try --load-path
+guix graph -L $module_dir dummy | grep 'label = "dummy'
-- 
2.23.0

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [bug#38678] [PATCH v2 2/4] size: Add '--load-path' option.
  2020-01-08 18:56 ` [bug#38678] [PATCH v2 1/4] graph: Add '--load-path' option zimoun
@ 2020-01-08 18:56   ` zimoun
  2020-01-08 18:56   ` [bug#38678] [PATCH v2 3/4] refresh: " zimoun
  2020-01-08 18:56   ` [bug#38678] [PATCH v2 4/4] edit: " zimoun
  2 siblings, 0 replies; 24+ messages in thread
From: zimoun @ 2020-01-08 18:56 UTC (permalink / raw)
  To: 38678; +Cc: zimoun

* guix/scripts/size.scm (%option): Add '--load-path' option.
* doc/guix.texi: Document it.
---
 doc/guix.texi         | 7 +++++++
 guix/scripts/size.scm | 8 ++++++++
 2 files changed, 15 insertions(+)

diff --git a/doc/guix.texi b/doc/guix.texi
index 37218eb847..3d26facd2e 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -9837,6 +9837,13 @@ the case, @command{guix size} fails as it tries to load it.
 @itemx -s @var{system}
 Consider packages for @var{system}---e.g., @code{x86_64-linux}.
 
+@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
 
 @node Invoking guix graph
diff --git a/guix/scripts/size.scm b/guix/scripts/size.scm
index f549ce05b8..2446b84587 100644
--- a/guix/scripts/size.scm
+++ b/guix/scripts/size.scm
@@ -1,5 +1,6 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2015, 2016, 2017, 2018, 2019 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2019 Simon Tournier <zimon.toutoune@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -19,6 +20,7 @@
 (define-module (guix scripts size)
   #:use-module (guix ui)
   #:use-module (guix scripts)
+  #:use-module (guix scripts build)
   #:use-module (guix store)
   #:use-module (guix monads)
   #:use-module (guix combinators)
@@ -242,6 +244,9 @@ Report the size of PACKAGE and its dependencies.\n"))
   -m, --map-file=FILE    write to FILE a graphical map of disk usage"))
   (newline)
   (display (G_ "
+  -L, --load-path=DIR    prepend DIR to the package module search path"))
+  (newline)
+  (display (G_ "
   -h, --help             display this help and exit"))
   (display (G_ "
   -V, --version          display version information and exit"))
@@ -273,6 +278,9 @@ Report the size of PACKAGE and its dependencies.\n"))
         (option '(#\m "map-file") #t #f
                 (lambda (opt name arg result)
                   (alist-cons 'map-file arg result)))
+        (find (lambda (option)
+                (member "load-path" (option-names option)))
+              %standard-build-options)
         (option '(#\h "help") #f #f
                 (lambda args
                   (show-help)
-- 
2.23.0

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [bug#38678] [PATCH v2 3/4] refresh: Add '--load-path' option.
  2020-01-08 18:56 ` [bug#38678] [PATCH v2 1/4] graph: Add '--load-path' option zimoun
  2020-01-08 18:56   ` [bug#38678] [PATCH v2 2/4] size: " zimoun
@ 2020-01-08 18:56   ` zimoun
  2020-01-08 18:56   ` [bug#38678] [PATCH v2 4/4] edit: " zimoun
  2 siblings, 0 replies; 24+ messages in thread
From: zimoun @ 2020-01-08 18:56 UTC (permalink / raw)
  To: 38678; +Cc: zimoun

* guix/scripts/refresh.scm (%option): Add '--load-path' option.
* doc/guix.texi: Document it.
---
 doc/guix.texi            |  9 ++++++++-
 guix/scripts/refresh.scm | 18 ++++++++++++++++++
 2 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 3d26facd2e..bee4c3b2c9 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -69,7 +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@*
+Copyright @copyright{} 2019, 2020 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
@@ -9552,6 +9552,13 @@ the user whether to download it or not.  This is the default behavior.
 @item --key-server=@var{host}
 Use @var{host} as the OpenPGP key server when importing a public key.
 
+@item --load-path=@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
 
 The @code{github} updater uses the
diff --git a/guix/scripts/refresh.scm b/guix/scripts/refresh.scm
index daf6fcf947..4695d0b517 100644
--- a/guix/scripts/refresh.scm
+++ b/guix/scripts/refresh.scm
@@ -7,6 +7,7 @@
 ;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
 ;;; Copyright © 2018 Efraim Flashner <efraim@flashner.co.il>
 ;;; Copyright © 2019 Ricardo Wurmus <rekado@elephly.net>
+;;; Copyright © 2020 Simon Tournier <zimon.toutoune@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -27,6 +28,7 @@
   #:use-module (guix ui)
   #:use-module (gcrypt hash)
   #:use-module (guix scripts)
+  #:use-module ((guix scripts build) #:select (%standard-build-options))
   #:use-module (guix store)
   #:use-module (guix utils)
   #:use-module (guix packages)
@@ -116,6 +118,19 @@
                      (leave (G_ "unsupported policy: ~a~%")
                             arg)))))
 
+        ;; The short option -L is already used by --list-updaters, therefore
+        ;; it needs to be removed from %standard-build-options.
+        (let ((%load-path-option (find (lambda (option)
+                                         (member "load-path"
+                                                 (option-names option)))
+                                       %standard-build-options)))
+          (option
+           (filter (lambda (name) (equal? "load-path" name))
+                   (option-names %load-path-option))
+           (option-required-arg? %load-path-option)
+           (option-optional-arg? %load-path-option)
+           (option-processor     %load-path-option)))
+
         (option '(#\h "help") #f #f
                 (lambda args
                   (show-help)
@@ -165,6 +180,9 @@ specified with `--select'.\n"))
                          'always', 'never', and 'interactive', which is also
                          used when 'key-download' is not specified"))
   (newline)
+  (display (G_ "
+      --load-path=DIR    prepend DIR to the package module search path"))
+  (newline)
   (display (G_ "
   -h, --help             display this help and exit"))
   (display (G_ "
-- 
2.23.0

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [bug#38678] [PATCH v2 4/4] edit: Add '--load-path' option.
  2020-01-08 18:56 ` [bug#38678] [PATCH v2 1/4] graph: Add '--load-path' option zimoun
  2020-01-08 18:56   ` [bug#38678] [PATCH v2 2/4] size: " zimoun
  2020-01-08 18:56   ` [bug#38678] [PATCH v2 3/4] refresh: " zimoun
@ 2020-01-08 18:56   ` zimoun
  2 siblings, 0 replies; 24+ messages in thread
From: zimoun @ 2020-01-08 18:56 UTC (permalink / raw)
  To: 38678; +Cc: zimoun

* guix/scripts/edit.scm (%option): Add '--load-path' option.
* doc/guix.texi: Document it.
---
 doc/guix.texi         |  4 ++++
 guix/scripts/edit.scm | 10 +++++++++-
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index bee4c3b2c9..00eb85a4f7 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -8705,6 +8705,10 @@ have created your own packages on @code{GUIX_PACKAGE_PATH}
 recipes.  In other cases, you will be able to examine the read-only recipes
 for packages currently in the store.
 
+Instead of @code{GUIX_PACKAGE_PATH}, the command-line option
+@code{--load-path=@var{directory}} (or in short @code{-L
+@var{directory}}) allows you to add @var{directory} to the front of the
+package module search path and so make your own packages visible.
 
 @node Invoking guix download
 @section Invoking @command{guix download}
diff --git a/guix/scripts/edit.scm b/guix/scripts/edit.scm
index da3d2775e8..a6fd1d2751 100644
--- a/guix/scripts/edit.scm
+++ b/guix/scripts/edit.scm
@@ -1,6 +1,7 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2015, 2016, 2019 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2015 Mathieu Lirzin <mthl@gnu.org>
+;;; Copyright © 2020 Simon Tournier <zimon.toutoune@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -20,6 +21,7 @@
 (define-module (guix scripts edit)
   #:use-module (guix ui)
   #:use-module (guix scripts)
+  #:use-module ((guix scripts build) #:select (%standard-build-options))
   #:use-module (guix utils)
   #:use-module (gnu packages)
   #:use-module (srfi srfi-1)
@@ -28,7 +30,10 @@
             guix-edit))
 
 (define %options
-  (list (option '(#\h "help") #f #f
+  (list (find (lambda (option)
+                (member "load-path" (option-names option)))
+              %standard-build-options)
+        (option '(#\h "help") #f #f
                 (lambda args
                   (show-help)
                   (exit 0)))
@@ -39,6 +44,9 @@
 (define (show-help)
   (display (G_ "Usage: guix edit PACKAGE...
 Start $VISUAL or $EDITOR to edit the definitions of PACKAGE...\n"))
+  (newline)
+  (display (G_ "
+  -L, --load-path=DIR    prepend DIR to the package module search path"))
   (newline)
   (display (G_ "
   -h, --help             display this help and exit"))
-- 
2.23.0

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [bug#38678] [PATCH v3] better filter in 'refresh'
  2020-01-08 18:53 ` [bug#38678] [PATCH v2 0/4] Add '--load-path' to subcommands zimoun
@ 2020-01-08 19:12   ` zimoun
  0 siblings, 0 replies; 24+ messages in thread
From: zimoun @ 2020-01-08 19:12 UTC (permalink / raw)
  To: 38678; +Cc: Pierre Neidhardt

On Wed, 8 Jan 2020 at 19:53, zimoun <zimon.toutoune@gmail.com> wrote:

> The short option '-L' is dropped of the %standard-build-options.

My bad!
The patch v2 keeps only "load-path" when only #\L must be dropped out.
It is more about style than concrete issue.


All the best,
simon

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [bug#38678] [PATCH v3] refresh: Add '--load-path' option.
  2019-12-19 21:09 [bug#38678] [PATCH 0/2] Add '--load-path' to subcommands zimoun
                   ` (3 preceding siblings ...)
  2020-01-08 18:56 ` [bug#38678] [PATCH v2 1/4] graph: Add '--load-path' option zimoun
@ 2020-01-08 19:12 ` zimoun
  2020-01-08 20:59 ` [bug#38678] what about "guix repl"? zimoun
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 24+ messages in thread
From: zimoun @ 2020-01-08 19:12 UTC (permalink / raw)
  To: 38678; +Cc: zimoun

* guix/scripts/refresh.scm (%option): Add '--load-path' option.
* doc/guix.texi: Document it.
---
 doc/guix.texi            |  9 ++++++++-
 guix/scripts/refresh.scm | 18 ++++++++++++++++++
 2 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 3d26facd2e..bee4c3b2c9 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -69,7 +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@*
+Copyright @copyright{} 2019, 2020 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
@@ -9552,6 +9552,13 @@ the user whether to download it or not.  This is the default behavior.
 @item --key-server=@var{host}
 Use @var{host} as the OpenPGP key server when importing a public key.
 
+@item --load-path=@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
 
 The @code{github} updater uses the
diff --git a/guix/scripts/refresh.scm b/guix/scripts/refresh.scm
index daf6fcf947..bc8e906054 100644
--- a/guix/scripts/refresh.scm
+++ b/guix/scripts/refresh.scm
@@ -7,6 +7,7 @@
 ;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
 ;;; Copyright © 2018 Efraim Flashner <efraim@flashner.co.il>
 ;;; Copyright © 2019 Ricardo Wurmus <rekado@elephly.net>
+;;; Copyright © 2020 Simon Tournier <zimon.toutoune@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -27,6 +28,7 @@
   #:use-module (guix ui)
   #:use-module (gcrypt hash)
   #:use-module (guix scripts)
+  #:use-module ((guix scripts build) #:select (%standard-build-options))
   #:use-module (guix store)
   #:use-module (guix utils)
   #:use-module (guix packages)
@@ -116,6 +118,19 @@
                      (leave (G_ "unsupported policy: ~a~%")
                             arg)))))
 
+        ;; The short option -L is already used by --list-updaters, therefore
+        ;; it needs to be removed from %standard-build-options.
+        (let ((%load-path-option (find (lambda (option)
+                                         (member "load-path"
+                                                 (option-names option)))
+                                       %standard-build-options)))
+          (option
+           (filter (lambda (name) (not (equal? #\L name)))
+                   (option-names %load-path-option))
+           (option-required-arg? %load-path-option)
+           (option-optional-arg? %load-path-option)
+           (option-processor     %load-path-option)))
+
         (option '(#\h "help") #f #f
                 (lambda args
                   (show-help)
@@ -165,6 +180,9 @@ specified with `--select'.\n"))
                          'always', 'never', and 'interactive', which is also
                          used when 'key-download' is not specified"))
   (newline)
+  (display (G_ "
+      --load-path=DIR    prepend DIR to the package module search path"))
+  (newline)
   (display (G_ "
   -h, --help             display this help and exit"))
   (display (G_ "
-- 
2.23.0

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [bug#38678] what about "guix repl"?
  2019-12-19 21:09 [bug#38678] [PATCH 0/2] Add '--load-path' to subcommands zimoun
                   ` (4 preceding siblings ...)
  2020-01-08 19:12 ` [bug#38678] [PATCH v3] refresh: " zimoun
@ 2020-01-08 20:59 ` zimoun
  2020-01-08 21:27   ` Pierre Neidhardt
  2020-01-09 13:21 ` [bug#38678] [PATCH 1/2] repl: Add '--load-path' option zimoun
  2020-01-15 17:00 ` [bug#38678] [PATCH v4 1/6] graph: Add '--load-path' option zimoun
  7 siblings, 1 reply; 24+ messages in thread
From: zimoun @ 2020-01-08 20:59 UTC (permalink / raw)
  To: 38678; +Cc: Pierre Neidhardt

Dear,

Do it make sense to add the option "--load-path" to the subcommand 'repl'?


All the best,
simon

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [bug#38678] what about "guix repl"?
  2020-01-08 20:59 ` [bug#38678] what about "guix repl"? zimoun
@ 2020-01-08 21:27   ` Pierre Neidhardt
  2020-01-09 13:19     ` zimoun
  0 siblings, 1 reply; 24+ messages in thread
From: Pierre Neidhardt @ 2020-01-08 21:27 UTC (permalink / raw)
  To: zimoun, 38678

[-- Attachment #1: Type: text/plain, Size: 416 bytes --]

I'd say yes, even though it has limited benefits.
In `guix repl`, you can see the load path with

--8<---------------cut here---------------start------------->8---
%load-path
--8<---------------cut here---------------end--------------->8---

The --load-path option would essentially be the same as appending the
path to the %load-path variable from the REPL.

-- 
Pierre Neidhardt
https://ambrevar.xyz/

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [bug#38678] what about "guix repl"?
  2020-01-08 21:27   ` Pierre Neidhardt
@ 2020-01-09 13:19     ` zimoun
  0 siblings, 0 replies; 24+ messages in thread
From: zimoun @ 2020-01-09 13:19 UTC (permalink / raw)
  To: Pierre Neidhardt; +Cc: 38678

Hi Pierre,

On Wed, 8 Jan 2020 at 22:27, Pierre Neidhardt <mail@ambrevar.xyz> wrote:
>
> I'd say yes, even though it has limited benefits.
> In `guix repl`, you can see the load path with
>
> --8<---------------cut here---------------start------------->8---
> %load-path
> --8<---------------cut here---------------end--------------->8---
>
> The --load-path option would essentially be the same as appending the
> path to the %load-path variable from the REPL.

Agree.

Note that 'guile' has the option too:
" -L DIRECTORY   add DIRECTORY to the front of the module load path"


Well, I send 2 patches about "guix repl":

 1. adding the 'load-path' option;
 2. adding the option '--listen' in the message outputted by '--help'.

Feel free to review and push if everything appear to you correct.


Cheers,
simon

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [bug#38678] [PATCH 1/2] repl: Add '--load-path' option.
  2019-12-19 21:09 [bug#38678] [PATCH 0/2] Add '--load-path' to subcommands zimoun
                   ` (5 preceding siblings ...)
  2020-01-08 20:59 ` [bug#38678] what about "guix repl"? zimoun
@ 2020-01-09 13:21 ` zimoun
  2020-01-09 13:21   ` [bug#38678] [PATCH 2/2] repl: Fix '--help' message zimoun
  2020-01-15 17:00 ` [bug#38678] [PATCH v4 1/6] graph: Add '--load-path' option zimoun
  7 siblings, 1 reply; 24+ messages in thread
From: zimoun @ 2020-01-09 13:21 UTC (permalink / raw)
  To: 38678; +Cc: zimoun

* guix/scripts/repl.scm (%option): Add '--load-path' option.
* doc/guix.texi: Document it.
---
 doc/guix.texi         | 8 ++++++++
 guix/scripts/repl.scm | 9 ++++++++-
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 00eb85a4f7..ef6d1fc178 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -7995,6 +7995,14 @@ Accept connections on localhost on port 37146.
 @item --listen=unix:/tmp/socket
 Accept connections on the Unix-domain socket @file{/tmp/socket}.
 @end table
+
+@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 tool.
 @end table
 
 @c *********************************************************************
diff --git a/guix/scripts/repl.scm b/guix/scripts/repl.scm
index e1cc759fc8..39a9b09656 100644
--- a/guix/scripts/repl.scm
+++ b/guix/scripts/repl.scm
@@ -1,5 +1,6 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2018, 2019 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2020 Simon Tournier <zimon.toutoune@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -19,6 +20,7 @@
 (define-module (guix scripts repl)
   #:use-module (guix ui)
   #:use-module (guix scripts)
+  #:use-module ((guix scripts build) #:select (%standard-build-options))
   #:use-module (guix repl)
   #:use-module (guix utils)
   #:use-module (guix packages)
@@ -52,7 +54,10 @@
                   (alist-cons 'type (string->symbol arg) result)))
         (option '("listen") #t #f
                 (lambda (opt name arg result)
-                  (alist-cons 'listen arg result)))))
+                  (alist-cons 'listen arg result)))
+        (find (lambda (option)
+                (member "load-path" (option-names option)))
+              %standard-build-options)))
 
 
 (define (show-help)
@@ -60,6 +65,8 @@
 Start a Guile REPL in the Guix execution environment.\n"))
   (display (G_ "
   -t, --type=TYPE        start a REPL of the given TYPE"))
+  (display (G_ "
+  -L, --load-path=DIR    prepend DIR to the package module search path"))
   (newline)
   (display (G_ "
   -h, --help             display this help and exit"))
-- 
2.23.0

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [bug#38678] [PATCH 2/2] repl: Fix '--help' message.
  2020-01-09 13:21 ` [bug#38678] [PATCH 1/2] repl: Add '--load-path' option zimoun
@ 2020-01-09 13:21   ` zimoun
  0 siblings, 0 replies; 24+ messages in thread
From: zimoun @ 2020-01-09 13:21 UTC (permalink / raw)
  To: 38678; +Cc: zimoun

* guix/scripts/repl.scm: (show-help): Add '--listen' option message.
---
 guix/scripts/repl.scm | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/guix/scripts/repl.scm b/guix/scripts/repl.scm
index 39a9b09656..fc3e4e2131 100644
--- a/guix/scripts/repl.scm
+++ b/guix/scripts/repl.scm
@@ -65,6 +65,9 @@
 Start a Guile REPL in the Guix execution environment.\n"))
   (display (G_ "
   -t, --type=TYPE        start a REPL of the given TYPE"))
+  (display (G_ "
+      --listen=ENDPOINT  listen ENDPOINT instead of standard I/O"))
+  (newline)
   (display (G_ "
   -L, --load-path=DIR    prepend DIR to the package module search path"))
   (newline)
-- 
2.23.0

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [bug#38678] [PATCH v4 1/6] graph: Add '--load-path' option.
  2019-12-19 21:09 [bug#38678] [PATCH 0/2] Add '--load-path' to subcommands zimoun
                   ` (6 preceding siblings ...)
  2020-01-09 13:21 ` [bug#38678] [PATCH 1/2] repl: Add '--load-path' option zimoun
@ 2020-01-15 17:00 ` zimoun
  2020-01-15 17:00   ` [bug#38678] [PATCH v4 2/6] size: " zimoun
                     ` (4 more replies)
  7 siblings, 5 replies; 24+ messages in thread
From: zimoun @ 2020-01-15 17:00 UTC (permalink / raw)
  To: 38678; +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 <ludo@gnu.org>
+;;; Copyright © 2019 Simon Tournier <zimon.toutoune@gmail.com>
 ;;;
 ;;; 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 <ludo@gnu.org>
+# Copyright © 2019 Simon Tournier <zimon.toutoune@gmail.com>
 #
 # 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"<<EOF
+(define-module (foo)
+  #:use-module (guix packages)
+  #:use-module (gnu packages base))
+
+(define-public dummy
+  (package (inherit hello)
+    (name "dummy")
+    (version "42")
+    (synopsis "dummy package")
+    (description "dummy package. Only used for testing purposes.")))
+EOF
+
+
 guix graph --version
 
 for package in guile-bootstrap coreutils python
@@ -59,3 +79,6 @@ guix graph git | grep 'label = "openssl'
 guix graph git --with-input=openssl=libressl | grep 'label = "libressl'
 if guix graph git --with-input=openssl=libressl | grep 'label = "openssl'
 then false; else true; fi
+
+# Try --load-path
+guix graph -L $module_dir dummy | grep 'label = "dummy'
-- 
2.23.0

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [bug#38678] [PATCH v4 2/6] size: Add '--load-path' option.
  2020-01-15 17:00 ` [bug#38678] [PATCH v4 1/6] graph: Add '--load-path' option zimoun
@ 2020-01-15 17:00   ` zimoun
  2020-01-15 17:00   ` [bug#38678] [PATCH v4 3/6] refresh: " zimoun
                     ` (3 subsequent siblings)
  4 siblings, 0 replies; 24+ messages in thread
From: zimoun @ 2020-01-15 17:00 UTC (permalink / raw)
  To: 38678; +Cc: zimoun

* guix/scripts/size.scm (%option): Add '--load-path' option.
* doc/guix.texi: Document it.
---
 doc/guix.texi         | 7 +++++++
 guix/scripts/size.scm | 8 ++++++++
 2 files changed, 15 insertions(+)

diff --git a/doc/guix.texi b/doc/guix.texi
index 37218eb847..3d26facd2e 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -9837,6 +9837,13 @@ the case, @command{guix size} fails as it tries to load it.
 @itemx -s @var{system}
 Consider packages for @var{system}---e.g., @code{x86_64-linux}.
 
+@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
 
 @node Invoking guix graph
diff --git a/guix/scripts/size.scm b/guix/scripts/size.scm
index f549ce05b8..2446b84587 100644
--- a/guix/scripts/size.scm
+++ b/guix/scripts/size.scm
@@ -1,5 +1,6 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2015, 2016, 2017, 2018, 2019 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2019 Simon Tournier <zimon.toutoune@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -19,6 +20,7 @@
 (define-module (guix scripts size)
   #:use-module (guix ui)
   #:use-module (guix scripts)
+  #:use-module (guix scripts build)
   #:use-module (guix store)
   #:use-module (guix monads)
   #:use-module (guix combinators)
@@ -242,6 +244,9 @@ Report the size of PACKAGE and its dependencies.\n"))
   -m, --map-file=FILE    write to FILE a graphical map of disk usage"))
   (newline)
   (display (G_ "
+  -L, --load-path=DIR    prepend DIR to the package module search path"))
+  (newline)
+  (display (G_ "
   -h, --help             display this help and exit"))
   (display (G_ "
   -V, --version          display version information and exit"))
@@ -273,6 +278,9 @@ Report the size of PACKAGE and its dependencies.\n"))
         (option '(#\m "map-file") #t #f
                 (lambda (opt name arg result)
                   (alist-cons 'map-file arg result)))
+        (find (lambda (option)
+                (member "load-path" (option-names option)))
+              %standard-build-options)
         (option '(#\h "help") #f #f
                 (lambda args
                   (show-help)
-- 
2.23.0

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [bug#38678] [PATCH v4 3/6] refresh: Add '--load-path' option.
  2020-01-15 17:00 ` [bug#38678] [PATCH v4 1/6] graph: Add '--load-path' option zimoun
  2020-01-15 17:00   ` [bug#38678] [PATCH v4 2/6] size: " zimoun
@ 2020-01-15 17:00   ` zimoun
  2020-01-15 17:00   ` [bug#38678] [PATCH v4 4/6] edit: " zimoun
                     ` (2 subsequent siblings)
  4 siblings, 0 replies; 24+ messages in thread
From: zimoun @ 2020-01-15 17:00 UTC (permalink / raw)
  To: 38678; +Cc: zimoun

* guix/scripts/refresh.scm (%option): Add '--load-path' option.
* doc/guix.texi: Document it.
---
 doc/guix.texi            |  9 ++++++++-
 guix/scripts/refresh.scm | 18 ++++++++++++++++++
 2 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 3d26facd2e..bee4c3b2c9 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -69,7 +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@*
+Copyright @copyright{} 2019, 2020 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
@@ -9552,6 +9552,13 @@ the user whether to download it or not.  This is the default behavior.
 @item --key-server=@var{host}
 Use @var{host} as the OpenPGP key server when importing a public key.
 
+@item --load-path=@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
 
 The @code{github} updater uses the
diff --git a/guix/scripts/refresh.scm b/guix/scripts/refresh.scm
index daf6fcf947..bc8e906054 100644
--- a/guix/scripts/refresh.scm
+++ b/guix/scripts/refresh.scm
@@ -7,6 +7,7 @@
 ;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
 ;;; Copyright © 2018 Efraim Flashner <efraim@flashner.co.il>
 ;;; Copyright © 2019 Ricardo Wurmus <rekado@elephly.net>
+;;; Copyright © 2020 Simon Tournier <zimon.toutoune@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -27,6 +28,7 @@
   #:use-module (guix ui)
   #:use-module (gcrypt hash)
   #:use-module (guix scripts)
+  #:use-module ((guix scripts build) #:select (%standard-build-options))
   #:use-module (guix store)
   #:use-module (guix utils)
   #:use-module (guix packages)
@@ -116,6 +118,19 @@
                      (leave (G_ "unsupported policy: ~a~%")
                             arg)))))
 
+        ;; The short option -L is already used by --list-updaters, therefore
+        ;; it needs to be removed from %standard-build-options.
+        (let ((%load-path-option (find (lambda (option)
+                                         (member "load-path"
+                                                 (option-names option)))
+                                       %standard-build-options)))
+          (option
+           (filter (lambda (name) (not (equal? #\L name)))
+                   (option-names %load-path-option))
+           (option-required-arg? %load-path-option)
+           (option-optional-arg? %load-path-option)
+           (option-processor     %load-path-option)))
+
         (option '(#\h "help") #f #f
                 (lambda args
                   (show-help)
@@ -165,6 +180,9 @@ specified with `--select'.\n"))
                          'always', 'never', and 'interactive', which is also
                          used when 'key-download' is not specified"))
   (newline)
+  (display (G_ "
+      --load-path=DIR    prepend DIR to the package module search path"))
+  (newline)
   (display (G_ "
   -h, --help             display this help and exit"))
   (display (G_ "
-- 
2.23.0

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [bug#38678] [PATCH v4 4/6] edit: Add '--load-path' option.
  2020-01-15 17:00 ` [bug#38678] [PATCH v4 1/6] graph: Add '--load-path' option zimoun
  2020-01-15 17:00   ` [bug#38678] [PATCH v4 2/6] size: " zimoun
  2020-01-15 17:00   ` [bug#38678] [PATCH v4 3/6] refresh: " zimoun
@ 2020-01-15 17:00   ` zimoun
  2020-01-15 17:00   ` [bug#38678] [PATCH v4 5/6] repl: " zimoun
  2020-01-15 17:00   ` [bug#38678] [PATCH v4 6/6] repl: Fix '--help' message zimoun
  4 siblings, 0 replies; 24+ messages in thread
From: zimoun @ 2020-01-15 17:00 UTC (permalink / raw)
  To: 38678; +Cc: zimoun

* guix/scripts/edit.scm (%option): Add '--load-path' option.
* doc/guix.texi: Document it.
---
 doc/guix.texi         |  4 ++++
 guix/scripts/edit.scm | 10 +++++++++-
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index bee4c3b2c9..00eb85a4f7 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -8705,6 +8705,10 @@ have created your own packages on @code{GUIX_PACKAGE_PATH}
 recipes.  In other cases, you will be able to examine the read-only recipes
 for packages currently in the store.
 
+Instead of @code{GUIX_PACKAGE_PATH}, the command-line option
+@code{--load-path=@var{directory}} (or in short @code{-L
+@var{directory}}) allows you to add @var{directory} to the front of the
+package module search path and so make your own packages visible.
 
 @node Invoking guix download
 @section Invoking @command{guix download}
diff --git a/guix/scripts/edit.scm b/guix/scripts/edit.scm
index da3d2775e8..a6fd1d2751 100644
--- a/guix/scripts/edit.scm
+++ b/guix/scripts/edit.scm
@@ -1,6 +1,7 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2015, 2016, 2019 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2015 Mathieu Lirzin <mthl@gnu.org>
+;;; Copyright © 2020 Simon Tournier <zimon.toutoune@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -20,6 +21,7 @@
 (define-module (guix scripts edit)
   #:use-module (guix ui)
   #:use-module (guix scripts)
+  #:use-module ((guix scripts build) #:select (%standard-build-options))
   #:use-module (guix utils)
   #:use-module (gnu packages)
   #:use-module (srfi srfi-1)
@@ -28,7 +30,10 @@
             guix-edit))
 
 (define %options
-  (list (option '(#\h "help") #f #f
+  (list (find (lambda (option)
+                (member "load-path" (option-names option)))
+              %standard-build-options)
+        (option '(#\h "help") #f #f
                 (lambda args
                   (show-help)
                   (exit 0)))
@@ -39,6 +44,9 @@
 (define (show-help)
   (display (G_ "Usage: guix edit PACKAGE...
 Start $VISUAL or $EDITOR to edit the definitions of PACKAGE...\n"))
+  (newline)
+  (display (G_ "
+  -L, --load-path=DIR    prepend DIR to the package module search path"))
   (newline)
   (display (G_ "
   -h, --help             display this help and exit"))
-- 
2.23.0

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [bug#38678] [PATCH v4 5/6] repl: Add '--load-path' option.
  2020-01-15 17:00 ` [bug#38678] [PATCH v4 1/6] graph: Add '--load-path' option zimoun
                     ` (2 preceding siblings ...)
  2020-01-15 17:00   ` [bug#38678] [PATCH v4 4/6] edit: " zimoun
@ 2020-01-15 17:00   ` zimoun
  2020-01-15 17:00   ` [bug#38678] [PATCH v4 6/6] repl: Fix '--help' message zimoun
  4 siblings, 0 replies; 24+ messages in thread
From: zimoun @ 2020-01-15 17:00 UTC (permalink / raw)
  To: 38678; +Cc: zimoun

* guix/scripts/repl.scm (%option): Add '--load-path' option.
* doc/guix.texi: Document it.
---
 doc/guix.texi         | 8 ++++++++
 guix/scripts/repl.scm | 9 ++++++++-
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 00eb85a4f7..ef6d1fc178 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -7995,6 +7995,14 @@ Accept connections on localhost on port 37146.
 @item --listen=unix:/tmp/socket
 Accept connections on the Unix-domain socket @file{/tmp/socket}.
 @end table
+
+@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 tool.
 @end table
 
 @c *********************************************************************
diff --git a/guix/scripts/repl.scm b/guix/scripts/repl.scm
index e1cc759fc8..39a9b09656 100644
--- a/guix/scripts/repl.scm
+++ b/guix/scripts/repl.scm
@@ -1,5 +1,6 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2018, 2019 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2020 Simon Tournier <zimon.toutoune@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -19,6 +20,7 @@
 (define-module (guix scripts repl)
   #:use-module (guix ui)
   #:use-module (guix scripts)
+  #:use-module ((guix scripts build) #:select (%standard-build-options))
   #:use-module (guix repl)
   #:use-module (guix utils)
   #:use-module (guix packages)
@@ -52,7 +54,10 @@
                   (alist-cons 'type (string->symbol arg) result)))
         (option '("listen") #t #f
                 (lambda (opt name arg result)
-                  (alist-cons 'listen arg result)))))
+                  (alist-cons 'listen arg result)))
+        (find (lambda (option)
+                (member "load-path" (option-names option)))
+              %standard-build-options)))
 
 
 (define (show-help)
@@ -60,6 +65,8 @@
 Start a Guile REPL in the Guix execution environment.\n"))
   (display (G_ "
   -t, --type=TYPE        start a REPL of the given TYPE"))
+  (display (G_ "
+  -L, --load-path=DIR    prepend DIR to the package module search path"))
   (newline)
   (display (G_ "
   -h, --help             display this help and exit"))
-- 
2.23.0

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [bug#38678] [PATCH v4 6/6] repl: Fix '--help' message.
  2020-01-15 17:00 ` [bug#38678] [PATCH v4 1/6] graph: Add '--load-path' option zimoun
                     ` (3 preceding siblings ...)
  2020-01-15 17:00   ` [bug#38678] [PATCH v4 5/6] repl: " zimoun
@ 2020-01-15 17:00   ` zimoun
  4 siblings, 0 replies; 24+ messages in thread
From: zimoun @ 2020-01-15 17:00 UTC (permalink / raw)
  To: 38678; +Cc: zimoun

* guix/scripts/repl.scm: (show-help): Add '--listen' option message.
---
 guix/scripts/repl.scm | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/guix/scripts/repl.scm b/guix/scripts/repl.scm
index 39a9b09656..fc3e4e2131 100644
--- a/guix/scripts/repl.scm
+++ b/guix/scripts/repl.scm
@@ -65,6 +65,9 @@
 Start a Guile REPL in the Guix execution environment.\n"))
   (display (G_ "
   -t, --type=TYPE        start a REPL of the given TYPE"))
+  (display (G_ "
+      --listen=ENDPOINT  listen ENDPOINT instead of standard I/O"))
+  (newline)
   (display (G_ "
   -L, --load-path=DIR    prepend DIR to the package module search path"))
   (newline)
-- 
2.23.0

^ permalink raw reply related	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2020-01-15 17:01 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-12-19 21:09 [bug#38678] [PATCH 0/2] Add '--load-path' to subcommands zimoun
2019-12-19 21:13 ` [bug#38678] [PATCH 1/2] graph: Add '--load-path' option zimoun
2019-12-19 21:14 ` [bug#38678] [PATCH 2/2] size: " zimoun
2019-12-19 21:35   ` Pierre Neidhardt
2019-12-19 21:43     ` zimoun
2019-12-19 21:48       ` Pierre Neidhardt
2020-01-08 18:53 ` [bug#38678] [PATCH v2 0/4] Add '--load-path' to subcommands zimoun
2020-01-08 19:12   ` [bug#38678] [PATCH v3] better filter in 'refresh' zimoun
2020-01-08 18:56 ` [bug#38678] [PATCH v2 1/4] graph: Add '--load-path' option zimoun
2020-01-08 18:56   ` [bug#38678] [PATCH v2 2/4] size: " zimoun
2020-01-08 18:56   ` [bug#38678] [PATCH v2 3/4] refresh: " zimoun
2020-01-08 18:56   ` [bug#38678] [PATCH v2 4/4] edit: " zimoun
2020-01-08 19:12 ` [bug#38678] [PATCH v3] refresh: " zimoun
2020-01-08 20:59 ` [bug#38678] what about "guix repl"? zimoun
2020-01-08 21:27   ` Pierre Neidhardt
2020-01-09 13:19     ` zimoun
2020-01-09 13:21 ` [bug#38678] [PATCH 1/2] repl: Add '--load-path' option zimoun
2020-01-09 13:21   ` [bug#38678] [PATCH 2/2] repl: Fix '--help' message zimoun
2020-01-15 17:00 ` [bug#38678] [PATCH v4 1/6] graph: Add '--load-path' option zimoun
2020-01-15 17:00   ` [bug#38678] [PATCH v4 2/6] size: " zimoun
2020-01-15 17:00   ` [bug#38678] [PATCH v4 3/6] refresh: " zimoun
2020-01-15 17:00   ` [bug#38678] [PATCH v4 4/6] edit: " zimoun
2020-01-15 17:00   ` [bug#38678] [PATCH v4 5/6] repl: " zimoun
2020-01-15 17:00   ` [bug#38678] [PATCH v4 6/6] repl: Fix '--help' message zimoun

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).