all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Guix and Emacs Integration for Polyglot Development
@ 2018-07-27 18:53 Kenny Ballou
  2018-08-02  8:08 ` Chris Marusich
  2018-09-11  1:10 ` George Clemmer
  0 siblings, 2 replies; 30+ messages in thread
From: Kenny Ballou @ 2018-07-27 18:53 UTC (permalink / raw)
  To: help-guix


This may be the wrong list, but I figure most Guix users/developers are
_probably_ also Emacs users, I figured I would ask here first...

Obviously, there is the [[alezost/guix.el][guix.el]] for interacting
with Guix from within Emacs.  However, what sort of integration is
available for Emacs with the ~guix environment -m
<some-project-manifest.scm>~ command.  I would like to be able to
specify a project's dependencies in a manifest file, add any environment
variables as necessary, and have Emacs be aware of those variables when
entering that environment.  Tools like ~pyflake~ for Python projects, or
~go-fmt~ integration for a Golang project, would have their regular
integration with Emacs when in those environments.  All of this without
having to have some version of the tools installed in either the user
profile or the host OS (regardless if that's GuixSD or some other
foreign distribution), both of which would disallow usage of `--pure`
during development (not my ideal).  Furthermore, to me is it preferable
to only have one Emacs (server) session that is capable of switching
between projects and different ~guix environments~, as opposed to adding
Emacs to the development dependencies of a project and using several
different Emacs instances/sessions.

Understandably, this may be tricky for a number of reasons:

- Keeping many buffers/files that are in a different environments may
  causes issues when the environments switch, causing some buffers to
  lose connections or reference to the tools the buffer expects.

- Global(?) variables everywhere, unless this is easy to add to a buffer
  local or similar?

- (e)Shell or long running process integration and patching.  Similar
  problems for other inferior shells, e.g., ~python~, ~geiser~, ~ghc~,
  etc.

Perhaps a solution is to integrate with a "project" root
~.dir-locals.el~ file for each environment.  However, since I'm not well
versed in what is possible with such a file, I don't know if this is
viable.

Another solution would be to attempt to integrate with something like
~projectile~ for the variables, but this sounds similar to the previous
idea.  Moreover, this forces ~projectile~ onto users and that is perhaps
not appropriate.

Hopefully, what I have described makes sense.  I'm hoping to see what
other users are doing for this kind of setup.

Thanks in advance.

-Kenny

#+LINK: alezost/guix.el https://github.com/alezost/guix.el
#+LINK: bauer-nix-emacs: https://matthewbauer.us/blog/bauer.html

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

* Re: Guix and Emacs Integration for Polyglot Development
  2018-07-27 18:53 Kenny Ballou
@ 2018-08-02  8:08 ` Chris Marusich
  2018-08-05 19:16   ` Kenny Ballou
  2018-09-11  1:10 ` George Clemmer
  1 sibling, 1 reply; 30+ messages in thread
From: Chris Marusich @ 2018-08-02  8:08 UTC (permalink / raw)
  To: Kenny Ballou; +Cc: help-guix

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

Kenny Ballou <kballou@devnulllabs.io> writes:

> I would like to be able to specify a project's dependencies in a
> manifest file, add any environment variables as necessary, and have
> Emacs be aware of those variables when entering that environment.

It may not be what you're looking for, but projects like Haunt [1] put a
guix.scm file in the root directory of their project.  The file contains
a package as its top-level form (I think that's the right terminology),
and you can get the dependencies via "guix environment -l guix.scm".

Hope that helps!

Footnotes: 
[1]  http://haunt.dthompson.us

-- 
Chris

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

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

* Re: Guix and Emacs Integration for Polyglot Development
  2018-08-02  8:08 ` Chris Marusich
@ 2018-08-05 19:16   ` Kenny Ballou
  2018-08-20 12:32     ` Maxim Cournoyer
  0 siblings, 1 reply; 30+ messages in thread
From: Kenny Ballou @ 2018-08-05 19:16 UTC (permalink / raw)
  To: Chris Marusich; +Cc: help-guix


On 2018年08月02日 08:08 GMT, Chris Marusich wrote:
> Kenny Ballou <kballou@devnulllabs.io> writes:
>
>> I would like to be able to specify a project's dependencies in a
>> manifest file, add any environment variables as necessary, and have
>> Emacs be aware of those variables when entering that environment.
>
> It may not be what you're looking for, but projects like Haunt [1] put a
> guix.scm file in the root directory of their project.  The file contains
> a package as its top-level form (I think that's the right terminology),
> and you can get the dependencies via "guix environment -l guix.scm".

When I mentioned the "manifest" file, I wasn't aware it was common to
refer to this file as `guix.scm`, but yes, this is definitely the first
part.  However, to clarify, my question is regarding the second part:
how to get the `guix.scm` and any environment variables loaded as part
of `guix environment -l guix.scm` or `guix environment -m
project_manifest.scm`-- search paths and similar -- integrated into the
buffers local to the project directory?  I believe `.dir-locals.el` or
similar might actually be the right approach here, but I'm still in the
early stages of exploring this.

I hope that clarifies my question better.  For more reference, I'm also
thinking of wingo's blog on developing v8 with guix[1] (though I believe
`guix environment` wasn't yet available).

Again, if this is the wrong list, I can move this question to emacs-help
instead.

-Kenny

[1]: https://wingolog.org/archives/2015/08/04/developing-v8-with-guix

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

* Re: Guix and Emacs Integration for Polyglot Development
  2018-08-05 19:16   ` Kenny Ballou
@ 2018-08-20 12:32     ` Maxim Cournoyer
  2018-08-24 21:55       ` Ludovic Courtès
  2018-08-31 12:49       ` Maxim Cournoyer
  0 siblings, 2 replies; 30+ messages in thread
From: Maxim Cournoyer @ 2018-08-20 12:32 UTC (permalink / raw)
  To: Kenny Ballou; +Cc: help-guix

Hi Kenny!

Kenny Ballou <kballou@devnulllabs.io> writes:

> On 2018年08月02日 08:08 GMT, Chris Marusich wrote:
>> Kenny Ballou <kballou@devnulllabs.io> writes:
>>
>>> I would like to be able to specify a project's dependencies in a
>>> manifest file, add any environment variables as necessary, and have
>>> Emacs be aware of those variables when entering that environment.
>>
>> It may not be what you're looking for, but projects like Haunt [1] put a
>> guix.scm file in the root directory of their project.  The file contains
>> a package as its top-level form (I think that's the right terminology),
>> and you can get the dependencies via "guix environment -l guix.scm".
>
> When I mentioned the "manifest" file, I wasn't aware it was common to
> refer to this file as `guix.scm`, but yes, this is definitely the first
> part.  However, to clarify, my question is regarding the second part:
> how to get the `guix.scm` and any environment variables loaded as part
> of `guix environment -l guix.scm` or `guix environment -m
> project_manifest.scm`-- search paths and similar -- integrated into the
> buffers local to the project directory?  I believe `.dir-locals.el` or
> similar might actually be the right approach here, but I'm still in the
> early stages of exploring this.
>
> I hope that clarifies my question better.  For more reference, I'm also
> thinking of wingo's blog on developing v8 with guix[1] (though I believe
> `guix environment` wasn't yet available).
>
> Again, if this is the wrong list, I can move this question to emacs-help
> instead.

I think it's a valid question here, and I'd like to find a great
solution too! So far when using guix environments, I resorted to:

1. Spawning the environment in the command line
2. Starting a new Emacs instance (not attached to my Emacs server) from
this environment, so that it gets access to all the variables and tools
defined within the environment.

I see there is a way to create Guix environments in Emacs using the Emacs-Guix tool,
but it seems those are limited to be used from a *shell* like buffer;
Emacs is not magically picking up tools that might become available in
that new environment.

If you find a more integrated way to work with a single instance of
Emacs (say, emacs-server) + Guix environments, please let us know!

Thank you,

Maxim

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

* Re: Guix and Emacs Integration for Polyglot Development
  2018-08-20 12:32     ` Maxim Cournoyer
@ 2018-08-24 21:55       ` Ludovic Courtès
  2018-08-25 19:47         ` Alex Kost
  2018-08-31 12:49       ` Maxim Cournoyer
  1 sibling, 1 reply; 30+ messages in thread
From: Ludovic Courtès @ 2018-08-24 21:55 UTC (permalink / raw)
  To: Maxim Cournoyer; +Cc: Kenny Ballou, help-guix

Hello!

Maxim Cournoyer <maxim.cournoyer@gmail.com> skribis:

> I think it's a valid question here, and I'd like to find a great
> solution too! So far when using guix environments, I resorted to:
>
> 1. Spawning the environment in the command line
> 2. Starting a new Emacs instance (not attached to my Emacs server) from
> this environment, so that it gets access to all the variables and tools
> defined within the environment.
>
> I see there is a way to create Guix environments in Emacs using the Emacs-Guix tool,
> but it seems those are limited to be used from a *shell* like buffer;
> Emacs is not magically picking up tools that might become available in
> that new environment.
>
> If you find a more integrated way to work with a single instance of
> Emacs (say, emacs-server) + Guix environments, please let us know!

That’s also something I’m interested in.  For example, I’ve done things
like:

  M-x compile RET guix environment … -- make -j4

in the past, but it’s inconvenient and respawning ‘guix environment’
every time is inefficient.

It would be nice if we could somehow attach an environment to a buffer,
and for instance have M-x compile operate under that environment.

Another interesting thing would be the ability to have Babel snippet
specify their complete environment, instead of just the language.  For
that we’d need help from Emacs-Guix to keep track of existing
environments.

Maybe if Alex Kost is reading this they can comment.  :-)

Thanks,
Ludo’.

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

* Re: Guix and Emacs Integration for Polyglot Development
  2018-08-24 21:55       ` Ludovic Courtès
@ 2018-08-25 19:47         ` Alex Kost
  2018-08-25 21:59           ` Ludovic Courtès
  0 siblings, 1 reply; 30+ messages in thread
From: Alex Kost @ 2018-08-25 19:47 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: Kenny Ballou, help-guix

Ludovic Courtès (2018-08-24 23:55 +0200) wrote:

[...]
> It would be nice if we could somehow attach an environment to a buffer,
> and for instance have M-x compile operate under that environment.
>
> Another interesting thing would be the ability to have Babel snippet
> specify their complete environment, instead of just the language.  For
> that we’d need help from Emacs-Guix to keep track of existing
> environments.
>
> Maybe if Alex Kost is reading this they can comment.  :-)

I am not "they", I prefer to be called "he" ;-)

I am afraid I don't plan to do anything related to the features you
discuss, sorry.

-- 
Alex

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

* Re: Guix and Emacs Integration for Polyglot Development
  2018-08-25 19:47         ` Alex Kost
@ 2018-08-25 21:59           ` Ludovic Courtès
  0 siblings, 0 replies; 30+ messages in thread
From: Ludovic Courtès @ 2018-08-25 21:59 UTC (permalink / raw)
  To: Alex Kost; +Cc: Kenny Ballou, help-guix

Hello Alex,

Alex Kost <alezost@gmail.com> skribis:

> Ludovic Courtès (2018-08-24 23:55 +0200) wrote:
>
> [...]
>> It would be nice if we could somehow attach an environment to a buffer,
>> and for instance have M-x compile operate under that environment.
>>
>> Another interesting thing would be the ability to have Babel snippet
>> specify their complete environment, instead of just the language.  For
>> that we’d need help from Emacs-Guix to keep track of existing
>> environments.
>>
>> Maybe if Alex Kost is reading this they can comment.  :-)
>
> I am not "they", I prefer to be called "he" ;-)

Noted, sorry.

> I am afraid I don't plan to do anything related to the features you
> discuss, sorry.

I was soliciting comments, nothing more, but that’s okay.

Ludo’.

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

* Re: Guix and Emacs Integration for Polyglot Development
@ 2018-08-29 18:41 Jan Nieuwenhuizen
  2018-09-01 14:41 ` Ludovic Courtès
  0 siblings, 1 reply; 30+ messages in thread
From: Jan Nieuwenhuizen @ 2018-08-29 18:41 UTC (permalink / raw)
  To: help-guix

Hi!

Just subscribed to help-guix because of a request on IRC, so hoping that
OP is subscribed here, or someone can notify them.

I have an ugly hack to switch emacs to a profile or environment.  It
parses the <profile>/etc/profile script...using MANIFEST or
`--search-paths' would be much nicer...

Anyway, I'm using some named profiles, eg

    ~/.config/guix/mes

and when starting work on mes i do

    M-x guix-switch-profile RET ~/.config/guix/mes RET

similar for other projects I work on.

A real solution would be nice...

HTH, janneke

--8<---------------cut here---------------start------------->8---
(defun guix-switch-profile (&optional profile)
  "reset Emacs' environment by snarfing PROFILE/etc/profile"

  (defun matches-in-string (regexp string)
    "return a list of matches of REGEXP in STRING."
    (let ((matches))
      (save-match-data
        (string-match "^" "")
        (while (string-match regexp string (match-end 0))
          (push (or (match-string 1 string) (match-string 0 string)) matches)))
      matches))

  (interactive "fprofile: ")
  (let* ((output (shell-command-to-string (concat "GUIX_PROFILE= /bin/sh -x " profile "/etc/profile")))
         (exports (matches-in-string "^[+] export \\(.*\\)" output)))
    (mapcar (lambda (line) (apply #'setenv (split-string line "="))) exports )))
--8<---------------cut here---------------end--------------->8---

-- 
Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.com

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

* Re: Guix and Emacs Integration for Polyglot Development
  2018-08-20 12:32     ` Maxim Cournoyer
  2018-08-24 21:55       ` Ludovic Courtès
@ 2018-08-31 12:49       ` Maxim Cournoyer
  2018-09-10 15:25         ` Kenny Ballou
  1 sibling, 1 reply; 30+ messages in thread
From: Maxim Cournoyer @ 2018-08-31 12:49 UTC (permalink / raw)
  To: Kenny Ballou; +Cc: help-guix

Hello!

I'm reposting Janneke's recent answer here so that it can have all its
context and participants.

Jan Nieuwenhuizen <janneke@gnu.org> writes:

> Hi!
>
> Just subscribed to help-guix because of a request on IRC, so hoping that
> OP is subscribed here, or someone can notify them.
>
> I have an ugly hack to switch emacs to a profile or environment.  It
> parses the <profile>/etc/profile script...using MANIFEST or
> `--search-paths' would be much nicer...
>
> Anyway, I'm using some named profiles, eg
>
>     ~/.config/guix/mes
>
> and when starting work on mes i do
>
>     M-x guix-switch-profile RET ~/.config/guix/mes RET
>
> similar for other projects I work on.
>
> A real solution would be nice...
>
> HTH, janneke
>
> --8<---------------cut here---------------start------------->8---
>
> (defun guix-switch-profile (&optional profile)
>   "reset Emacs' environment by snarfing PROFILE/etc/profile"
>
>   (defun matches-in-string (regexp string)
>     "return a list of matches of REGEXP in STRING."
>     (let ((matches))
>       (save-match-data
>         (string-match "^" "")
>         (while (string-match regexp string (match-end 0))
>           (push (or (match-string 1 string) (match-string 0 string)) matches)))
>       matches))
>
>   (interactive "fprofile: ")
>   (let* ((output (shell-command-to-string (concat "GUIX_PROFILE= /bin/sh -x " profile "/etc/profile")))
>          (exports (matches-in-string "^[+] export \\(.*\\)" output)))
>     (mapcar (lambda (line) (apply #'setenv (split-string line "="))) exports )))
> --8<---------------cut here---------------end--------------->8---

Thank you, Janneke!

An alternative if you'd like to also define some variables (say,
PYTHONPATH to add a couple of sources libraries while working on a
Python project) would be to use `direnv'[0] and `emacs-direnv'.

Christopher Baines detailed the solution in this thread:
https://lists.gnu.org/archive/html/guix-devel/2017-05/msg00475.html.

I hope this helps!

Maxim

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

* Re: Guix and Emacs Integration for Polyglot Development
  2018-08-29 18:41 Guix and Emacs Integration for Polyglot Development Jan Nieuwenhuizen
@ 2018-09-01 14:41 ` Ludovic Courtès
  2018-09-01 15:11   ` Jan Nieuwenhuizen
  0 siblings, 1 reply; 30+ messages in thread
From: Ludovic Courtès @ 2018-09-01 14:41 UTC (permalink / raw)
  To: Jan Nieuwenhuizen; +Cc: help-guix

Hi!

Jan Nieuwenhuizen <janneke@gnu.org> skribis:

> I have an ugly hack to switch emacs to a profile or environment.  It
> parses the <profile>/etc/profile script...using MANIFEST or
> `--search-paths' would be much nicer...
>
> Anyway, I'm using some named profiles, eg
>
>     ~/.config/guix/mes
>
> and when starting work on mes i do
>
>     M-x guix-switch-profile RET ~/.config/guix/mes RET
>
> similar for other projects I work on.

Very nice!  To make the code nicer, I suppose we could simply change it
to use the Geiser integration in emacs-guix.  We could call out to (guix
profiles) and (guix search-paths) and ‘setenv’ what it returns.

It might turn out to be more code that what you posted though, so your
solution is not that bad after all!

Ludo’.

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

* Re: Guix and Emacs Integration for Polyglot Development
  2018-09-01 14:41 ` Ludovic Courtès
@ 2018-09-01 15:11   ` Jan Nieuwenhuizen
  2018-09-01 17:25     ` Ludovic Courtès
  0 siblings, 1 reply; 30+ messages in thread
From: Jan Nieuwenhuizen @ 2018-09-01 15:11 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: help-guix

Ludovic Courtès writes:

> Very nice!  To make the code nicer, I suppose we could simply change it
> to use the Geiser integration in emacs-guix.  We could call out to (guix
> profiles) and (guix search-paths) and ‘setenv’ what it returns.

Hmm, interesting!  I was thinking I should have used the guix repl to
guix package -m ... / guix environment --search-paths; or that we should
create the information that's now in etc/profile also in sexp form,
possibly readable by Guile and Emacs Lisp alike...

> It might turn out to be more code that what you posted though, so your
> solution is not that bad after all!

...but indeed, then I settled for "parsing" sh ;-)

janneke

-- 
Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.com

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

* Re: Guix and Emacs Integration for Polyglot Development
  2018-09-01 15:11   ` Jan Nieuwenhuizen
@ 2018-09-01 17:25     ` Ludovic Courtès
  2018-09-13 20:45       ` Jan Nieuwenhuizen
  0 siblings, 1 reply; 30+ messages in thread
From: Ludovic Courtès @ 2018-09-01 17:25 UTC (permalink / raw)
  To: Jan Nieuwenhuizen; +Cc: help-guix

Jan Nieuwenhuizen <janneke@gnu.org> skribis:

> Ludovic Courtès writes:
>
>> Very nice!  To make the code nicer, I suppose we could simply change it
>> to use the Geiser integration in emacs-guix.  We could call out to (guix
>> profiles) and (guix search-paths) and ‘setenv’ what it returns.
>
> Hmm, interesting!  I was thinking I should have used the guix repl to
> guix package -m ... / guix environment --search-paths; or that we should
> create the information that's now in etc/profile also in sexp form,
> possibly readable by Guile and Emacs Lisp alike...

In all modesty ;-) I think the API is rather good:

--8<---------------cut here---------------start------------->8---
scheme@(guile-user)> ,use(guix profiles)
scheme@(guile-user)> (profile-search-paths "/home/ludo/.guix-profile")
$11 = ((#<<search-path-specification> variable: "PATH" files: ("bin" "sbin") separator: ":" file-type: directory file-pattern: #f> . "/home/ludo/.guix-profile/bin:/home/ludo/.guix-profile/sbin") (#<<search-path-specification> variable: "PYTHONPATH" files: ("lib/python3.6/site-packages") separator: ":" file-type: directory file-pattern: #f> . "/home/ludo/.guix-profile/lib/python3.6/site-packages") …
--8<---------------cut here---------------end--------------->8---

Ludo’.

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

* Re: Guix and Emacs Integration for Polyglot Development
  2018-08-31 12:49       ` Maxim Cournoyer
@ 2018-09-10 15:25         ` Kenny Ballou
  0 siblings, 0 replies; 30+ messages in thread
From: Kenny Ballou @ 2018-09-10 15:25 UTC (permalink / raw)
  To: Maxim Cournoyer; +Cc: help-guix


On 2018-08-31 12:49 GMT, Maxim Cournoyer wrote:
> Hello!
>
> I'm reposting Janneke's recent answer here so that it can have all its
> context and participants.
>
> Jan Nieuwenhuizen <janneke@gnu.org> writes:
>
>> Hi!
>>
>> Just subscribed to help-guix because of a request on IRC, so hoping that
>> OP is subscribed here, or someone can notify them.
>>
>> I have an ugly hack to switch emacs to a profile or environment.  It
>> parses the <profile>/etc/profile script...using MANIFEST or
>> `--search-paths' would be much nicer...
>>
>> Anyway, I'm using some named profiles, eg
>>
>>     ~/.config/guix/mes
>>
>> and when starting work on mes i do
>>
>>     M-x guix-switch-profile RET ~/.config/guix/mes RET
>>
>> similar for other projects I work on.
>>
>> A real solution would be nice...
>>
>> HTH, janneke
>>
>> --8<---------------cut here---------------start------------->8---
>>
>> (defun guix-switch-profile (&optional profile)
>>   "reset Emacs' environment by snarfing PROFILE/etc/profile"
>>
>>   (defun matches-in-string (regexp string)
>>     "return a list of matches of REGEXP in STRING."
>>     (let ((matches))
>>       (save-match-data
>>         (string-match "^" "")
>>         (while (string-match regexp string (match-end 0))
>>           (push (or (match-string 1 string) (match-string 0 string)) matches)))
>>       matches))
>>
>>   (interactive "fprofile: ")
>>   (let* ((output (shell-command-to-string (concat "GUIX_PROFILE= /bin/sh -x " profile "/etc/profile")))
>>          (exports (matches-in-string "^[+] export \\(.*\\)" output)))
>>     (mapcar (lambda (line) (apply #'setenv (split-string line "="))) exports )))
>> --8<---------------cut here---------------end--------------->8---
>
> Thank you, Janneke!
>
> An alternative if you'd like to also define some variables (say,
> PYTHONPATH to add a couple of sources libraries while working on a
> Python project) would be to use `direnv'[0] and `emacs-direnv'.
>
> Christopher Baines detailed the solution in this thread:
> https://lists.gnu.org/archive/html/guix-devel/2017-05/msg00475.html.
>
> I hope this helps!
>
> Maxim


Thank you for posting this, I still haven't had a chance to play around
with this yet, but I think this is the kind of solution that is exactly
what I'm looking for.  However, Named profiles was sorta where I was
leaning.

I may not use the `emacs-direnv` part.  But I if I understand correctly,
switching profiles will change the `${HOME}/.guix-profile` symlink, I
can just statically add the current profile to any path variables and go
from there(?).

Again, thank you and apologies for the necrobump because of late
replies...

-Kenny

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

* Re: Guix and Emacs Integration for Polyglot Development
  2018-07-27 18:53 Kenny Ballou
  2018-08-02  8:08 ` Chris Marusich
@ 2018-09-11  1:10 ` George Clemmer
  1 sibling, 0 replies; 30+ messages in thread
From: George Clemmer @ 2018-09-11  1:10 UTC (permalink / raw)
  To: Kenny Ballou; +Cc: help-guix

Kenny Ballou <kballou@devnulllabs.io> writes:

> I would like to be able to specify a project's dependencies in a
> manifest file, add any environment variables as necessary, and have
> Emacs be aware of those variables when entering that environment.

Hi Kenny,

I have experimented with various schemes for managing projects in
guix. I have tried 'guix environment', 'guix package', and 'guix system
vm'. FWIW, I have ended up "running" projects with an script that
includes ...

GCP_ROOT=$gcp_root guix package \
	--profile=$gcp_root/.guix-profile \
	-m $gcp_root/.manifest.scm

eval $(guix package -p /var/guix/profiles/system/profile \
	-p $gcp_root/.guix-profile --search-paths=exact)

... where $gcp_root is the project directory.  This effectively replaces
the "default user profile" with a "custom project profile"
($gcp_root/.guix-profile). I put the emacs project config in
$gcp_root/.emacs and run emacs with a script that includes ...

$GCP_ROOT/.guix-profile/bin/emacs \
    --no-site-file \
    --eval='(let ((guix-env (concat (getenv "GCP_ROOT") "/.guix-profile"))) (when (and guix-env (require (quote guix-emacs) nil t)) (guix-emacs-autoload-packages guix-env)))' \
    --no-init-file \
    --eval='(setq user-emacs-directory (concat (getenv "GCP_ROOT") "/.emacs.d/"))' \
    --eval='(load (concat (getenv "GCP_ROOT") "/.emacs"))' \
    --debug-init \
    "$@"

The net effect: a custom emacs config running in a custom profile for
each project. I use Makefiles to maintain $gcp_root/.manifest.scm,
$gcp_root/.emacs, etc. and GNU screen to run/juggle these projects.

HTH - George

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

* Re: Guix and Emacs Integration for Polyglot Development
  2018-09-01 17:25     ` Ludovic Courtès
@ 2018-09-13 20:45       ` Jan Nieuwenhuizen
  2018-09-14  9:56         ` Ludovic Courtès
                           ` (2 more replies)
  0 siblings, 3 replies; 30+ messages in thread
From: Jan Nieuwenhuizen @ 2018-09-13 20:45 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: help-guix

Ludovic Courtès writes:

> In all modesty ;-) I think the API is rather good:
>
> scheme@(guile-user)> ,use(guix profiles)
> scheme@(guile-user)> (profile-search-paths "/home/ludo/.guix-profile")
> $11 = ((#<<search-path-specification> variable: "PATH" files: ("bin" "sbin") separator: ":" file-type: directory file-pattern: #f> . "/home/ludo/.guix-profile/bin:/home/ludo/.guix-profile/sbin") (#<<search-path-specification> variable: "PYTHONPATH" files: ("lib/python3.6/site-packages") separator: ":" file-type: directory file-pattern: #f> . "/home/ludo/.guix-profile/lib/python3.6/site-packages") …

Whoa, that helps!  Is it just me who is so dense -- I really think this
REPL'y power of Guix is much under-appreciated and would deserve
more attention.

So, what about (thanks to Ricardo via #guile irc and wasamasa via #emacs)

--8<---------------cut here---------------start------------->8---
(defun guix-switch-profile (&optional profile)
  "Switch Emacs' environment to PROFILE.  PROFILE can be a named
profile (like ~/.guix-profile, ~/.config/guix/work) or an
environment (like: echo $GUIX_ENVIRONMENT)."

  (interactive "fprofile: ")
  (lexical-let* ((guix-program
                  `(begin
                    (use-modules (ice-9 match)
                                 (guix profiles)
                                 (guix search-paths))
                    (let ((specs (profile-search-paths ,(expand-file-name profile))))
                      (map
                       (match-lambda ((spec . dir)
                                      (list (search-path-specification-variable spec)
                                            (or (search-path-specification-separator spec) "")
                                            dir)))
                       specs))))
                 (guix-output (guix-eval (format "%S" guix-program)))
                 (profile-sexp (car (read-from-string (car guix-output)))))
    (mapcar*
     (lambda (variable separator path)
       (lexical-let ((value (cond ((string-empty-p separator) path)
                                  ((getenv variable) (concat path separator (getenv variable)))
                                  (t path))))
         (setenv variable value)))
     (mapcar #'car profile-sexp)
     (mapcar #'cadr profile-sexp)
     (mapcar #'caddr profile-sexp))))
--8<---------------cut here---------------end--------------->8---

and where to put this?

janneke

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

* Re: Guix and Emacs Integration for Polyglot Development
  2018-09-13 20:45       ` Jan Nieuwenhuizen
@ 2018-09-14  9:56         ` Ludovic Courtès
  2018-09-14 11:53           ` Jan Nieuwenhuizen
  2018-09-14 21:34         ` Alex Kost
  2018-10-26  1:22         ` Maxim Cournoyer
  2 siblings, 1 reply; 30+ messages in thread
From: Ludovic Courtès @ 2018-09-14  9:56 UTC (permalink / raw)
  To: Jan Nieuwenhuizen; +Cc: help-guix

Hello!

Jan Nieuwenhuizen <janneke@gnu.org> skribis:

> Ludovic Courtès writes:
>
>> In all modesty ;-) I think the API is rather good:
>>
>> scheme@(guile-user)> ,use(guix profiles)
>> scheme@(guile-user)> (profile-search-paths "/home/ludo/.guix-profile")
>> $11 = ((#<<search-path-specification> variable: "PATH" files: ("bin" "sbin") separator: ":" file-type: directory file-pattern: #f> . "/home/ludo/.guix-profile/bin:/home/ludo/.guix-profile/sbin") (#<<search-path-specification> variable: "PYTHONPATH" files: ("lib/python3.6/site-packages") separator: ":" file-type: directory file-pattern: #f> . "/home/ludo/.guix-profile/lib/python3.6/site-packages") …
>
> Whoa, that helps!  Is it just me who is so dense -- I really think this
> REPL'y power of Guix is much under-appreciated and would deserve
> more attention.

Heheh, maybe!

> So, what about (thanks to Ricardo via #guile irc and wasamasa via #emacs)
>
> (defun guix-switch-profile (&optional profile)
>   "Switch Emacs' environment to PROFILE.  PROFILE can be a named
> profile (like ~/.guix-profile, ~/.config/guix/work) or an
> environment (like: echo $GUIX_ENVIRONMENT)."
>
>   (interactive "fprofile: ")
>   (lexical-let* ((guix-program
>                   `(begin
>                     (use-modules (ice-9 match)
>                                  (guix profiles)
>                                  (guix search-paths))
>                     (let ((specs (profile-search-paths ,(expand-file-name profile))))
>                       (map
>                        (match-lambda ((spec . dir)
>                                       (list (search-path-specification-variable spec)
>                                             (or (search-path-specification-separator spec) "")
>                                             dir)))
>                        specs))))
>                  (guix-output (guix-eval (format "%S" guix-program)))
>                  (profile-sexp (car (read-from-string (car guix-output)))))
>     (mapcar*
>      (lambda (variable separator path)
>        (lexical-let ((value (cond ((string-empty-p separator) path)
>                                   ((getenv variable) (concat path separator (getenv variable)))
>                                   (t path))))
>          (setenv variable value)))
>      (mapcar #'car profile-sexp)
>      (mapcar #'cadr profile-sexp)
>      (mapcar #'caddr profile-sexp))))
>
> and where to put this?

That LGTM!  Perhaps you could submit it for inclusion in Emacs-Guix
<https://github.com/alezost/guix.el>?

Thank you,
Ludo’.

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

* Re: Guix and Emacs Integration for Polyglot Development
  2018-09-14  9:56         ` Ludovic Courtès
@ 2018-09-14 11:53           ` Jan Nieuwenhuizen
  0 siblings, 0 replies; 30+ messages in thread
From: Jan Nieuwenhuizen @ 2018-09-14 11:53 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: help-guix

Ludovic Courtès writes:

>> (defun guix-switch-profile (&optional profile)
>>   "Switch Emacs' environment to PROFILE.  PROFILE can be a named
>> profile (like ~/.guix-profile, ~/.config/guix/work) or an
>> environment (like: echo $GUIX_ENVIRONMENT)."
snip
>> and where to put this?
>
> That LGTM!  Perhaps you could submit it for inclusion in Emacs-Guix
> <https://github.com/alezost/guix.el>?

Thanks, done!
janneke

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

* Re: Guix and Emacs Integration for Polyglot Development
  2018-09-13 20:45       ` Jan Nieuwenhuizen
  2018-09-14  9:56         ` Ludovic Courtès
@ 2018-09-14 21:34         ` Alex Kost
  2018-09-15  5:21           ` Jan Nieuwenhuizen
  2018-10-26  4:59           ` George Clemmer
  2018-10-26  1:22         ` Maxim Cournoyer
  2 siblings, 2 replies; 30+ messages in thread
From: Alex Kost @ 2018-09-14 21:34 UTC (permalink / raw)
  To: Jan Nieuwenhuizen; +Cc: help-guix

Jan Nieuwenhuizen (2018-09-13 22:45 +0200) wrote:

> (defun guix-switch-profile (&optional profile)
>   "Switch Emacs' environment to PROFILE.  PROFILE can be a named
> profile (like ~/.guix-profile, ~/.config/guix/work) or an
> environment (like: echo $GUIX_ENVIRONMENT)."
>
>   (interactive "fprofile: ")
>   (lexical-let* ((guix-program
>                   `(begin
>                     (use-modules (ice-9 match)
>                                  (guix profiles)
>                                  (guix search-paths))
>                     (let ((specs (profile-search-paths ,(expand-file-name profile))))
>                       (map
>                        (match-lambda ((spec . dir)
>                                       (list (search-path-specification-variable spec)
>                                             (or (search-path-specification-separator spec) "")
>                                             dir)))
>                        specs))))
>                  (guix-output (guix-eval (format "%S" guix-program)))
>                  (profile-sexp (car (read-from-string (car guix-output)))))
>     (mapcar*
>      (lambda (variable separator path)
>        (lexical-let ((value (cond ((string-empty-p separator) path)
>                                   ((getenv variable) (concat path separator (getenv variable)))
>                                   (t path))))
>          (setenv variable value)))
>      (mapcar #'car profile-sexp)
>      (mapcar #'cadr profile-sexp)
>      (mapcar #'caddr profile-sexp))))

Thank you!  I'm going to apply it.  I have extracted the guile code and
put it to the "scheme side" of Emacs-Guix, also I have rewritten this
command a bit.  The only thing: I don't like the name (neither
"guix-switch-profile" nor "guix-profile-apply").  I think
"guix-set-emacs-environment" suits better, as setting the environment is
exactly what this command does, WDYT?

You may look at my version of your patch (not in "master" yet) here:

  https://notabug.org/alezost/emacs-guix/commit/a4bd696f0b8c564c1e654c426e9059cac1607996

Let me know, if you think something should be fixed there.

-- 
Alex

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

* Re: Guix and Emacs Integration for Polyglot Development
  2018-09-14 21:34         ` Alex Kost
@ 2018-09-15  5:21           ` Jan Nieuwenhuizen
  2018-09-15 19:40             ` Alex Kost
  2018-10-26  4:59           ` George Clemmer
  1 sibling, 1 reply; 30+ messages in thread
From: Jan Nieuwenhuizen @ 2018-09-15  5:21 UTC (permalink / raw)
  To: Alex Kost; +Cc: help-guix

Alex Kost writes:

> Jan Nieuwenhuizen (2018-09-13 22:45 +0200) wrote:
>
>> (defun guix-switch-profile (&optional profile)

> Thank you!  I'm going to apply it.  I have extracted the guile code and
> put it to the "scheme side" of Emacs-Guix, also I have rewritten this
> command a bit.  The only thing: I don't like the name (neither
> "guix-switch-profile" nor "guix-profile-apply").  I think
> "guix-set-emacs-environment" suits better, as setting the environment is
> exactly what this command does, WDYT?

> You may look at my version of your patch (not in "master" yet) here:
>
>   https://notabug.org/alezost/emacs-guix/commit/a4bd696f0b8c564c1e654c426e9059cac1607996

Thank you, I enjoyed reading your rewrite, makes me happy!  Moving the
scheme side makes it cleaner and I learned about -let, nice :-)

I also like the new name better, you see that I struggled/renaed because
I wasn't happy with it.  The initial switch-profile name was simply
chosen because that's how I use it: to switch between my named profiles.

> Let me know, if you think something should be fixed there.

I think it's OK to go in.  The thing I'm not really happy with yet is
the UX of how to switch to temporary `guix environment ...'
environments.  You have to do: echo $GUIX_ENVIRONMENT, <select>, <cut>,
M-x guix-set-emacs-environment RET <paste> ... but I have no idea how we
could improve on that.  Thoughts?

janneke

-- 
Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.com

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

* Re: Guix and Emacs Integration for Polyglot Development
  2018-09-15  5:21           ` Jan Nieuwenhuizen
@ 2018-09-15 19:40             ` Alex Kost
  0 siblings, 0 replies; 30+ messages in thread
From: Alex Kost @ 2018-09-15 19:40 UTC (permalink / raw)
  To: Jan Nieuwenhuizen; +Cc: help-guix

Jan Nieuwenhuizen (2018-09-15 07:21 +0200) wrote:

> Alex Kost writes:
>
>> Jan Nieuwenhuizen (2018-09-13 22:45 +0200) wrote:
>>
>>> (defun guix-switch-profile (&optional profile)
>
>> Thank you!  I'm going to apply it.  I have extracted the guile code and
>> put it to the "scheme side" of Emacs-Guix, also I have rewritten this
>> command a bit.  The only thing: I don't like the name (neither
>> "guix-switch-profile" nor "guix-profile-apply").  I think
>> "guix-set-emacs-environment" suits better, as setting the environment is
>> exactly what this command does, WDYT?
>
>> You may look at my version of your patch (not in "master" yet) here:
>>
>>   https://notabug.org/alezost/emacs-guix/commit/a4bd696f0b8c564c1e654c426e9059cac1607996
>
> Thank you, I enjoyed reading your rewrite, makes me happy!  Moving the
> scheme side makes it cleaner and I learned about -let, nice :-)

"-let" (and other "-foo" procedures and macros) is from "emacs-dash"
package.  This library contains many useful things to work with lists:

  https://github.com/magnars/dash.el

> I also like the new name better, you see that I struggled/renaed because
> I wasn't happy with it.  The initial switch-profile name was simply
> chosen because that's how I use it: to switch between my named profiles.

Ah, I see.

>> Let me know, if you think something should be fixed there.
>
> I think it's OK to go in.

Thanks, it is in master now.

> The thing I'm not really happy with yet is
> the UX of how to switch to temporary `guix environment ...'
> environments.  You have to do: echo $GUIX_ENVIRONMENT, <select>, <cut>,
> M-x guix-set-emacs-environment RET <paste> ... but I have no idea how we
> could improve on that.  Thoughts?

Sorry, I also don't see a way to simplify this.

-- 
Alex

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

* Re: Guix and Emacs Integration for Polyglot Development
  2018-09-13 20:45       ` Jan Nieuwenhuizen
  2018-09-14  9:56         ` Ludovic Courtès
  2018-09-14 21:34         ` Alex Kost
@ 2018-10-26  1:22         ` Maxim Cournoyer
  2 siblings, 0 replies; 30+ messages in thread
From: Maxim Cournoyer @ 2018-10-26  1:22 UTC (permalink / raw)
  To: Jan Nieuwenhuizen; +Cc: help-guix

Hello!

Jan Nieuwenhuizen <janneke@gnu.org> writes:

> Ludovic Courtès writes:
>
>> In all modesty ;-) I think the API is rather good:
>>
>> scheme@(guile-user)> ,use(guix profiles)
>> scheme@(guile-user)> (profile-search-paths "/home/ludo/.guix-profile")
>> $11 = ((#<<search-path-specification> variable: "PATH" files: ("bin"
>> "sbin") separator: ":" file-type: directory file-pattern: #f>
>> . "/home/ludo/.guix-profile/bin:/home/ludo/.guix-profile/sbin")
>> (#<<search-path-specification> variable: "PYTHONPATH" files:
>> ("lib/python3.6/site-packages") separator: ":" file-type: directory
>> file-pattern: #f>
>> . "/home/ludo/.guix-profile/lib/python3.6/site-packages") …
>
> Whoa, that helps!  Is it just me who is so dense -- I really think this
> REPL'y power of Guix is much under-appreciated and would deserve
> more attention.
>
> So, what about (thanks to Ricardo via #guile irc and wasamasa via #emacs)
>
> (defun guix-switch-profile (&optional profile)
>   "Switch Emacs' environment to PROFILE.  PROFILE can be a named
> profile (like ~/.guix-profile, ~/.config/guix/work) or an
> environment (like: echo $GUIX_ENVIRONMENT)."
>
>   (interactive "fprofile: ")
>   (lexical-let* ((guix-program
>                   `(begin
>                     (use-modules (ice-9 match)
>                                  (guix profiles)
>                                  (guix search-paths))
>                     (let ((specs (profile-search-paths ,(expand-file-name profile))))
>                       (map
>                        (match-lambda ((spec . dir)
>                                       (list (search-path-specification-variable spec)
>                                             (or (search-path-specification-separator spec) "")
>                                             dir)))
>                        specs))))
>                  (guix-output (guix-eval (format "%S" guix-program)))
>                  (profile-sexp (car (read-from-string (car guix-output)))))
>     (mapcar*
>      (lambda (variable separator path)
>        (lexical-let ((value (cond ((string-empty-p separator) path)
>                                   ((getenv variable) (concat path separator (getenv variable)))
>                                   (t path))))
>          (setenv variable value)))
>      (mapcar #'car profile-sexp)
>      (mapcar #'cadr profile-sexp)
>      (mapcar #'caddr profile-sexp))))
>
> and where to put this?
>
> janneke

Thanks for sharing this and better -- contributing it to Emacs-Guix!
I've already tried it and it seems to work well :)

For those who'd like to try it, it's part of Emacs-Guix but not released
yet. The command is M-x guix-set-emacs-environment, and it prompts for a
profile.

You can upgrade your Emacs-Guix a recent commit by using the following
package definition (I just added it to my emacs.scm file and
./pre-inst-env guix package -u emacs-guix):

--8<---------------cut here---------------start------------->8---
(define-public my-emacs-guix
  (package
    (inherit emacs-guix)
    (name "emacs-guix")
    (version "0.5.1")
    (source (origin
              (method git-fetch)
              (uri (git-reference
                    (url "https://notabug.org/alezost/emacs-guix.git")
                    (commit "012dbf6959108f3e6d953dc7e3b1941fb11db33d")))
              (file-name (string-append name "-" version "-checkout"))
              (sha256
               (base32
                "1c44dklskj96krfdm6l4i2h2z80h0xri6bzwzcm9mcd93y1icrm4"))))
    (native-inputs
     `(("autoconf" ,autoconf)
       ("automake" ,automake)
       ("texinfo" ,texinfo)
       ,@(package-native-inputs emacs-guix)))))
--8<---------------cut here---------------end--------------->8---

Thanks again!

Maxim

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

* Re: Guix and Emacs Integration for Polyglot Development
  2018-09-14 21:34         ` Alex Kost
  2018-09-15  5:21           ` Jan Nieuwenhuizen
@ 2018-10-26  4:59           ` George Clemmer
  2018-10-26 17:04             ` Alex Kost
  1 sibling, 1 reply; 30+ messages in thread
From: George Clemmer @ 2018-10-26  4:59 UTC (permalink / raw)
  To: Alex Kost; +Cc: help-guix

Hi Alex,

I have been using code like ...

(with-eval-after-load (quote guix-ui-profile)
  (setq guix-profiles
	(append (quote("/home/glc/gom/.guix-profile")) guix-profiles)))
(setq guix-current-profile "/home/glc/gom/.guix-profile")

... to add a "project" profile to *Guix Profile* and make it
current. This has my desired effect: "making" emacs-guix package-related
commands operate on a "project" profile instead of the "default user
profile". Using your commit ...

4ce2b6a * master origin/master Add new 'guix' command and rename the old
one to 'guix-command'

... I tried "guix-set-emacs-environment" expecting it to be another way
to do the same thing.  I was surprised when it didn't add the "new"
profile to *Guix Profiles*. Shouldn't it do this, or am I missing
something? In fact, it doesn't seem to be doing anything :-(

I'm also using git from guix v0.15.0-2913-g21c51ebd6.

TIA - George

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

* Re: Guix and Emacs Integration for Polyglot Development
  2018-10-26  4:59           ` George Clemmer
@ 2018-10-26 17:04             ` Alex Kost
  2018-10-26 18:01               ` George Clemmer
  0 siblings, 1 reply; 30+ messages in thread
From: Alex Kost @ 2018-10-26 17:04 UTC (permalink / raw)
  To: George Clemmer; +Cc: help-guix

George Clemmer (2018-10-26 00:59 -0400) wrote:

> Hi Alex,

Hello George!

> I have been using code like ...
>
> (with-eval-after-load (quote guix-ui-profile)
>   (setq guix-profiles
> 	(append (quote("/home/glc/gom/.guix-profile")) guix-profiles)))
> (setq guix-current-profile "/home/glc/gom/.guix-profile")
>
> ... to add a "project" profile to *Guix Profile* and make it
> current. This has my desired effect: "making" emacs-guix package-related
> commands operate on a "project" profile instead of the "default user
> profile". Using your commit ...
>
> 4ce2b6a * master origin/master Add new 'guix' command and rename the old
> one to 'guix-command'

  Hint: since you are on this commit, you may check the new "M-x guix" -
  you will be the first person who will try it (maybe you will like it
  this time)  ;-)

> ... I tried "guix-set-emacs-environment" expecting it to be another way
> to do the same thing.  I was surprised when it didn't add the "new"
> profile to *Guix Profiles*. Shouldn't it do this, or am I missing
> something? In fact, it doesn't seem to be doing anything :-(

"M-x guix-set-emacs-environment" sets environment variables for Emacs
itself!  For example, you may check "M-x getenv PATH" or other
variables.  They should be augmented for the profile you selected.

-- 
Alex

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

* Re: Guix and Emacs Integration for Polyglot Development
  2018-10-26 17:04             ` Alex Kost
@ 2018-10-26 18:01               ` George Clemmer
  2018-10-26 20:56                 ` George Clemmer
  0 siblings, 1 reply; 30+ messages in thread
From: George Clemmer @ 2018-10-26 18:01 UTC (permalink / raw)
  To: Alex Kost; +Cc: help-guix


Alex Kost <alezost@gmail.com> writes:

> George Clemmer (2018-10-26 00:59 -0400) wrote:
>
>> Hi Alex,
>
> Hello George!
>
>> I have been using code like ...
>>
>> (with-eval-after-load (quote guix-ui-profile)
>>   (setq guix-profiles
>> 	(append (quote("/home/glc/gom/.guix-profile")) guix-profiles)))
>> (setq guix-current-profile "/home/glc/gom/.guix-profile")
>>
>> ... to add a "project" profile to *Guix Profile* and make it
>> current. This has my desired effect: "making" emacs-guix package-related
>> commands operate on a "project" profile instead of the "default user
>> profile". Using your commit ...
>>
>> 4ce2b6a * master origin/master Add new 'guix' command and rename the old
>> one to 'guix-command'
>
>   Hint: since you are on this commit, you may check the new "M-x guix" -
>   you will be the first person who will try it (maybe you will like it
>   this time)  ;-)

Yes, I saw that you moved the old guix to guix-command which sounds
great and works here. Sadly, 'M-x guix' gives me a backtrace ...

Debugger entered--Lisp error: (error "Autoloading file /home/glc/gom/.gpm/gfg/emacs-guix/emacs-guix/elisp/guix-command.elc failed to define function guix")
  autoload-do-load((autoload "guix-command" "Popup window for 'guix'." t nil) guix)
  command-execute(guix record)
  execute-extended-command(nil "guix" "guix")
  funcall-interactively(execute-extended-command nil "guix" "guix")
  call-interactively(execute-extended-command nil nil)
  command-execute(execute-extended-command)

... with this emacs-guix config ...

;;; >>> /home/glc/gom//home/glc/gom/.gpm/gfg/emacs-guix/init.el
;; run emacs-guix from git checkout
(add-to-list 'load-path (substitute-in-file-name "$GPM_ROOT/.gpm/gfg/emacs-guix/emacs-guix/elisp"))
(require 'guix-autoloads nil t)

;; use guix from the Git working tree
(setq guix-load-path (substitute-in-file-name "$GPM_ROOT/.gpm/gfg/guix/guix"))

;; enable development mode 'C-c . _' functions in .scm buffers
(add-hook 'scheme-mode-hook 'guix-devel-mode)

;; don't use results, if any, of a guix pull
(setq guix-repl-use-latest nil)

;;; >>> /home/glc/gom//home/glc/gom/.gpm/gfg/geiser/init.el
;; run bleading-edge geiser
(load (substitute-in-file-name "$GPM_ROOT/.gpm/gfg/geiser/geiser/elisp/geiser-load") t)

;; enable development mode 'C-c . _' functions in .scm buffers
(add-hook 'scheme-mode-hook 'guix-devel-mode)

>> ... I tried "guix-set-emacs-environment" expecting it to be another way
>> to do the same thing.  I was surprised when it didn't add the "new"
>> profile to *Guix Profiles*. Shouldn't it do this, or am I missing
>> something? In fact, it doesn't seem to be doing anything :-(
>
> "M-x guix-set-emacs-environment" sets environment variables for Emacs
> itself!  For example, you may check "M-x getenv PATH" or other
> variables.  They should be augmented for the profile you selected.

Oh, DUH! Thanks!

- George

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

* Re: Guix and Emacs Integration for Polyglot Development
  2018-10-26 18:01               ` George Clemmer
@ 2018-10-26 20:56                 ` George Clemmer
  2018-10-27 14:42                   ` Alex Kost
  0 siblings, 1 reply; 30+ messages in thread
From: George Clemmer @ 2018-10-26 20:56 UTC (permalink / raw)
  To: Alex Kost; +Cc: help-guix


Hi Alex,

Oops, please disregard the problem reported earlier (cc below).  I had
the emacs-guix package installed at the same time the load path included
the source build. When I remove the package .. everything works fine.

George Clemmer <myglc2@gmail.com> writes:

> Alex Kost <alezost@gmail.com> writes:
>
>>   Hint: since you are on this commit, you may check the new "M-x guix" -
>>   you will be the first person who will try it (maybe you will like it
>>   this time)  ;-)

I am sorry if I gave the impression that I disliked it. I do like the
new one better. It makes it easier to find and use Emacs-guix features.

I have another question. Is there a shortcut to
guix-installed-system-packages in the popup that I am missing?

> Yes, I saw that you moved the old guix to guix-command which sounds
> great and works here. Sadly, 'M-x guix' gives me a backtrace ...
>
> Debugger entered--Lisp error: (error "Autoloading file /home/glc/gom/.gpm/gfg/emacs-guix/emacs-guix/elisp/guix-command.elc failed to define function guix")
>   autoload-do-load((autoload "guix-command" "Popup window for 'guix'." t nil) guix)
>   command-execute(guix record)
>   execute-extended-command(nil "guix" "guix")
>   funcall-interactively(execute-extended-command nil "guix" "guix")
>   call-interactively(execute-extended-command nil nil)
>   command-execute(execute-extended-command)

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

* Re: Guix and Emacs Integration for Polyglot Development
  2018-10-26 20:56                 ` George Clemmer
@ 2018-10-27 14:42                   ` Alex Kost
  2018-10-27 19:32                     ` George Clemmer
  0 siblings, 1 reply; 30+ messages in thread
From: Alex Kost @ 2018-10-27 14:42 UTC (permalink / raw)
  To: George Clemmer; +Cc: help-guix

George Clemmer (2018-10-26 16:56 -0400) wrote:

>> Alex Kost <alezost@gmail.com> writes:
>>
>>>   Hint: since you are on this commit, you may check the new "M-x guix" -
>>>   you will be the first person who will try it (maybe you will like it
>>>   this time)  ;-)
>
> I am sorry if I gave the impression that I disliked it.

No problem, I dislike it :-)

> I do like the
> new one better. It makes it easier to find and use Emacs-guix features.

Great!  It was the main intention.

> I have another question. Is there a shortcut to
> guix-installed-system-packages in the popup that I am missing?

No, there is a direct shortcut.  Currently there are 2 "long" ways
to access system packages from "M-x guix":

1) setting current profile to the system one ("p" in "packages"
sub-popup) and openning installed packages (with "i" key), or

2) through *Guix Profiles* buffer (which can be accessed with "M-x guix
P a"): there you can move to the system profile and press "P".

I'm afraid, I am not going to add a shortcut for system packages inside
"packages" sub-popup, as it and "profiles" sub-popup are designed to
work with the current profile, so if you want to open packages or
generations from some profile, you need to make it the current one at
first.

But maybe it would be good to add a new sub-popup for system commands,
where a key for system packages will be placed, WDYT?

-- 
Alex

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

* Re: Guix and Emacs Integration for Polyglot Development
  2018-10-27 14:42                   ` Alex Kost
@ 2018-10-27 19:32                     ` George Clemmer
  2018-10-28 14:39                       ` Alex Kost
  0 siblings, 1 reply; 30+ messages in thread
From: George Clemmer @ 2018-10-27 19:32 UTC (permalink / raw)
  To: Alex Kost; +Cc: help-guix


Alex Kost <alezost@gmail.com> writes:

> George Clemmer (2018-10-26 16:56 -0400) wrote:
>
>> I have another question. Is there a shortcut to
>> guix-installed-system-packages in the popup that I am missing?
>
> No, there is a direct shortcut.  Currently there are 2 "long" ways
> to access system packages from "M-x guix":
>
> 1) setting current profile to the system one ("p" in "packages"
> sub-popup) and openning installed packages (with "i" key), or
>
> 2) through *Guix Profiles* buffer (which can be accessed with "M-x guix
> P a"): there you can move to the system profile and press "P".

I also found ... 'M-x guix P s P' ... which I had missed and is all I
want/need ;-)

> I'm afraid, I am not going to add a shortcut for system packages inside
> "packages" sub-popup, as it and "profiles" sub-popup are designed to
> work with the current profile, so if you want to open packages or
> generations from some profile, you need to make it the current one at
> first.
>
> But maybe it would be good to add a new sub-popup for system commands,
> where a key for system packages will be placed, WDYT?

I agree with your approach.  I think this is all REALLY GREAT STUFF. You
can leave it just the way it is and I will be happy.

FWIW, here are a few comments/ideas ...

It would be handy if 'quit-window' in the final buffer reached via
*guix-popup* took me take me back 'UP' the "tree" of sub-popups that
lead there so I could chose another option.

With regard to system/user profiles. First, to state what may not be
obvious to a novice guix user ...

- In addition to the "default user" profile, you may use multiple "user
  project" profiles.

- In practice, a novice uses the packages in the union of the system and
  default "user" profile. A more advanced user may have 1 or more
  "project" profiles as well.

- The system profile is fundamentally "a different kind of
  animal". There is only one and you need different guix "tools" to
  modify it.

In the present design, presenting the system profile as "just another
profile" in *Guix Profiles* leads to slapping the user's hand if/when
they try to change the system profile, E.g.,

    user-error: Packages cannot be installed or removed to/from profile ’/var/guix/profiles/system/profile’.
    Use ’guix system reconfigure’ shell command to modify a system profile.

If, as you suggest, you create the system sub-popup, you might consider
removing the system profile from *Guix Profiles* since the user can get
to the system profile package list via system generations + 'P'. Of
course, you may still choose to show the user the error message above,
but it would no longer be an asymmetric behavior on one of a group of
things presented as equals.

It might be useful to allow the user to see system profile packages in
the context a user/project profile. E.g., a key could toggle the system
profile packages into and out of the *Guix Packages * list view.

HTH - George

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

* Re: Guix and Emacs Integration for Polyglot Development
  2018-10-27 19:32                     ` George Clemmer
@ 2018-10-28 14:39                       ` Alex Kost
  2018-10-28 21:19                         ` George Clemmer
  0 siblings, 1 reply; 30+ messages in thread
From: Alex Kost @ 2018-10-28 14:39 UTC (permalink / raw)
  To: George Clemmer; +Cc: help-guix

George Clemmer (2018-10-27 15:32 -0400) wrote:

> Alex Kost <alezost@gmail.com> writes:
>
>> George Clemmer (2018-10-26 16:56 -0400) wrote:
>>
>>> I have another question. Is there a shortcut to
>>> guix-installed-system-packages in the popup that I am missing?
>>
>> No, there is a direct shortcut.  Currently there are 2 "long" ways
>> to access system packages from "M-x guix":
>>
>> 1) setting current profile to the system one ("p" in "packages"
>> sub-popup) and openning installed packages (with "i" key), or
>>
>> 2) through *Guix Profiles* buffer (which can be accessed with "M-x guix
>> P a"): there you can move to the system profile and press "P".
>
> I also found ... 'M-x guix P s P' ... which I had missed and is all I
> want/need ;-)

Oh, cool, I forgot about it :-)

>> I'm afraid, I am not going to add a shortcut for system packages inside
>> "packages" sub-popup, as it and "profiles" sub-popup are designed to
>> work with the current profile, so if you want to open packages or
>> generations from some profile, you need to make it the current one at
>> first.
>>
>> But maybe it would be good to add a new sub-popup for system commands,
>> where a key for system packages will be placed, WDYT?
>
> I agree with your approach.  I think this is all REALLY GREAT STUFF. You
> can leave it just the way it is and I will be happy.
>
> FWIW, here are a few comments/ideas ...
>
> It would be handy if 'quit-window' in the final buffer reached via
> *guix-popup* took me take me back 'UP' the "tree" of sub-popups that
> lead there so I could chose another option.

Is "q" key what you are looking for?  It is a general "magit-popup"
thing and there is nothing I can do about it on Emacs-Guix side.

Note, however, that "q" works only for one level, I mean if you press
"q" one time, it will take you back to the previous popup, but if you
press it again, it will simply quit.  Yet again, this is how
"magit-popup" works.

> With regard to system/user profiles. First, to state what may not be
> obvious to a novice guix user ...
>
> - In addition to the "default user" profile, you may use multiple "user
>   project" profiles.
>
> - In practice, a novice uses the packages in the union of the system and
>   default "user" profile. A more advanced user may have 1 or more
>   "project" profiles as well.
>
> - The system profile is fundamentally "a different kind of
>   animal". There is only one and you need different guix "tools" to
>   modify it.
>
> In the present design, presenting the system profile as "just another
> profile" in *Guix Profiles* leads to slapping the user's hand if/when
> they try to change the system profile, E.g.,
>
>     user-error: Packages cannot be installed or removed to/from profile ’/var/guix/profiles/system/profile’.
>     Use ’guix system reconfigure’ shell command to modify a system profile.
>
> If, as you suggest, you create the system sub-popup

I went ahead and added it (by commit bffd65a).  I think keeping system
commands in one place is good.

> you might consider
> removing the system profile from *Guix Profiles* since the user can get
> to the system profile package list via system generations + 'P'.

No, no, I will not hide system profile.  Yes, you can't install anything
to it with the usual means, but it is a profile after all, and you can
see what packages are installed there.  Besides, some day a user should
learn that the only way to update a system profile is "guix system …"
command.

BTW, in general, I think that hiding features is a bad thing… however,
there is one hidden feature in Emacs-Guix (although, it is hidden just
because it is also hidden in Guix itself ;-) )

> Of
> course, you may still choose to show the user the error message above,
> but it would no longer be an asymmetric behavior on one of a group of
> things presented as equals.
>
> It might be useful to allow the user to see system profile packages in
> the context a user/project profile. E.g., a key could toggle the system
> profile packages into and out of the *Guix Packages * list view.

Sorry, I didn't understand this phrase.  Do you mean there should be a
key in *Guix Packages* buffer to show system packages along with the
current user packages?  If so, I'm afraid it is not possible, as these
"Packages" buffers are designed to show packages only from a single
profile.

-- 
Alex

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

* Re: Guix and Emacs Integration for Polyglot Development
  2018-10-28 14:39                       ` Alex Kost
@ 2018-10-28 21:19                         ` George Clemmer
  2018-10-29 16:37                           ` Alex Kost
  0 siblings, 1 reply; 30+ messages in thread
From: George Clemmer @ 2018-10-28 21:19 UTC (permalink / raw)
  To: Alex Kost; +Cc: help-guix

Hi Alex,

Alex Kost <alezost@gmail.com> writes:

> George Clemmer (2018-10-27 15:32 -0400) wrote:
>
>> FWIW, here are a few comments/ideas ...
>>
>> It would be handy if 'quit-window' in the final buffer reached via
>> *guix-popup* took me take me back 'UP' the "tree" of sub-popups that
>> lead there so I could chose another option.
>
> Is "q" key what you are looking for?  It is a general "magit-popup"
> thing and there is nothing I can do about it on Emacs-Guix side.
>
> Note, however, that "q" works only for one level, I mean if you press
> "q" one time, it will take you back to the previous popup, but if you
> press it again, it will simply quit.  Yet again, this is how
> "magit-popup" works.

I see. Thanks for letting me know.

>> If, as you suggest, you create the system sub-popup

> I went ahead and added it (by commit bffd65a).  I think keeping system
> commands in one place is good.

Yes, I agree. I tried it. Very cool.

>> you might consider
>> removing the system profile from *Guix Profiles* since the user can get
>> to the system profile package list via system generations + 'P'.
>
> No, no, I will not hide system profile.  Yes, you can't install anything
> to it with the usual means, but it is a profile after all, and you can
> see what packages are installed there.  Besides, some day a user should
> learn that the only way to update a system profile is "guix system …"
> command.

OK, no problem ;)

> BTW, in general, I think that hiding features is a bad thing… however,
> there is one hidden feature in Emacs-Guix (although, it is hidden just
> because it is also hidden in Guix itself ;-) )

Is this a riddle?

>> It might be useful to allow the user to see system profile packages in
>> the context a user/project profile. E.g., a key could toggle the system
>> profile packages into and out of the *Guix Packages * list view.
>
> Sorry, I didn't understand this phrase.  Do you mean there should be a
> key in *Guix Packages* buffer to show system packages along with the
> current user packages?  If so, I'm afraid it is not possible, as these
> "Packages" buffers are designed to show packages only from a single
> profile.

Yes. It's a "blue sky" idea.

Thanks.

-George

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

* Re: Guix and Emacs Integration for Polyglot Development
  2018-10-28 21:19                         ` George Clemmer
@ 2018-10-29 16:37                           ` Alex Kost
  0 siblings, 0 replies; 30+ messages in thread
From: Alex Kost @ 2018-10-29 16:37 UTC (permalink / raw)
  To: George Clemmer; +Cc: help-guix

George Clemmer (2018-10-28 17:19 -0400) wrote:

> Alex Kost <alezost@gmail.com> writes:
[...]
>> BTW, in general, I think that hiding features is a bad thing… however,
>> there is one hidden feature in Emacs-Guix (although, it is hidden just
>> because it is also hidden in Guix itself ;-) )
>
> Is this a riddle?

Yeah, this feature is rather easy to find in Emacs-Guix, because it is
"hidden" ;-)

-- 
grep

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

end of thread, other threads:[~2018-10-29 16:38 UTC | newest]

Thread overview: 30+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-29 18:41 Guix and Emacs Integration for Polyglot Development Jan Nieuwenhuizen
2018-09-01 14:41 ` Ludovic Courtès
2018-09-01 15:11   ` Jan Nieuwenhuizen
2018-09-01 17:25     ` Ludovic Courtès
2018-09-13 20:45       ` Jan Nieuwenhuizen
2018-09-14  9:56         ` Ludovic Courtès
2018-09-14 11:53           ` Jan Nieuwenhuizen
2018-09-14 21:34         ` Alex Kost
2018-09-15  5:21           ` Jan Nieuwenhuizen
2018-09-15 19:40             ` Alex Kost
2018-10-26  4:59           ` George Clemmer
2018-10-26 17:04             ` Alex Kost
2018-10-26 18:01               ` George Clemmer
2018-10-26 20:56                 ` George Clemmer
2018-10-27 14:42                   ` Alex Kost
2018-10-27 19:32                     ` George Clemmer
2018-10-28 14:39                       ` Alex Kost
2018-10-28 21:19                         ` George Clemmer
2018-10-29 16:37                           ` Alex Kost
2018-10-26  1:22         ` Maxim Cournoyer
  -- strict thread matches above, loose matches on Subject: below --
2018-07-27 18:53 Kenny Ballou
2018-08-02  8:08 ` Chris Marusich
2018-08-05 19:16   ` Kenny Ballou
2018-08-20 12:32     ` Maxim Cournoyer
2018-08-24 21:55       ` Ludovic Courtès
2018-08-25 19:47         ` Alex Kost
2018-08-25 21:59           ` Ludovic Courtès
2018-08-31 12:49       ` Maxim Cournoyer
2018-09-10 15:25         ` Kenny Ballou
2018-09-11  1:10 ` George Clemmer

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.