# Configuring Emacs TRAMP to enter Guix container

**URL:** <https://forum.systemcrafters.net/t/configuring-emacs-tramp-to-enter-guix-container/1055>\
**Category:** Emacs\
**Tags:** guix\
**Created:** [October 18, 2024, 12:41pm UTC](https://forum.systemcrafters.net/t/configuring-emacs-tramp-to-enter-guix-container/1055 "2024-10-18T12:41:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![aemogie](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.systemcrafters.net/aemogie/32/709_2.png) [@aemogie](https://forum.systemcrafters.net/u/aemogie)\
**Post date:** [October 18, 2024, 12:41pm UTC](https://forum.systemcrafters.net/t/configuring-emacs-tramp-to-enter-guix-container/1055/1 "2024-10-18T12:41:49Z")

</div>

Hi all, I’m new to Emacs and Guix. I found out recently that Emacs has a package named TRAMP which allows you to work in remote systems. I was wondering how to use it to go into a Guix container built with `guix system container`.

I’m running it on a NixOS host, as I have a bit of config that I want to migrate using a container, before installing Guix on bare-metal. I got the container working, I’m just not sure how to use TRAMP to enter it.

---

<div class="post-metadata">

**Author:** ![aemogie](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.systemcrafters.net/aemogie/32/709_2.png) [@aemogie](https://forum.systemcrafters.net/u/aemogie)\
**Post date:** [October 18, 2024, 1:21pm UTC](https://forum.systemcrafters.net/t/configuring-emacs-tramp-to-enter-guix-container/1055/2 "2024-10-18T13:21:21Z")

</div>

Additional information, `guix system container` prints two recommended commands,  
`sudo guix container exec <PID-HERE> /run/current-system/profile/bin/bash --login` and `sudo nsenter -at <PID-HERE>`.  
Neither worked, but `sudo nsenter -at <PID-HERE> /run/current-system/profile/bin/bash --login` does work.

TRAMP seems to have some concept of “methods”, I’m just not sure how it nor how Linux namespaces work. `sudo lsns` does give a bunch of “namespaces” (whatever that means) that have the same PID as what is shown by `guix container`, I’m just unsure how to make use of it.

---

<div class="post-metadata">

**Author:** ![aemogie](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.systemcrafters.net/aemogie/32/709_2.png) [@aemogie](https://forum.systemcrafters.net/u/aemogie)\
**Post date:** [October 18, 2024, 4:16pm UTC](https://forum.systemcrafters.net/t/configuring-emacs-tramp-to-enter-guix-container/1055/3 "2024-10-18T16:16:47Z")

</div>

Solved it! Took a look at how `lxc-tramp` works.

```elisp
(add-to-list 'tramp-remote-path "/run/current-system/profile/bin/")
(add-to-list 'tramp-methods
	     '("guixcontainer"
	       (tramp-login-program "nsenter")
	       (tramp-login-args (("-a" "-t" "%h")
				  ("/run/current-system/profile/bin/bash" "--login")))
	       (tramp-remote-shell "/run/current-system/profile/bin/bash")
	       (tramp-remote-shell-args ("-c"))))

```

 ![2 Frames, 4 buffers. One shows the runtime output of the script produced by , notably the process ID of 32934. Another is a scratch buffer with the above snippet. The third is a shell buffer of root@komputilo su-ing into alice@komputilo. The final buffer shows that the hostname and the username are as per the configuration.scm file.](https://canada1.discourse-cdn.com/flex029/uploads/systemcrafters/original/1X/34feb32de374968b2de144d3193557b1c4665333.jpeg)

One issue I had for a while was tramp constantly saying `ls` not found, but adding the Guix system profile bin directory to `tramp-remote-path` fixes it.

---

<div class="post-metadata">

**Author:** ![aemogie](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.systemcrafters.net/aemogie/32/709_2.png) [@aemogie](https://forum.systemcrafters.net/u/aemogie)\
**Post date:** [October 18, 2024, 5:39pm UTC](https://forum.systemcrafters.net/t/configuring-emacs-tramp-to-enter-guix-container/1055/4 "2024-10-18T17:39:49Z")

</div>

An additional issue I faced was that Eshell would be broken, but in really weird ways (such as not having anything other than `/bin` in `$PATH` and any attempts to modify it silently failing). Looking into the docs I found that the the service responsible for symlinking `/usr/bin/env` was part of `%base-services`. But the services were explicitly overidden to not include anything other than the guix daemon, in the `docker-image.tmpl` which I used. After fixing that, Eshell worked like a charm.

Edit: No, it doesn’t.
