[PATCH 0/2] Add simple Guix extensions as example

  • Open
  • quality assurance status badge
Details
3 participants
  • Liliana Marie Prikler
  • Christopher Baines
  • zimoun
Owner
unassigned
Submitted by
zimoun
Severity
normal

Debbugs page

Z
Z
zimoun wrote on 6 Oct 2022 09:36
(address . guix-patches@gnu.org)(name . zimoun)(address . zimon.toutoune@gmail.com)
20221006163609.2280960-1-zimon.toutoune@gmail.com
Hi,

Based on patch#57982 [1], here are two simple examples for extending Guix
subcommands. Here are starter versions which will be improved.

The first is based on a binary; I replaced 'git-send-email' by 'hello'.

The second is based on a simple pure Guile module. Somehow, it is the first
step to document Guix extensions as proposed at 10 years event [2].

For instance, it is not handy to manually tweak the %standard-phases of
guile-build-system when maybe we could have guix-build-system (or whatever
more relevant name, bikeshed open ;-)). Neither to tweak the native-inputs.



Cheers,
simon


Efraim Flashner (1):
gnu: Add guix-hello.

zimoun (1):
gnu: Add guix-example.

gnu/local.mk | 1 +
gnu/packages/guix-extensions.scm | 97 ++++++++++++++++++++++++++++++++
2 files changed, 98 insertions(+)
create mode 100644 gnu/packages/guix-extensions.scm


base-commit: 5b42b64ea89564c58325d16d3d0f4a0a03ebae0f
--
2.36.0
Z
Z
zimoun wrote on 6 Oct 2022 09:39
[PATCH 2/2] gnu: Add guix-example.
(address . 58339@debbugs.gnu.org)(name . zimoun)(address . zimon.toutoune@gmail.com)
20221006163935.2282212-2-zimon.toutoune@gmail.com
* gnu/packages/guix-extensions.scm (guix-example): New variable.
---
gnu/packages/guix-extensions.scm | 39 +++++++++++++++++++++++++++++++-
1 file changed, 38 insertions(+), 1 deletion(-)

Toggle diff (52 lines)
diff --git a/gnu/packages/guix-extensions.scm b/gnu/packages/guix-extensions.scm
index 6294c15f3d..6541630ddd 100644
--- a/gnu/packages/guix-extensions.scm
+++ b/gnu/packages/guix-extensions.scm
@@ -19,7 +19,44 @@ (define-module (gnu packages guix-extensions)
#:use-module (guix gexp)
#:use-module (guix packages)
#:use-module (guix build-system trivial)
- #:use-module (gnu packages base))
+ #:use-module (guix build-system guile)
+ #:use-module (guix git-download)
+ #:use-module (gnu packages base)
+ #:use-module (gnu packages package-management))
+
+(define-public guix-example
+ (let ((commit "d600bd742dae9df86e980a25cf1d0ac71ee01438")
+ (revision "0"))
+ (package
+ (name "guix-example")
+ (version (git-version "0" revision commit))
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://gitlab.com/zimoun/guix-example")
+ (commit commit)))
+ (file-name (string-append name version "-checkout"))
+ (sha256
+ (base32
+ "0s48b5a1i0vkx5lq7jn9b46zzqv2g3dli7b54sd9365dszqjqzmx"))))
+ (build-system guile-build-system)
+ (arguments
+ '(#:phases (modify-phases %standard-phases
+ (add-after 'install 'move-to-extension-directory
+ (lambda* (#:key outputs #:allow-other-keys)
+ (let* ((out (assoc-ref outputs "out"))
+ (target (string-append
+ out
+ "/share/guix/extensions/example.scm")))
+ (mkdir-p (dirname target))
+ (rename-file (car (find-files out "example.scm"))
+ target)))))))
+ (native-inputs (list (lookup-package-input guix "guile") guix))
+ (home-page "") ; Should be documentation location for GUIX_EXTENSIONS_PATH
+ (synopsis "Example of Guix sub-command extension")
+ (description "This Guix extension provides a simple example to extend Guix subcommands.")
+ (license license:gpl3+))))
(define-public guix-hello
(package
--
2.36.0
Z
Z
zimoun wrote on 6 Oct 2022 09:39
[PATCH 1/2] gnu: Add guix-hello.
(address . 58339@debbugs.gnu.org)
20221006163935.2282212-1-zimon.toutoune@gmail.com
From: Efraim Flashner <efraim@flashner.co.il>

* gnu/packages/guix-extensions.scm (guix-hello): New variable.
* gnu/local.mk (GNU_SYSTEM_MODULES): Add guix-extensions.

Co-authored-by: zimoun <zimon.toutoune@gmail.com>
---
gnu/local.mk | 1 +
gnu/packages/guix-extensions.scm | 60 ++++++++++++++++++++++++++++++++
2 files changed, 61 insertions(+)
create mode 100644 gnu/packages/guix-extensions.scm

Toggle diff (80 lines)
diff --git a/gnu/local.mk b/gnu/local.mk
index 5976cbe90c..7bf1c34995 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -299,6 +299,7 @@ GNU_SYSTEM_MODULES = \
%D%/packages/guile.scm \
%D%/packages/guile-wm.scm \
%D%/packages/guile-xyz.scm \
+ %D%/packages/guix-extensions.scm \
%D%/packages/gv.scm \
%D%/packages/gxmessage.scm \
%D%/packages/hardware.scm \
diff --git a/gnu/packages/guix-extensions.scm b/gnu/packages/guix-extensions.scm
new file mode 100644
index 0000000000..6294c15f3d
--- /dev/null
+++ b/gnu/packages/guix-extensions.scm
@@ -0,0 +1,60 @@
+;;; Copyright © 2022 Efraim Flashner <efraim@flashner.co.il>
+;;; Copyright © 2022 Simon Tournier <zimon.toutoune@gmail.com>
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (gnu packages guix-extensions)
+ #:use-module ((guix licenses) #:prefix license:)
+ #:use-module (guix gexp)
+ #:use-module (guix packages)
+ #:use-module (guix build-system trivial)
+ #:use-module (gnu packages base))
+
+(define-public guix-hello
+ (package
+ (name "guix-hello")
+ (version "0")
+ (source #f)
+ (build-system trivial-build-system)
+ (arguments
+ (list
+ #:modules '((guix build utils))
+ #:builder
+ #~(begin
+ (use-modules (guix build utils))
+ (let ((dest (string-append #$output
+ "/share/guix/extensions/hello.scm"))
+ (hello #$(this-package-input "hello")))
+ (mkdir-p (dirname dest))
+ (with-output-to-file dest
+ (lambda ()
+ (format #t
+ "(define-module (guix extensions hello)~@
+ #:use-module (guix scripts)~@
+ #:export (guix-hello))~@
+~@
+(define-command (guix-hello . args)~@
+ (category extension)~@
+ (synopsis \"world\")~@
+ (apply system* \"~a/bin/hello\" args))~%"
+ hello)))))))
+ (home-page "") ; Should be documentation location for GUIX_EXTENSIONS_PATH
+ (inputs
+ (list hello))
+ (synopsis "Example of Guix sub-command extension")
+ (description "This Guix extension provides a shell redirection from
+@code{guix hello} to @code{hello}.")
+ ;; The package definition is longer than the code;
+ ;; let this serve as the declaration of the license.
+ (license license:gpl3+)))
--
2.36.0
L
L
Liliana Marie Prikler wrote on 6 Oct 2022 12:58
Re: [PATCH 2/2] gnu: Add guix-example.
e94febb946fbcf7eb662e3e349889c978e80b604.camel@gmail.com
Am Donnerstag, dem 06.10.2022 um 18:39 +0200 schrieb zimoun:
Toggle quote (56 lines)
> * gnu/packages/guix-extensions.scm (guix-example): New variable.
> ---
>  gnu/packages/guix-extensions.scm | 39
> +++++++++++++++++++++++++++++++-
>  1 file changed, 38 insertions(+), 1 deletion(-)
>
> diff --git a/gnu/packages/guix-extensions.scm b/gnu/packages/guix-
> extensions.scm
> index 6294c15f3d..6541630ddd 100644
> --- a/gnu/packages/guix-extensions.scm
> +++ b/gnu/packages/guix-extensions.scm
> @@ -19,7 +19,44 @@ (define-module (gnu packages guix-extensions)
>    #:use-module (guix gexp)
>    #:use-module (guix packages)
>    #:use-module (guix build-system trivial)
> -  #:use-module (gnu packages base))
> +  #:use-module (guix build-system guile)
> +  #:use-module (guix git-download)
> +  #:use-module (gnu packages base)
> +  #:use-module (gnu packages package-management))
> +
> +(define-public guix-example
> +  (let ((commit "d600bd742dae9df86e980a25cf1d0ac71ee01438")
> +        (revision "0"))
> +    (package
> +      (name "guix-example")
> +      (version (git-version "0" revision commit))
> +      (source
> +       (origin
> +         (method git-fetch)
> +         (uri (git-reference
> +               (url "https://gitlab.com/zimoun/guix-example")
> +               (commit commit)))
> +         (file-name (string-append name version "-checkout"))
> +         (sha256
> +          (base32
> +          
> "0s48b5a1i0vkx5lq7jn9b46zzqv2g3dli7b54sd9365dszqjqzmx"))))
> +      (build-system guile-build-system)
> +      (arguments
> +       '(#:phases (modify-phases %standard-phases
> +                    (add-after 'install 'move-to-extension-directory
> +                      (lambda* (#:key outputs #:allow-other-keys)
> +                        (let* ((out (assoc-ref outputs "out"))
> +                               (target (string-append
> +                                        out
> +                                       
> "/share/guix/extensions/example.scm")))
> +                          (mkdir-p (dirname target))
> +                          (rename-file (car (find-files out
> "example.scm"))
> +                                       target)))))))
> +      (native-inputs (list (lookup-package-input guix "guile")
> guix))
> +      (home-page "") ; Should be documentation location for
> GUIX_EXTENSIONS_PATH
Note that this example has a home-page.
Toggle quote (4 lines)
> +      (synopsis "Example of Guix sub-command extension")
> +      (description "This Guix extension provides a simple example to
> extend Guix subcommands.")
> +      (license license:gpl3+))))
While Ludo said "Maybe we should just keep it as an example in the
source tree?", I'm really not sure whether that's the best course of
action. It will simultaneously act as a package that users won't know
how to use (as evidenced by some people now and then asking how to run
gwl) *and* as not that great of an example on how to write extension,
because people only have the history of the Guix repo to go by.

For a proper guide, I think we should walk through:

1. Writing a sample extension (e.g. one simply printing hello world)
2. Testing the extension via `guix shell'
3. (Pointers on) submitting the extension to Guix proper or managing it
in one's own channel

For now, we barely cover 1.

Cheers
Z
Z
zimoun wrote on 7 Oct 2022 01:21
Re: [bug#58339] ’guix shell’ not working with GUIX_EXTENSIONS_PATH
871qrkujrh.fsf@gmail.com
Hi Liliana,

Thanks for your feedback.

On jeu., 06 oct. 2022 at 21:58, Liliana Marie Prikler <liliana.prikler@gmail.com> wrote:

About this:

Toggle quote (2 lines)
> 2. Testing the extension via `guix shell'

We need to open another issue because it is not related to the current
patch (proposal for a simple example of an extensions); this point #2 is
an issue about all the extensions.

For instance, let consider guix-modules [1]. It reads,

Toggle snippet (4 lines)
$ guix install guix-modules
$ export GUIX_EXTENSIONS_PATH="$HOME/.guix-profile/share/guix/extensions"

and if instead, one uses a shell, it fails:

Toggle snippet (10 lines)
$ guix shell guix-modules -- guix module -h
guix: module: command not found
Try `guix --help' for more information.

$ guix shell guix-modules
[env]$ guix module -h
guix: module: command not found
Try `guix --help' for more information.

Note that the variable GUIX_EXTENSIONS_PATH is listed in etc/profile,

Toggle snippet (14 lines)
[env]$ cat $GUIX_ENVIRONMENT/etc/profile
# Source this file to define all the relevant environment variables in Bash
# for this profile. You may want to define the 'GUIX_PROFILE' environment
# variable to point to the "visible" name of the profile, like this:
#
# GUIX_PROFILE=/path/to/profile ; \
# source /path/to/profile/etc/profile
#
# When GUIX_PROFILE is undefined, the various environment variables refer
# to this specific profile generation.

export GUIX_EXTENSIONS_PATH="${GUIX_PROFILE:-/gnu/store/qhfy9wwzg98a0j3i88qaxdmy19rvp0s8-profile}/share/guix/extensions${GUIX_EXTENSIONS_PATH:+:}$GUIX_EXTENSIONS_PATH"

Well, another issue with extensions. :-)

1:


Cheers,
simon
L
L
Liliana Marie Prikler wrote on 7 Oct 2022 11:21
Re: [bug#58339] ’guix shell’ not working with GUIX_EXTENSIONS_PATH
b41131281ab6cff3cb2121c81916c586f4523e3c.camel@gmail.com
Am Freitag, dem 07.10.2022 um 10:21 +0200 schrieb zimoun:
Toggle quote (14 lines)
> Hi Liliana,
>
> Thanks for your feedback.
>
> On jeu., 06 oct. 2022 at 21:58, Liliana Marie Prikler
> <liliana.prikler@gmail.com> wrote:
>
> About this:
>
> > 2. Testing the extension via `guix shell'
>
> We need to open another issue because it is not related to the
> current patch (proposal for a simple example of an extensions); this
> point #2 is an issue about all the extensions.
But that's the point. Simply adding an extension – whether an example
or an actually useful one – doesn't teach users how to use them. It's
missing this very information among other things.

Toggle quote (45 lines)
> For instance, let consider guix-modules [1].  It reads,
>
> --8<---------------cut here---------------start------------->8---
> $ guix install guix-modules
> $ export GUIX_EXTENSIONS_PATH="$HOME/.guix-
> profile/share/guix/extensions"
> --8<---------------cut here---------------end--------------->8---
>
> and if instead, one uses a shell, it fails:
>
> --8<---------------cut here---------------start------------->8---
> $ guix shell guix-modules -- guix module -h
> guix: module: command not found
> Try `guix --help' for more information.
>
> $ guix shell guix-modules
> [env]$ guix module -h
> guix: module: command not found
> Try `guix --help' for more information.
> --8<---------------cut here---------------end--------------->8---
>
> Note that the variable GUIX_EXTENSIONS_PATH is listed in etc/profile,
>
> --8<---------------cut here---------------start------------->8---
> [env]$ cat $GUIX_ENVIRONMENT/etc/profile
> # Source this file to define all the relevant environment variables
> in Bash
> # for this profile.  You may want to define the 'GUIX_PROFILE'
> environment
> # variable to point to the "visible" name of the profile, like this:
> #
> #  GUIX_PROFILE=/path/to/profile ; \
> #  source /path/to/profile/etc/profile
> #
> # When GUIX_PROFILE is undefined, the various environment variables
> refer
> # to this specific profile generation.
>
> export GUIX_EXTENSIONS_PATH="${GUIX_PROFILE:-
> /gnu/store/qhfy9wwzg98a0j3i88qaxdmy19rvp0s8-
> profile}/share/guix/extensions${GUIX_EXTENSIONS_PATH:+:}$GUIX_EXTENSI
> ONS_PATH"
> --8<---------------cut here---------------end--------------->8---
>
> Well, another issue with extensions. :-)
In case you really didn't know how to use extensions with guix shell,
it's guix shell guix your-extension -- guix blah, assuming your
extension works with a slightly older guix.

Cheers
Z
Z
zimoun wrote on 7 Oct 2022 11:49
Re: [bug#58339] ’guix shell’ not working with GU IX_EXTENSIONS_PATH
(name . Liliana Marie Prikler)(address . liliana.prikler@gmail.com)(address . 58339@debbugs.gnu.org)
CAJ3okZ1-kLa8Q_gEVmYzDiwVc13KTLA+oJxU1cbB9fUbRkm5SA@mail.gmail.com
Hi Liliana,

Well, I am in favor to go one foot then the other. :-) Let start to
have a simple extension that we can improve by incremental changes,
then let add a section in the manual for having the reference
documentation, then let add a cookbook entry, etc. Well, somehow the
perfect is the enemy of the good. :-)

It appears to me more motivational to document Guix extensions step by
step, i.e., people can contribute to the improvements, etc.. Instead
of going my way alone and then come back with a complete work. For
what my opinion is worth.


On Fri, 7 Oct 2022 at 20:21, Liliana Marie Prikler
<liliana.prikler@gmail.com> wrote:

Toggle quote (4 lines)
> But that's the point. Simply adding an extension – whether an example
> or an actually useful one – doesn't teach users how to use them. It's
> missing this very information among other things.

The answer of this is provided by the following part of my previous message. :-)


Toggle quote (8 lines)
> > For instance, let consider guix-modules [1]. It reads,
> >
> > --8<---------------cut here---------------start------------->8---
> > $ guix install guix-modules
> > $ export GUIX_EXTENSIONS_PATH="$HOME/.guix-
> > profile/share/guix/extensions"
> > --8<---------------cut here---------------end--------------->8---

The already included extension 'guix-modules' is usable using the
snippet above. And we teach people via a blog post on hpc.guix.info.


Toggle quote (15 lines)
> > --8<---------------cut here---------------start------------->8---
> > $ guix shell guix-modules -- guix module -h
> > guix: module: command not found
> > Try `guix --help' for more information.
> >
> > $ guix shell guix-modules
> > [env]$ guix module -h
> > guix: module: command not found
> > Try `guix --help' for more information.
> > --8<---------------cut here---------------end--------------->8---

> In case you really didn't know how to use extensions with guix shell,
> it's guix shell guix your-extension -- guix blah, assuming your
> extension works with a slightly older guix.

As shown by my snippet above, it does not work; at least on foreign distro.

Cheers,
simon
L
L
Liliana Marie Prikler wrote on 7 Oct 2022 12:28
Re: [bug#58339] ’guix shell’ not working with GUIX_EXTENSIONS_PATH
(name . zimoun)(address . zimon.toutoune@gmail.com)(address . 58339@debbugs.gnu.org)
00943eca15a92b5985361d14b12b6ffe9794c187.camel@gmail.com
Am Freitag, dem 07.10.2022 um 20:49 +0200 schrieb zimoun:
Toggle quote (2 lines)
> Let start to have a simple extension that we can improve by
> incremental changes,
My point is that we already have proper extensions in both guix and
other channels. It's a little late to "start with a simple [one]".

Toggle quote (9 lines)
> On Fri, 7 Oct 2022 at 20:21, Liliana Marie Prikler
> <liliana.prikler@gmail.com> wrote:
>
> > But that's the point.  Simply adding an extension – whether an
> > example or an actually useful one – doesn't teach users how to use
> > them.  It's missing this very information among other things.
>
> The answer of this is provided by the following part of my previous
> message. :-)
I might be missing it or perhaps I disagree. Pick whichever makes
sense to you after reading this mail.

Toggle quote (10 lines)
> > > For instance, let consider guix-modules [1].  It reads,
> > >
> > > --8<---------------cut here---------------start------------->8---
> > > $ guix install guix-modules
> > > $ export GUIX_EXTENSIONS_PATH="$HOME/.guix-
> > > profile/share/guix/extensions"
> > > --8<---------------cut here---------------end--------------->8---
>
> The already included extension 'guix-modules' is usable using the
> snippet above.  And we teach people via a blog post on hpc.guix.info.
A manual is clearly more visible than a blog post. Also, even if that
blog post had everything, we've added blog posts to the cookbook
already, so it wouldn't even be that hard in this case.

Toggle quote (17 lines)
> > > --8<---------------cut here---------------start------------->8---
> > > $ guix shell guix-modules -- guix module -h
> > > guix: module: command not found
> > > Try `guix --help' for more information.
> > >
> > > $ guix shell guix-modules
> > > [env]$ guix module -h
> > > guix: module: command not found
> > > Try `guix --help' for more information.
> > > --8<---------------cut here---------------end--------------->8---
>
> > In case you really didn't know how to use extensions with guix
> > shell, it's guix shell guix your-extension -- guix blah, assuming
> > your extension works with a slightly older guix.
>
> As shown by my snippet above, it does not work; at least on foreign
> distro.
Look at your snippet, then back to mine, now back to your snippet, now
back to mine. Sadly, your snippet isn't mine, but it could be mine if
you added "guix" to the the packages listed before the --.

Cheers
Z
Z
zimoun wrote on 8 Oct 2022 01:35
Re: [bug#58339] ’guix shell’ not working with GUIX_EXTENSIONS_PATH
(name . Liliana Marie Prikler)(address . liliana.prikler@gmail.com)(address . 58339@debbugs.gnu.org)
86v8ouu301.fsf@gmail.com
Hi Liliana,

What are we discussing if we are agreeing? ;-)

Well, from my understanding, we are miscommunicating and somehow just
saying the same thing using a different point of view.


On Fri, 07 Oct 2022 at 21:28, Liliana Marie Prikler <liliana.prikler@gmail.com> wrote:
Toggle quote (8 lines)
> Am Freitag, dem 07.10.2022 um 20:49 +0200 schrieb zimoun:

>> Let start to have a simple extension that we can improve by
>> incremental changes,
>
> My point is that we already have proper extensions in both guix and
> other channels. It's a little late to "start with a simple [one]".

What others do I miss? I am only aware of gwl and guix-modules.

What are the other extensions and from which channels?


Toggle quote (7 lines)
>> The already included extension 'guix-modules' is usable using the
>> snippet above.  And we teach people via a blog post on hpc.guix.info.
>
> A manual is clearly more visible than a blog post. Also, even if that
> blog post had everything, we've added blog posts to the cookbook
> already, so it wouldn't even be that hard in this case.

We agree, I guess. Maybe it was poorly worded but I was saying that the
current situation is not satisfying and these patches are a tiny first
step in improving the situation. Yes the manual is the location for the
documentation and that’s some coming patches. :-)

From my understanding, we are saying the same thing. :-)


Toggle quote (22 lines)
>> > > --8<---------------cut here---------------start------------->8---
>> > > $ guix shell guix-modules -- guix module -h
>> > > guix: module: command not found
>> > > Try `guix --help' for more information.
>> > >
>> > > $ guix shell guix-modules
>> > > [env]$ guix module -h
>> > > guix: module: command not found
>> > > Try `guix --help' for more information.
>> > > --8<---------------cut here---------------end--------------->8---
>>
>> > In case you really didn't know how to use extensions with guix
>> > shell, it's guix shell guix your-extension -- guix blah, assuming
>> > your extension works with a slightly older guix.
>>
>> As shown by my snippet above, it does not work; at least on foreign
>> distro.
>
> Look at your snippet, then back to mine, now back to your snippet, now
> back to mine. Sadly, your snippet isn't mine, but it could be mine if
> you added "guix" to the the packages listed before the --.

Maybe I am wrong or maybe I miss a point but rely on the package ’guix’
is not an option for an extension. We had some discussions [1] about
that on gwl-devel some time ago – which leads to GUIX_EXTENSION_PATH. :-)

Consider,

guix shell guix <whatever> -- guix <something>

then two revisions of Guix are involved:

1. one by ~/.config/current/bin/guix calling the subcommand ’shell’
2. one by ’-- guix <something>’ provided here by the package ’guix’

When an user runs an extension, they expect to run their current Guix.
For instance, consider that ’name-version’ is an extension displaying
name and version.

Toggle snippet (18 lines)
(define-module (guix extensions name-version)
#:use-module (guix scripts)
#:use-module (guix ui)
#:use-module (guix packages)
#:use-module (gnu packages)
#:export (guix-name-version))

(define-command (guix-name-version . args)
(category extension)
(synopsis "show name and version")

(let* ((pkg (car args))
(package (specification->package pkg))
(name (package-name package))
(version (package-version package)))
(format #t (G_ "name: ~a~%version: ~a~%") name version)))

Using Guix 65cabb0, the use of this extension reads,

Toggle snippet (10 lines)
$ GUIX_EXTENSIONS_PATH=/tmp/name-version/guix/extensions guix name-version parallel
name: parallel
version: 20220722

$ guix shell guix
[env]$ GUIX_EXTENSIONS_PATH=/tmp/name-version/guix/extensions guix name-version parallel
name: parallel
version: 20220522

There is no difference with an extension and a proper module once
configured GUIX_EXTENSIONS_PATH adequately. So, equivalently:

Toggle snippet (9 lines)
$ guix show parallel | recsel -p name,version
name: parallel
version: 20220722

$ guix shell guix -- guix show parallel | recsel -p name,version
name: parallel
version: 20220522

That’s why the package guix is not provided (before --) by the snippets
above. It is not a mistake and I still maintain there is an unexpected
behaviour (bug?) for the extensions and ’guix shell’ – the fix you are
proposing does not match the idea behind the extensions, IMHO.

BTW, shell+extension is a corner case from my point of view. I also
maintain it is unrelated to this patch submission. :-)



From the feedback I got at the lightening talk in 10 years event, I
assume the feature is barely known. I still miss what is the concrete
objection with these patches. Could you elaborate? Do they break
something? Are they not compliant?

I got it, you find them useless. :-) But as I said, maybe I or someone
else will improve next – is perfection not the enemy of the good?

The two only Guix extensions I am aware of are ’gwl’ and ’guix-modules’.
Both are complex and difficult starters, IMHO. Hence these tiny starter
examples, for what they are worth.

I am fine to expand ’guix-example’, write a section to the manual, etc.
That’s the general idea with the submission of this patch. :-) Well, I
am just missing the objections because these patches appears to me
complementary and a first tiny step.


Cheers,
simon


L
L
Liliana Marie Prikler wrote on 8 Oct 2022 02:43
Re: [bug#58339] ’guix shell’ not working with GUIX_EXTENSIONS_PATH
(name . zimoun)(address . zimon.toutoune@gmail.com)(address . 58339@debbugs.gnu.org)
d889f25cd82d37db255306d1ba1efb3caae53a2f.camel@gmail.com
Am Samstag, dem 08.10.2022 um 10:35 +0200 schrieb zimoun:
Toggle quote (21 lines)
> Hi Liliana,
>
> What are we discussing if we are agreeing? ;-)
>
> Well, from my understanding, we are miscommunicating and somehow just
> saying the same thing using a different point of view.
>
>
> On Fri, 07 Oct 2022 at 21:28, Liliana Marie Prikler
> <liliana.prikler@gmail.com> wrote:
> > Am Freitag, dem 07.10.2022 um 20:49 +0200 schrieb zimoun:
>
> > > Let start to have a simple extension that we can improve by
> > > incremental changes,
> >
> > My point is that we already have proper extensions in both guix and
> > other channels.  It's a little late to "start with a simple [one]".
>
> What others do I miss?  I am only aware of gwl and guix-modules.
>
> What are the other extensions and from which channels?
Oh, guix-modules is included in Guix proper. I thought it was part of
an HPC channel, my bad.

Toggle quote (14 lines)
> > > The already included extension 'guix-modules' is usable using the
> > > snippet above.  And we teach people via a blog post on
> > > hpc.guix.info.
> >
> > A manual is clearly more visible than a blog post.  Also, even if
> > that blog post had everything, we've added blog posts to the
> > cookbook already, so it wouldn't even be that hard in this case.
>
> We agree, I guess.  Maybe it was poorly worded but I was saying that
> the current situation is not satisfying and these patches are a tiny
> first step in improving the situation.  Yes the manual is the
> location for the documentation and that’s some coming patches. :-)
>
> From my understanding, we are saying the same thing. :-)
From my understanding we are not. Or at least not under the assumption
that you're saying that adding example extensions will somehow improve
the situation. Again, we already have actual extensions packaged, I
don't see what the point would be in having an example one.

Toggle quote (29 lines)
> > > > > --8<---------------cut here---------------start-------------
> > > > > >8---
> > > > > $ guix shell guix-modules -- guix module -h
> > > > > guix: module: command not found
> > > > > Try `guix --help' for more information.
> > > > >
> > > > > $ guix shell guix-modules
> > > > > [env]$ guix module -h
> > > > > guix: module: command not found
> > > > > Try `guix --help' for more information.
> > > > > --8<---------------cut here---------------end---------------
> > > > > >8---
> > >
> > > > In case you really didn't know how to use extensions with guix
> > > > shell, it's guix shell guix your-extension -- guix blah,
> > > > assuming
> > > > your extension works with a slightly older guix.
> > >
> > > As shown by my snippet above, it does not work; at least on
> > > foreign distro.
> >
> > Look at your snippet, then back to mine, now back to your snippet,
> > now back to mine.  Sadly, your snippet isn't mine, but it could be
> > mine if you added "guix" to the the packages listed before the --.
>
> Maybe I am wrong or maybe I miss a point but rely on the package
> ’guix’ is not an option for an extension.  We had some discussions
> [1] about that on gwl-devel some time ago – which leads to
> GUIX_EXTENSION_PATH. :-)
IIUC this discussion is only tangentially related to what we're
discussing now. At the time of writing, only the guix package provides
GUIX_EXTENSION_PATH as a search path -- similar to how glib is one of
the few packages to provide XDG_DATA_DIRS.

Toggle quote (68 lines)
> Consider,
>
>     guix shell guix <whatever> -- guix <something>
>
> then two revisions of Guix are involved:
>
>   1. one by ~/.config/current/bin/guix calling the subcommand ’shell’
>   2. one by ’-- guix <something>’ provided here by the package ’guix’
>
> When an user runs an extension, they expect to run their current
> Guix. For instance, consider that ’name-version’ is an extension
> displaying name and version.
>
> --8<---------------cut here---------------start------------->8---
> (define-module (guix extensions name-version)
>   #:use-module (guix scripts)
>   #:use-module (guix ui)
>   #:use-module (guix packages)
>   #:use-module (gnu packages)
>   #:export (guix-name-version))
>
> (define-command (guix-name-version . args)
>   (category extension)
>   (synopsis "show name and version")
>
>   (let* ((pkg (car args))
>          (package (specification->package pkg))
>          (name (package-name package))
>          (version (package-version package)))
>     (format #t (G_ "name: ~a~%version: ~a~%") name version)))
> --8<---------------cut here---------------end--------------->8---
>
> Using Guix 65cabb0, the use of this extension reads,
>
> --8<---------------cut here---------------start------------->8---
> $ GUIX_EXTENSIONS_PATH=/tmp/name-version/guix/extensions guix name-
> version parallel
> name: parallel
> version: 20220722
>
> $ guix shell guix
> [env]$ GUIX_EXTENSIONS_PATH=/tmp/name-version/guix/extensions guix
> name-version parallel
> name: parallel
> version: 20220522
> --8<---------------cut here---------------end--------------->8---
>
> There is no difference with an extension and a proper module once
> configured GUIX_EXTENSIONS_PATH adequately.  So, equivalently:
>
> --8<---------------cut here---------------start------------->8---
> $ guix show parallel | recsel -p name,version
> name: parallel
> version: 20220722
>
> $ guix shell guix -- guix show parallel | recsel -p name,version
> name: parallel
> version: 20220522
> --8<---------------cut here---------------end--------------->8---
>
> That’s why the package guix is not provided (before --) by the
> snippets above.  It is not a mistake and I still maintain there is an
> unexpected behaviour (bug?) for the extensions and ’guix shell’ – the
> fix you are proposing does not match the idea behind the extensions,
> IMHO.
>
> BTW, shell+extension is a corner case from my point of view.  I also
> maintain it is unrelated to this patch submission. :-)
To be fair, the actual bug here is -- as I've said in a number of
patches already -- that manifests don't have first-class search paths.
Were it not for that, you could do guix shell normally.

However, this difference in package versions, while visible, should not
be something a *simple* extension needs to care about. Plus, I think
people have mentioned the "extensions as channels" pattern, which I
believe is what Andrew was using for Guix Home before it became
upstreamed (and might still be using).

Toggle quote (17 lines)
> From the feedback I got at the lightening talk in 10 years event, I
> assume the feature is barely known.  I still miss what is the
> concrete objection with these patches.  Could you elaborate?  Do they
> break something?  Are they not compliant?
>
> I got it, you find them useless. :-) But as I said, maybe I or
> someone else will improve next – is perfection not the enemy of the
> good?
>
> The two only Guix extensions I am aware of are ’gwl’ and ’guix-
> modules’. Both are complex and difficult starters, IMHO.  Hence
> these tiny starter examples, for what they are worth.
>
> I am fine to expand ’guix-example’, write a section to the manual,
> etc. That’s the general idea with the submission of this patch. :-)
> Well, I am just missing the objections because these patches appears
> to me complementary and a first tiny step.
I reject the idea of including examples that are strictly less
explanatory than GNU hello -- which imho all the hitherto proposed ones
are -- as packages to install solely on the ground that gwl and guix-
modules are "complex and difficult starters". Of course, they are
complex by the nature of the real-world problems they are trying to
solve, but that doesn't mean there are no real-world problems with
simpler solutions.

The work a novice user would have to do to understand all of guix-
example would be to `guix build -S guix-example', then understand its
code, followed by `guix edit guix-example', understand that, and
finally apply it to their use case. Note how this includes commands
that are typically more on the contributor side. Also note how the
code is splintered in two segments so they have to switch between the
two (or it's tangled as in the case of guix-hello, which also has its
issues). The cookbook on the other hand can be read with the info
reader (or browser) of their choice, and is thus imho preferable. It
also offers a better way of putting the code together without literally
writing the extension code inside the package itself.

Cheers
C
C
Christopher Baines wrote on 8 Dec 2022 03:36
tag 58339 moreinfo
(address . control@debbugs.gnu.org)
871qpa5dqo.fsf@cbaines.net
tags 58339 + moreinfo
quit
?
Your comment

Commenting via the web interface is currently disabled.

To comment on this conversation send an email to 58339@patchwise.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 58339
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch