How to setup a remote pair-programming environment with GNU Guix

Guix logo

Have you ever wanted to hack on a free software project with a fellow hacker sitting next to you ? I did. But suddenly, I could not !

So I look for solutions to do remote pair-programming. I wanted to work on Guile projects, within Emacs, using Git, Autotools, etc. Do you know how many solutions are out there providing such environment to collectively hack in ? I've found none.

So I've made one with Guix.

Disclaimer: This was an experimental but very very very enjoyable work. I'm not an experienced Guix/VM/Emacs user. So don't take my words for granted. Read manuals, ask questions.

Introductory Tutorial

Let's say you want to host your first remote pair-programming session to do a Code Kata, in Guile programming language, with your partner in crime.

I cooked you 5 steps to get to a basic setup!

1. IP addresses

You will need to know your public (or external) and private (or local) IP addresses. Here is a way to get them:

# Get the public address

# Get the private address
ip route get | grep -oP 'src \K[^ ]+'

2. System declaration

Here is a declaration (not for production use):

;; file: pair-with-us.scm

(use-modules (gnu))
(use-service-modules networking ssh)
(use-package-modules ssh emacs emacs-xyz certs)

 (host-name "pair-with-us")
 (timezone "Europe/Paris")
 (locale "fr_FR.utf8")
 (bootloader (bootloader-configuration
	      (bootloader grub-bootloader)
	      (targets "/dev/vda")))
 (file-systems (cons (file-system
		      (device "/dev/vda1")
		      (mount-point "/")
		      (type "ext4"))
 (packages (cons* emacs emacs-geiser emacs-geiser-guile emacs-paredit nss-certs %base-packages))
 (services (append (list (service dhcp-client-service-type)
			 (service openssh-service-type
				   (x11-forwarding? #t)
				   (permit-root-login #t)
				   (allow-empty-passwords? #t)
				   (port-number 22))))

3. Build the VM and run it.

One command to spawn your environment :

$(guix system vm pair-with-us.scm) -net nic -net user,hostfwd=tcp:"${LOCAL_IP_ADDRESS}":10022-:22

4. Connect to the VM

As you are not physically close (or you would simply do pair-programming), you need to do a little port redirection with your router. For instance, every connections incoming from the outside world to the port 52222 (arbitrary value) has to be redirected to your computer's IP address on the port 10022 (arbitrary value), for both protocols TCP and UPD.

How you can connect to your VM:

ssh -Y -p 10022 root@${LOCAL_IP_ADDRESS}

How your pairs can connect to your VM:

ssh -Y -p 52222 root@${PUBLIC_IP_ADDRESS}

5. Fire up Emacs

Any pair can run the following command to attach to the same Emacs session :

emacsclient -a '' -c

Few extensions are available to tinker with Guile right now (thanks to the system declaration above).

Alright, you are all good to hack together, enjoy!

Going further

guix system image sub-command

This command is foundational.

With the vm sub-command, it allows you to build a virtual machine (which shares its store with the host) with the system declaration file you provided and returns a script to spawn the VM !

This was suited to work on small projects, with few dependencies. I used it to introduce Guile and Test Driven Development doing Code Katas for like half an hour.

But it can't handle a project like Guix. Not enough space available on the VM. This is where the image sub-command comes into play. It will build the image of a standalone (independent store) system, according to the declaration file you provided.

In this kind of VM, I was able to clone and build the Guix sources. Then Simon and I were ready to hack !

Emacs'Lockstep extension

Trevor Jim had put the right keywords into the README file so I've found it. I will quote him to introduce his work :

Lockstep is a package for pair programming in Emacs. It synchronizes the windows and points of two or more Emacs frames, so that a team of programmers can share an editing session. All programmers see the same buffers and live edits, and any programmer can take over the editing session.

Sounds fun ? It is.

I did a remote pair-programming session with more than one guest. Some were following my moves, some where not. Their choice.

Sounds even more fun ? It is.


Because it feels more natural to me to work with someone I can see and hear, I used Jitsi to handle the communication part of the remote pair-programming sessions.


I wrote a bash script to handle the creation of the VMs, the generation of SSH keys, finding my IP addresses, and so on.

I still have to manually configure my router to set the port-redirection. But it's a one time effort.

Then all I need to do is, run the script and share the private key and IP address to my guests.

Personal feedback

On the VM side, nothing much to say. I guess Guix covers all the needs. My laptop sometimes crashed without explanation.

On the editor side, Emacs and Lockstep went buggy some times. I could not determinate if it comes from my configuration full of extensions and custom key-bindings or from something Lockstep ? Moreover, Lockstep does not share the minibuffer view to all participants.

One the communication side, Jitsi is fine. But there could be something more suited for remote pair-programming sessions. I read about a Jami serviceā€¦

Thank you very much for reading this article!

Don't hesitate to give me your opinion, suggest an idea for improvement, report an error, or ask a question ! I would be so glad to discuss about the topic covered here with you ! You can reach me here.

Don't miss out on the next ones !

And more importantly, share this blog and tell your friends it's the best blog in the history of Free Software! No kidding!

#gnu #guile #emacs #guix #remotepairprogramming #tutorial #english