An Virtual elementaryOS Development Enviroment October 9, 2018


Summary

I’ve been working on my first (non-monetary) contribution to elementaryOS and created a clean and practical development environment along the road with a VM and X11-forwarding.

Introductory Words

Recently I achieved something rather small, that gave me a lot of joy. I wrote my first patch for an open source piece of software. It was for the default terminal application that comes with elementaryOS. Cassidy James Blaede opened an issue on github and added the Bytesize tag to it. This tag brought me to the issue, since I was looking for an easy entry to the elementaryOS development ecosystem. In elementaryOS, this is the tag for exactly that.

The Initial Setup

In order to be productive, I decided to work in a virtual machine. This would ensure that I didn’t clutter my system and it gave me the opportunity to roll back to certain points in the past if I did something stupid during development 1. Going back in time with virtual machine snapshots is really easy.

Creating an elementaryOS VM in elementaryOS works like this:

Connecting Conveniently

I assume that you’re familiar with a terminal and have set up an SSH key. Now, in the VM enable the OpenSSH server:

sudo apt install openssh-server
sudo systemctl enable ssh
sudo systemctl start ssh
ip -c a s

The last line will show the IP address that you need to connect to. On your host configure the connection:

ssh-copy-id $vm_ip

Forwarding

Now to the nifty part. This is not witchwork, but I’m sure a lot of people don’t know this or aren’t aware how useful this is. Add an entry like this to your SSH config (~/.ssh/config)

Host $vm_ip
	ForwardAgent yes
	ForwardX11 yes

BTW, you might want to add the IP address to your hosts file:

echo "$vm_ip $vm_name" | sudo tee -a /etc/hosts
sed -i 's/$vm_ip/$vm_name/' ~/.ssh/config

The changes to your SSH config enabled forwarding your SSH agent and your X11 server. You need your SSH agent in the VM to work with the same credential for GitHub that you usually use, but without having to manually setting them up in the VM again.

Forwarding X11 is the really cool part: When starting an graphical editor on the command line of the VM, for example Sublime Text, it will display on your regular screen. You don’t have to have a VNC connection to the server. The other cool thing: When you’re compiling a graphical tool, like the elementaryOS terminal, it also will start on your regular screen. And as a bonus, you can have two different versions of the terminal running, at the same time. Your usual version which houses the SSH connection, and a development version, which you’re currently working on.

The Actual Environment

This step depends on the project you’re working on. Terminal’s README shows how to do it. Of course all the steps necessary are done in the VM.

Little Advice At The End (Snapshots)

Make use of snapshots (conveniently done through virt-manager’s GUI). If you feel you achieved some kind of a milestone in your VMs setup, like “all’s setup, going to clone the repo now”, you should take a snapshot.

Conclusion

Building this setup felt really useful, and I think it’s a good way to keep your desktop environment clean and have an easy way to build a reproducible development environment.


  1. You know, sometimes you install or remove some packages and when you try to revert that action somehow your system never behaves the same again… or is it just me? [return]
  2. It might be due to my work experience with virt-manager, but I couldn’t get a working VM for whatever reason. I quickly switched to virt-manager, so I’m not sure if I was just impatient or if something was seriously broken. I’m sure it wasn’t the latter. [return]