plan9front

ehm... what?

What is 9front? Well, it's a fork of plan 9 of course... Ok, but what if that also doesn't tell you anything? Well, let me explain.

Plan 9 from Bell Labs was a reasearch operating system developed by the same folks that developed the original UNIX. It was supposed to be some form of continuation with more focus on networking and GUI, both of which were not a thing when UNIX was developed.

The Plan 9 team also did a great job at disregarding any previous standards, which allows for some fun design decisions, but also makes porting stuff quite painful.

I've red Plan 9 being described as UNIX, but if everything they promised you was true. I'm not sure how accurate that is, but it sure sounds like a great marketing. Plan 9 goes really hard on the 'everything is a file' approach. In fact, Plan 9 goes even further and makes stuff entire filesystems.

Filesystems are then further distributed over a network via the 9p protocol. OK, that's kind of a lie; the 9p protocol is also used a lot inside one computers filesystem.

Developemnt on the OS has stopped and the crew has moved onto other projects, such as the Go programming language, but after a bunch of legal hassle, as one would expect from AT&T, it was released under an opensource licence. A bunch of forks has been created, but 9front is the most prominent.

While it probably isn't a great choice for a daily driver, it sounds like a lot of fun to explore from the point of view of someone interested in computer history and OS design.

This is not a comprehensive manual for 9front. If you want to read more on 9front, you can start here. This is just a log of my journey mixed with few opinions here and there.

Where to start?

To explore 9front, one first needs 9front. Makes sense, right? You can run 9front on real hardware, such as an old laptop or Raspberry Pi. I decided against that and went the VM route instead. Installing 9front is a well documented endevour. Some nice resources are: The official manual, pspodcasting or nicolasmontanaro.

At first, I tried to install 9front in VirtualBox, as I already had it installed. It about worked, but I was trying, and failing, to set up two network cards. One to do NAT and the other to be connected to the host. While searching for results, I stumbeled upon the official manual saying that VirtualBox is not recommended and that I should use Qemu instead.

And so I did.

I will not tell you how to do Qemu, mostly because I don't know how to do Qemu. I can however tell you that it's all set up via flags at strartup, which I don't know how to feel about. There I learned that the NAT is supposed to tunnel selected ports to localhost, but I had already Qemu up and running, so I stayed there.

Drawterm

Plan 9 servers are built to be accessed remotely. Either from another, possibly diskless, Plan 9 machine or from a client, such as drawterm. Note that for whatever reason, 9front demands it's own version of drawterm (the one I linked).

To configure the server for drawterm support, I just followed pspodcasting's manual.

Using drawterm is nice, as it proveds a bridge between your computer and the target cpu server (a role in a Plan 9 network). I did however stumbeled on some flaws as well. First of all, it sometimes lags. I don't have fix for that yet, but it can be a bit annoying. Second, the middle and right mouse buttons were swapped for some reason. I don't know why, but I fixed it with the following command:

echo buttonmap 123 > /dev/mousectl - fixes drawterm mouse binds

You just need to do it once.

Also, I should probably talk about the-

Basics

The window manager of 9front is rio(1). Rio is very minimal and, just like the rest of Plan 9, very mouse focused. Don't let this decieve you. Plan 9 is still very text focused and you do most things via commands, you just controll the text with a mouse rather than keybindings.

Upon login, you should already have a terminal opened. You can open another by clicking the right mouse button (or the middle, if your drawterm is broken) and selecting new. Then you will drag the shape of your new window. Once you have your terminal, you can start using it for stuff. One good thing to begin with is reading the introduction. You can do so by typing:

man 0intro

You will notice that your terminal doesn't scroll by itself. This can be enabled by selecting the 'scroll' option in the middle mouse button menu. To scroll, one would use the scroll bar. You can drag it with the middle mouse button, or scroll up and down a set amount by clicking it with the left or right button. the lower you click it, the more it scrolls.

You might notice that Plan 9 uses a lot of middle clicks. This is because it was developed for the kid of oldschool three-button mice that are almost extinct now. To combat this, I decided to rebind one of my extra side mouse buttons to middle click. I have found this to be very useful even outside of Plan 9. If you have smart mouse, it probably has some fancy reprogramming software, but if you are stuck with a dumb mouse like me, you have to do with xinput(1).

#!/bin/sh
MICE=$(xinput list | grep -i mouse | grep pointer |
       awk -F'id=' '{print $2}' | awk '{print $1}')

for MOUSE in $MICE; do
    xinput set-button-map "$MOUSE" 1 2 3 4 5 6 7 8 2
done

This script rebinds the ninth button (front side button for me) to the middle click for all devices that have 'mouse' in the name. Note however, that it only works for currently plugged devices and it has no memory once device is disconnected.

Back to the terminals. You can edit any part of it and execute selected text by selecting the 'send' option. You can start a GUI application from the terminal, which will turn the terminal window into said application. And yes, you can nest rio. ^C doesn't work, to terminate a process, you would use the delete key. There is a file name completion and it's invoked with ^F.

If you want to know more, RTFM.

Acme

Acme(1) is one of the two main 9front text editors. The other one is sam(1), which has been described by cat-v as a graphical version of the venerable ed on steroids, lots of steroids. I have yet to look into sam, however, so I will only talk about acme now.

I should probably post a picture first.

Acme looks very nice. It has multiple panes inside multiple columns. There was also a Linux window manager based on it, but that was a long time ago. It lacks a lot of features you would expect tho. Line numbers, syntax highlighting, autocompletion (except for files.), support for spaces in file names... It also has basically no keyboard shortcuts and the up/down keys scroll instead of moving between lines.

It, however, also has a lot of things. It has commands, it has integration with the outer system via a filesystem, so you can extend it. It has mouse chording (keybindings for the mouse) and all the blue bars are editable so you can put stuff there. It also has a lot of sam integrated into it, but again, I'm yet yo learn sam.

One might say that that is a lot of things missing, but they are all missing by design. Acme was made by some of the best programmers of their (and probably our as well) time, so I wouldn't write it off without trying it first. And that's what I'm doing! I'm in fact doing it right now!

Well, I'm not editing this from within 9front, (as I already stated, it has some nasty lag from time to time) but I have downloaded acme from the plan9port. Yes, there is also acme2k, which is a version of acme with some extra features and anvil, which is an acme-inspired editor with even more reworks (such as using REST API instead of filesystem). While anvil sounds good on paper, the UI is less polished that acme (at least for my taste) and I want to first try out acme as intended, before I hack the hell out of it.

But with a bit of polish (hacking. Polish hacking), anvil could be very nice modern editor.

I like trying out things, even if I don't think I will keep using them. A lot of time, there is at least one good idea that I incorporate into my workflow and if not even that, I cal at least say that yes, I tried it and I still think that it sucks.

I'm approaching the entire 9front with this attitude, so I will try doing most things from acme for some time. I will also try writing the acme way. That is no manual line wrapping, tab indent, some regexp. I'm not planing to introduce tabs into my existing code, so I'll still use nvim for that, but I will use it for small scripts and this b-log.

So yes, this b-log is written in completly different style then the rest, which will totaly not bite me leter.

Abrupt end

There are still more things to talk about, like plumber(4) or rc(1) or compose and stuff, but I don't have all the knowladge yet and this is already way longer than I would like, so I'm ending it here. Expect more 9front content coming soon.