Re: GUIX_EXTENSIONS_PATH error?

2021-01-15 Thread zimoun
Hi Ricardo,

About the precedence, i.e., extension that overrides default command,
see patch#45910.




On Fri, 15 Jan 2021 at 23:42, Ricardo Wurmus  wrote:
> zimoun  writes:

> We can change this, but we’d need to agree on an as yet unused directory
> as the root for extensions.

I do not know, maybe I will change my mind after a good ol’ black
coffee. :-)

We could say that:

 1. the prototype of GUIX_EXTENSIONS_PATH is path/to/guix
 2. the folder /extensions is implicitly appended 
 3. ~/.config/guix is implicitly appended

The patch attached does that.  But, the definition of the package ’guix’
needs to be tweaked (not done) in agreement, especially:

--8<---cut here---start->8---
  (native-search-paths
   (list (search-path-specification
  (variable "GUIX_EXTENSIONS_PATH")
  (files '("share/guix/extensions")
--8<---cut here---end--->8---


>> Moreover, it could nice to have GUIX_EXTENSIONS_PATH look by default
>> in ~/.config/guix/extensions, i.e., by default
>> GUIX_EXTENSIONS_PATH=~/.config.
>
> The last part of this sentence is what I meant above: we need to avoid
> that, because that would cause
> ~/.config/guix/current/share/guile/site/3.0/guix/scripts/ to be included
> in the search for extensions.

It is easy to filter out by adding rules in ’extensions-directories’. :-)

> I have added a search path specification to the “guix” package itself,
> so that it will set GUIX_EXTENSIONS_PATH to
> $profile/share/guix/extensions automatically.  The idea is to update the
> format of the “channels.scm” file to allow for the installation of extra
> packages into the “guix pull” profile (by default that’s
> ~/.config/guix/current).

I see.  Well, I need to fail myself to really understand…

> This way I could say that I want the freshly pulled Guix to also install
> the “gwl” package in the same profile, and that new Guix would
> automatically have the “gwl” extension’s “workflow” sub-command.

I agree.


Cheers,
simon
--

diff --git a/guix/ui.scm b/guix/ui.scm
index ad78d5cedd..e918b5b64f 100644
--- a/guix/ui.scm
+++ b/guix/ui.scm
@@ -2066,8 +2066,10 @@ contain a 'define-command' form."
 (define (extension-directories)
   "Return the list of directories containing Guix extensions."
   (filter file-exists?
-  (parse-path
-   (getenv "GUIX_EXTENSIONS_PATH"
+  (map (cut string-append <> "/extensions")
+   (parse-path
+(string-append (config-directory) ":"
+ (getenv "GUIX_EXTENSIONS_PATH"))
 
 (define (commands)
   "Return the list of commands, alphabetically sorted."


Re: GUIX_EXTENSIONS_PATH error?

2021-01-15 Thread Ricardo Wurmus


zimoun  writes:

>> I have added a search path specification to the “guix” package itself,
>> so that it will set GUIX_EXTENSIONS_PATH to
>> $profile/share/guix/extensions automatically.  The idea is to update the
>> format of the “channels.scm” file to allow for the installation of extra
>> packages into the “guix pull” profile (by default that’s
>> ~/.config/guix/current).
>
> ...because yeah that's the aim. :-)  Provide extensions as channels.

It’s very similar to providing extensions as channels, but without
actually using the channel mechanism.   Channels are a little different
from regular packages.  They consist solely of Guile source files, they
are not compiled ahead of time but built during “guix pull”, and they
cannot have inputs other than channels.

Extensions like the GWL have non-trivial dependencies, which cannot be
included when the GWL is treated as a channel.

Maybe there’s a way to express channels themselves as regular packages,
but I’m not seeing it.  So until we can unify this, extensions should be
installed as packages once “guix pull” has finished building the new
Guix (with all its channels).

Does this make sense?

-- 
Ricardo



Re: GUIX_EXTENSIONS_PATH error?

2021-01-15 Thread zimoun
Re,

On Fri, 15 Jan 2021 at 23:42, Ricardo Wurmus  wrote:
> zimoun  writes:
>
> >> So if the file is at /tmp/foo/guix/extensions/bar.scm then
> >> $GUIX_EXTENSIONS_PATH should be /tmp/foo/guix/extensions.
> >
> > Well, I will propose to have the thing as you said before.  Because
> > fixing (guix extensions bar) and the path $GUIX_EXTENSIONS_PATH/foo
> > seems reasonable but $GUIX_EXTENSIONS_PATH/foo/guix/extensions is too
> > redundant.
>
> It does seem so, but the idea was to reduce the number of files that
> Guix will have to parse before finding an extension.
>
> Extensions would be installed to the same prefix /share/guix/extensions,
> so Guix can set GUIX_EXTENSIONS_PATH to $profile/share/guix/extensions
> and not worry about having to parse all the Scheme files in
> $profile/share, which may be a lot — for example Guix’s own commands are
> defined in files under $profile/share, so they would end up as
> extensions…

Ah I see.

> We can change this, but we’d need to agree on an as yet unused directory
> as the root for extensions.

Well, I have to rehash a bit and then see what could be "user
friendly" without typing redundancy.

> > Moreover, it could nice to have GUIX_EXTENSIONS_PATH look by default
> > in ~/.config/guix/extensions, i.e., by default
> > GUIX_EXTENSIONS_PATH=~/.config.
>
> The last part of this sentence is what I meant above: we need to avoid
> that, because that would cause
> ~/.config/guix/current/share/guile/site/3.0/guix/scripts/ to be included
> in the search for extensions.

Ah I see.  But we could filter out this "current" from the path.  In
the case of default to "~/.config/guix/extensions/".

Well, need some thoughts...

> I have added a search path specification to the “guix” package itself,
> so that it will set GUIX_EXTENSIONS_PATH to
> $profile/share/guix/extensions automatically.  The idea is to update the
> format of the “channels.scm” file to allow for the installation of extra
> packages into the “guix pull” profile (by default that’s
> ~/.config/guix/current).

...because yeah that's the aim. :-)  Provide extensions as channels.


Cheers,
simon



Re: GUIX_EXTENSIONS_PATH error?

2021-01-15 Thread Ricardo Wurmus


zimoun  writes:

>> So if the file is at /tmp/foo/guix/extensions/bar.scm then
>> $GUIX_EXTENSIONS_PATH should be /tmp/foo/guix/extensions.
>
> Well, I will propose to have the thing as you said before.  Because
> fixing (guix extensions bar) and the path $GUIX_EXTENSIONS_PATH/foo
> seems reasonable but $GUIX_EXTENSIONS_PATH/foo/guix/extensions is too
> redundant.

It does seem so, but the idea was to reduce the number of files that
Guix will have to parse before finding an extension.

Extensions would be installed to the same prefix /share/guix/extensions,
so Guix can set GUIX_EXTENSIONS_PATH to $profile/share/guix/extensions
and not worry about having to parse all the Scheme files in
$profile/share, which may be a lot — for example Guix’s own commands are
defined in files under $profile/share, so they would end up as
extensions…

We can change this, but we’d need to agree on an as yet unused directory
as the root for extensions.

> Moreover, it could nice to have GUIX_EXTENSIONS_PATH look by default
> in ~/.config/guix/extensions, i.e., by default
> GUIX_EXTENSIONS_PATH=~/.config.

The last part of this sentence is what I meant above: we need to avoid
that, because that would cause
~/.config/guix/current/share/guile/site/3.0/guix/scripts/ to be included
in the search for extensions.

I have added a search path specification to the “guix” package itself,
so that it will set GUIX_EXTENSIONS_PATH to
$profile/share/guix/extensions automatically.  The idea is to update the
format of the “channels.scm” file to allow for the installation of extra
packages into the “guix pull” profile (by default that’s
~/.config/guix/current).

This way I could say that I want the freshly pulled Guix to also install
the “gwl” package in the same profile, and that new Guix would
automatically have the “gwl” extension’s “workflow” sub-command.

-- 
Ricardo



Re: GUIX_EXTENSIONS_PATH error?

2021-01-15 Thread zimoun
Hi,

On Fri, 15 Jan 2021 at 23:25, Ricardo Wurmus  wrote:

> Oh, my bad:  $GUIX_EXTENSIONS_PATH must actually include the
> “/guix/extensions” sub-directory.

Thanks.  It works! \o/
Awesome :-)


> So if the file is at /tmp/foo/guix/extensions/bar.scm then
> $GUIX_EXTENSIONS_PATH should be /tmp/foo/guix/extensions.

Well, I will propose to have the thing as you said before.  Because
fixing (guix extensions bar) and the path $GUIX_EXTENSIONS_PATH/foo
seems reasonable but $GUIX_EXTENSIONS_PATH/foo/guix/extensions is too
redundant.
Moreover, it could nice to have GUIX_EXTENSIONS_PATH look by default
in ~/.config/guix/extensions, i.e., by default
GUIX_EXTENSIONS_PATH=~/.config.


Cheers,
simon



Re: GUIX_EXTENSIONS_PATH error?

2021-01-15 Thread Ricardo Wurmus


zimoun  writes:

>>> --8<---cut here---start->8---
>>> $ cat /tmp/foo/bar.scm
>>> (define-module (guix extensions bar)
>>>   #:use-module (guix scripts))
>>
>> This right here is the problem.  The module name and the file name do
>> not match.  The file must be
>> $GUIX_EXTENSIONS_PATH/guix/extensions/bar.scm and provide the module
>> (guix extensions bar).
>
> Ah yeah, that makes sense.  Now, no error but nothing showed:
>
> --8<---cut here---start->8---
> $ cat $GUIX_EXTENSIONS_PATH/guix/extensions/bar.scm
> (define-module (guix extensions bar)
>   #:use-module (guix scripts)
>   #:export (guix-bar)
>   )
>
>
> (define-command (guix-bar . args)
>   (category extension)
>   (synopsis "a bar with beer")
>
>   (pk "dumb"))
>
> $ guix --help | grep bar
> --8<---cut here---end--->8---

Oh, my bad:  $GUIX_EXTENSIONS_PATH must actually include the
“/guix/extensions” sub-directory.

So if the file is at /tmp/foo/guix/extensions/bar.scm then
$GUIX_EXTENSIONS_PATH should be /tmp/foo/guix/extensions.

Sorry for the confusion!

-- 
Ricardo



Re: GUIX_EXTENSIONS_PATH error?

2021-01-15 Thread zimoun
Hi,

On Fri, 15 Jan 2021 at 21:45, Ricardo Wurmus  wrote:
> zimoun  writes:
>
>> In the mood for documenting the recent GUIX_EXTENSIONS_PATH, I am
>> missing something because I hit an error.
>
> It’s not your fault.  It’s hard to do this without documentation.

It’s so cool that I would like to document it. ;-)  Sorry to not dive in
the code first.

>> --8<---cut here---start->8---
>> $ cat /tmp/foo/bar.scm
>> (define-module (guix extensions bar)
>>   #:use-module (guix scripts))
>
> This right here is the problem.  The module name and the file name do
> not match.  The file must be
> $GUIX_EXTENSIONS_PATH/guix/extensions/bar.scm and provide the module
> (guix extensions bar).

Ah yeah, that makes sense.  Now, no error but nothing showed:

--8<---cut here---start->8---
$ cat $GUIX_EXTENSIONS_PATH/guix/extensions/bar.scm
(define-module (guix extensions bar)
  #:use-module (guix scripts)
  #:export (guix-bar)
  )


(define-command (guix-bar . args)
  (category extension)
  (synopsis "a bar with beer")

  (pk "dumb"))

$ guix --help | grep bar
--8<---cut here---end--->8---


Cheers,
simon



Re: GUIX_EXTENSIONS_PATH error?

2021-01-15 Thread Ricardo Wurmus


zimoun  writes:

> In the mood for documenting the recent GUIX_EXTENSIONS_PATH, I am
> missing something because I hit an error.

It’s not your fault.  It’s hard to do this without documentation.

> --8<---cut here---start->8---
> $ cat /tmp/foo/bar.scm
> (define-module (guix extensions bar)
>   #:use-module (guix scripts))

This right here is the problem.  The module name and the file name do
not match.  The file must be
$GUIX_EXTENSIONS_PATH/guix/extensions/bar.scm and provide the module
(guix extensions bar).

> $ export GUIX_EXTENSIONS_PATH=/tmp/foo
>
> $ guix --help
> Usage: guix COMMAND ARGS...
> Run COMMAND with ARGS.
>
> COMMAND must be one of the sub-commands listed below:
> Backtrace:
>4 (primitive-load "/home/simon/.config/guix/current/bin/guix")
> In ice-9/boot-9.scm:
>   1731:15  3 (with-exception-handler # ice-9/boot-9.scm:1815:7 (exn)> _ # _ …)
> In guix/ui.scm:
>   2105:20  2 (show-guix-help)
> In srfi/srfi-1.scm:
>691:23  1 (filter-map # _ . _)
> In guix/ui.scm:
>2023:2  0 (source-file-command _)
>
> guix/ui.scm:2023:2: In procedure source-file-command:
> Throw to key `match-error' with args `("match" "no matching pattern" ("tmp" 
> "foo" "bar.scm"))'.

But it still shouldn’t throw an error like that.  I’ll fix it.  Sorry!

-- 
Ricardo



GUIX_EXTENSIONS_PATH error?

2021-01-15 Thread zimoun
Hi,

In the mood for documenting the recent GUIX_EXTENSIONS_PATH, I am
missing something because I hit an error.  Before diving, maybe my
daily coffee dose is not enough…


--8<---cut here---start->8---
$ cat /tmp/foo/bar.scm
(define-module (guix extensions bar)
  #:use-module (guix scripts))


(define-command (guix-bar . args)
  (category extension)
  (synopsis "a bar with beers")

  (pk "dumb"))


$ export GUIX_EXTENSIONS_PATH=/tmp/foo

$ guix --help
Usage: guix COMMAND ARGS...
Run COMMAND with ARGS.

COMMAND must be one of the sub-commands listed below:
Backtrace:
   4 (primitive-load "/home/simon/.config/guix/current/bin/guix")
In ice-9/boot-9.scm:
  1731:15  3 (with-exception-handler # _ # _ …)
In guix/ui.scm:
  2105:20  2 (show-guix-help)
In srfi/srfi-1.scm:
   691:23  1 (filter-map # _ . _)
In guix/ui.scm:
   2023:2  0 (source-file-command _)

guix/ui.scm:2023:2: In procedure source-file-command:
Throw to key `match-error' with args `("match" "no matching pattern" ("tmp" 
"foo" "bar.scm"))'.
--8<---cut here---end--->8---

What do I miss?


All the best,
simon