From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jan Nieuwenhuizen Subject: Re: Guix and Emacs Integration for Polyglot Development Date: Thu, 13 Sep 2018 22:45:19 +0200 Message-ID: <875zz9gm8w.fsf@gnu.org> References: <87wos9rp5y.fsf@gnu.org> <87wos5cma6.fsf@gnu.org> <87tvn9s14w.fsf@gnu.org> <87k1o5b05d.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:38746) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g0YUt-0004OM-6T for help-guix@gnu.org; Thu, 13 Sep 2018 16:45:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g0YUr-00074g-OF for help-guix@gnu.org; Thu, 13 Sep 2018 16:45:54 -0400 In-Reply-To: <87k1o5b05d.fsf@gnu.org> ("Ludovic \=\?utf-8\?Q\?Court\=C3\=A8s\=22'\?\= \=\?utf-8\?Q\?s\?\= message of "Sat, 01 Sep 2018 19:25:18 +0200") List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-guix-bounces+gcggh-help-guix=m.gmane.org@gnu.org Sender: "Help-Guix" To: Ludovic =?utf-8?Q?Court=C3=A8s?= Cc: help-guix@gnu.org Ludovic Court=C3=A8s 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 =3D ((#< variable: "PATH" files: ("bin" "s= bin") separator: ":" file-type: directory file-pattern: #f> . "/home/ludo/.= guix-profile/bin:/home/ludo/.guix-profile/sbin") (#< variable: "PYTHONPATH" files: ("lib/python3.6/site-packages") separato= r: ":" file-type: directory file-pattern: #f> . "/home/ludo/.guix-profile/l= ib/python3.6/site-packages") =E2=80=A6 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 p= rofile)))) (map (match-lambda ((spec . dir) (list (search-path-specification-vari= able 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