unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: ludo@gnu.org (Ludovic Courtès)
To: Christopher Baines <mail@cbaines.net>
Cc: guix-devel@gnu.org, 27097@debbugs.gnu.org
Subject: bug#27097: Combining Guix, direnv and Emacs for environment customisation
Date: Tue, 30 May 2017 17:03:26 +0200	[thread overview]
Message-ID: <87tw424cap.fsf@gnu.org> (raw)
In-Reply-To: <20170527123113.1ca668e7@cbaines.net> (Christopher Baines's message of "Sat, 27 May 2017 12:31:13 +0100")

Hi Christopher!

Christopher Baines <mail@cbaines.net> skribis:

> direnv [1] is an environment switcher for shells, for example, you want
> to have a specific environment variable set when working on a particular
> project, you drop a .envrc file in to the relevant directory and
> providing direnv is hooked in to your shell, it will get loaded and
> unloaded as you move in and out of that directory.
>
> 1: https://direnv.net/
>
> While direnv is useful for simple environment variables, guix
> environment can output environment variables with the --shell-paths
> option. Using guix environment in a .envrc file would look something
> like:
>
>   eval "$(guix environment --ad-hoc guile --search-paths)"
>
> There is a use_guix helper function in the direnv stdlib [2] that helps
> with this, so you can just do:
>
>   use guix --ad-hoc guile

This is pretty cool!

However, using ‘guix environment --search-paths’ is kinda unsafe: the
items mentioned in its output are not protected from GC.  This is why
‘guix environment’ normally spawns a shell or some other process while
keep its guix-daemon session open.

> I've recently become aware of emacs-direnv [3], which provides access
> to the functionality of direnv from Emacs. When the global minor mode
> is active, this means that moving around between buffers in Emacs can
> completely change the environment within Emacs. This had made my
> workflow simpler, as I now just open Emacs, and navigate to the
> relevant directory, and direnv just works behind the scenes.
>
> 3: https://github.com/wbolster/emacs-direnv

I think it’d be great Emacs-Guix could do something similar, i.e.,
associate a ‘guix environment’ to a buffer.  :-)

> One issue with this is that running guix environment from direnv will
> slow down switching buffers. To make it a bit more useable, I found
> some bash code that caches the results of running commands, and wrapped
> that around guix environment when invoked from direnv. This helps speed
> things up, but I don't think its useful in the long term.
>
> For this particular use case, it would help if guix environment was
> faster, perhaps by doing caching internally? On my system, running guix
> environment --ad-hoc guile --search-paths repeatedly takes ~2 seconds,
> I haven't looked at what the breakdown of this is yet.

I agree that we could do a lot more things with a faster ‘guix
environment’.  My guess is that it won’t be easy to go optimize, and
very hard to go below 1 second.  We should profile that and see what can
be done.

Cheers,
Ludo’.

  parent reply	other threads:[~2017-05-30 15:04 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-27 10:56 bug#27097: [PATCH] gnu: Add emacs-direnv Christopher Baines
2017-05-28 20:09 ` Ludovic Courtès
     [not found] ` <20170527123113.1ca668e7@cbaines.net>
2017-05-30 15:03   ` Ludovic Courtès [this message]
     [not found]     ` <rbu4lvzetj0.fsf@gnu.org>
2017-06-03 13:59       ` bug#27097: Combining Guix, direnv and Emacs for environment customisation Ludovic Courtès
     [not found]         ` <871sr0ok2h.fsf@gnu.org>
2017-06-04 21:15           ` Ludovic Courtès
     [not found]             ` <87efuym57c.fsf@gnu.org>
     [not found]               ` <878tl4f4d4.fsf@elephly.net>
     [not found]                 ` <8760g856j8.fsf_-_@gnu.org>
2017-06-07 12:59                   ` bug#27097: Performance on NFS Ricardo Wurmus
     [not found]               ` <87a85kt7ad.fsf_-_@gnu.org>
     [not found]                 ` <rbutw3seym8.fsf@gnu.org>
     [not found]                   ` <87a85hnvqm.fsf@gnu.org>
2017-06-12  8:45                     ` [bug#27097] " Roel Janssen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87tw424cap.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=27097@debbugs.gnu.org \
    --cc=guix-devel@gnu.org \
    --cc=mail@cbaines.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

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

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