From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Felix Dietrich Newsgroups: gmane.emacs.help Subject: Re: local emacsclient to remote emacs server Date: Sun, 27 Mar 2022 05:58:56 +0200 Message-ID: <87mthckpvj.fsf@sperrhaken.name> References: <61ef851f-1d3a-4070-b19a-ad6d19813fc4@www.fastmail.com> <87o81wc289.fsf@elite.giraud> <3bdba293-340f-4b3f-8d86-8be0d19a9c1c@www.fastmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="39746"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Sun Mar 27 05:59:34 2022 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nYK3x-000ACa-W0 for geh-help-gnu-emacs@m.gmane-mx.org; Sun, 27 Mar 2022 05:59:33 +0200 Original-Received: from localhost ([::1]:33706 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nYK3w-0006Fj-Ep for geh-help-gnu-emacs@m.gmane-mx.org; Sat, 26 Mar 2022 23:59:32 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:38316) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nYK3a-0006FZ-N6 for help-gnu-emacs@gnu.org; Sat, 26 Mar 2022 23:59:10 -0400 Original-Received: from mout.kundenserver.de ([212.227.17.10]:47441) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nYK3Y-00082W-QR for help-gnu-emacs@gnu.org; Sat, 26 Mar 2022 23:59:10 -0400 Original-Received: from localhost ([78.55.235.154]) by mrelayeu.kundenserver.de (mreue109 [212.227.15.183]) with ESMTPSA (Nemesis) id 1M5Q6l-1nWx0p1ubt-001Pzz for ; Sun, 27 Mar 2022 05:59:06 +0200 In-Reply-To: <3bdba293-340f-4b3f-8d86-8be0d19a9c1c@www.fastmail.com> (t.'s message of "Thu, 24 Mar 2022 10:01:32 +0000") X-Provags-ID: V03:K1:kUbeYRi5SVwnYlSk/Btpd1HehDut76Qx7AFBl61u/5M2iaV0k72 V4hNjI+VGovAradfGq3w3MEnYebmPJsD/qs5kpPPFVdH5fFuiv2qEXe0QBlEJQxARt3DgiH SS7TF6AJckB5duldxVFvMHkvrA3Citga2kqeZKErd59hLpD1OB1E4/0mIyrBmLPSefu+6mD njMvfHwWQLiknxcdxQe9g== X-UI-Out-Filterresults: notjunk:1;V03:K0:7YdzD59ix1g=:q6zKXvraG8kDrRypDOvMLf DtH9+OkCIcgmRaZ6FGlQxlthZZIov9AbjIerUfBL0qUjVhnDKJ2dJQ4EAGAnHY10KiyIkL8fC YUjLl1UlccAIlw6fQGyEN2T8kIGOTlNlP1SzH5Cqyr1Pqtpb223SQTj/AWjjmTIZMzSu8mDRO /rJf0dqrt3UzEDXW576Rl2LncrJX02scsxgFyurl9P7No4FXfF2YYrtCepLGti2ckdmIBcXGq O9SVcoqiy9WgHVdPGrMkdo6T+hSQAi5FF0GChoGIXAd4cxcat2dudM1ORTInW5A16R7r4O20H eliVkf0v7VrO4jykWqfYYmSEI8m8/FwEbApZTPACb1X8msXDbHTjfpEeRYO+gvt6N2noxIZ/H 4iKZlntjIJ6noTfKHEFpgeFnufzxTuWOy5dt+quykeM9iVZs+deIrKPbGbRtA83LFUgx+YETl DmaMwidG+xDWVxf8YNwI6qiEKn6NrM1cjjk27PNdHfCul8h22FvbEHbhYpKxpYtgU9qaJnf2f +6yCX1V5AdeDZyYpyXGYsUA+0cZ9oMBFU4WxysEgrDmK+6mOaSwGrg2ocGv25+htP938tzB7u eEYvzHryhKWzGtlKxJicWrRCR8fziwhIXFfC0Y+jCMwAJgqWQZINgPIp+SHl9yLCj3xm6luLN NgAiDKf+81Ey3uttTpJFMLGwOm2LisU2NgdksMFMCWQRPSwKwFODewzXqZeZS2061IDYXQV9i sacJ8ZdkdON/0SOu Received-SPF: none client-ip=212.227.17.10; envelope-from=felix.dietrich@sperrhaken.name; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:136783 Archived-At: t@fullmeta.me writes: > I would like to be able to use said remote machine for all my dev > work. Of course the selling point of Guix is that you can setup > reproducible and minimal execution environments for your code and > hacking - think Virtualenv pushed to its logical conclusion. So, > typically I'd do the following: > > 1. mkdir myproj > 2. drop a manifest.scm or guix.scm script inside that has input packages = and sets up services, possibly entire OS definition in system.scm > 3. spawn this programmed environment `guix shell -D -f guix.scm` or > inside a container `guix shell -c` or if I really need to be close to > production or run services spawn entire OS in a container `guix system > -c system.scm` > 4. start Emacs inside that environment > > Now, do you see the problem with TRAMP? TRAMP is essentially an SSH > session spawned from local Emacs already running. It ends up talking > to your login shell over ssh basically. [=E2=80=A6] There needs to be some > kind of "hop" or additional step after TRAMP establishes an ssh > connection that puts its shell in appropriate environment. Is there a > way to do that? I played around with Guix and Tramp a little over the last days. Can=CA=BCt say that I am not still confused, and can=CA=BCt really explain much of the working of the following snippet, but maybe it can still serve you as a base for your customisations =E2=80=93 at least until someone comes up with= a proper solution. #+begin_src emacs-lisp (connection-local-set-profile-variables 'guix-shell-own-path-profile '((tramp-remote-path . (tramp-own-remote-path)))) =20=20 (connection-local-set-profiles '(:application tramp :protocol "guix-shell") 'guix-shell-own-path-profile) =20=20 (require 'tramp) (add-to-list 'tramp-methods `("guix-shell" (tramp-login-program "guix") (tramp-login-args (("shell") ("-m") ("projects/%u/manifest.scm"))) (tramp-remote-shell "/bin/sh") (tramp-remote-shell-args ("-c")) (tramp-remote-shell-login ("")) )) #+end_src =20=20 With this evaluated, you can change to a Guix shell environment on a remote host using: /ssh:me@remotehost|guix-shell:myproj@remotehost:/path/ As you can see this uses the user part of a tramp file name to select the environment. I first tried to use the host part, but it seems that this part has to be the same on each hop (I received an error about non-matching host parts). If you look at the =E2=80=98tramp-login-args=E2= =80=99 defined above, this uses a predefined directory =E2=80=9Cprojects=E2=80=9D under wh= ich are stored the environments in sub-directories. This is the part you need to adjust if you rather need to use the =E2=80=9C-D=E2=80=9D and =E2=80=9C-= f=E2=80=9D switches to =E2=80=9Cguix shell=E2=80=9D. =E2=80=98tramp-remote-shell-login=E2=80=99 is set to the e= mpty string so that tramp does not call /bin/shell with the =E2=80=9C-l=E2=80=9D switch, which = would remove the environment variables set up by =E2=80=9Cguix shell=E2=80=9D. Without =E2=80=98tramp-remote-shell=E2=80=99 and =E2=80=98tramp-remote-shell-args= =E2=80=99 I received an error (I believe it stated something like: =E2=80=9C(stringp nil)=E2=80=9D.). I = do not know why. Setting of the connection local variable =E2=80=98tramp-remote-path= =E2=80=99 is needed to instructed tramp to not override the PATH environment variable with paths from =E2=80=98tramp-remote-path=E2=80=99 that tramp can determin= e to be existing. As I have indicated, I mostly fiddled with the values until something seemed to work; it might no actually work correctly or be correct. So: no warranty ;). It is also not general at all. --=20 Felix Dietrich