help-guix
[Top][All Lists]
Advanced

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

Re: Guix and Emacs Integration for Polyglot Development


From: Ludovic Courtès
Subject: Re: Guix and Emacs Integration for Polyglot Development
Date: Fri, 14 Sep 2018 11:56:06 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux)

Hello!

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




reply via email to

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