[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Guix and Emacs Integration for Polyglot Development

From: Maxim Cournoyer
Subject: Re: Guix and Emacs Integration for Polyglot Development
Date: Thu, 25 Oct 2018 21:22:22 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux)


Jan Nieuwenhuizen <address@hidden> 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

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
    (inherit emacs-guix)
    (name "emacs-guix")
    (version "0.5.1")
    (source (origin
              (method git-fetch)
              (uri (git-reference
                    (url "";)
                    (commit "012dbf6959108f3e6d953dc7e3b1941fb11db33d")))
              (file-name (string-append name "-" version "-checkout"))
     `(("autoconf" ,autoconf)
       ("automake" ,automake)
       ("texinfo" ,texinfo)
       ,@(package-native-inputs emacs-guix)))))
--8<---------------cut here---------------end--------------->8---

Thanks again!


reply via email to

[Prev in Thread] Current Thread [Next in Thread]