all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Maxim Cournoyer <maxim.cournoyer@gmail.com>
To: Jan Nieuwenhuizen <janneke@gnu.org>
Cc: help-guix@gnu.org
Subject: Re: Guix and Emacs Integration for Polyglot Development
Date: Thu, 25 Oct 2018 21:22:22 -0400	[thread overview]
Message-ID: <87h8h9v6wh.fsf@gmail.com> (raw)
In-Reply-To: <875zz9gm8w.fsf@gnu.org> (Jan Nieuwenhuizen's message of "Thu, 13 Sep 2018 22:45:19 +0200")

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

  parent reply	other threads:[~2018-10-26  1:22 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
  -- 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

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

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

  git send-email \
    --in-reply-to=87h8h9v6wh.fsf@gmail.com \
    --to=maxim.cournoyer@gmail.com \
    --cc=help-guix@gnu.org \
    --cc=janneke@gnu.org \
    /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 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.