unkernel.alsopss.com

What this deployment adds to unkernel: Arch Linux, a setup menu, the distro's own desktop, and internet for the guest straight from your browser, all hosted on Cloudflare Pages.

unkernel.alsopss.com runs unkernel's page with a few additions by AL'S-OPS Labs. Everything on this page is in the alsopss branch of the page's source; the rest of these docs (the SDK) apply unchanged.

#Distributions

NameImagePackagesNotes
alpineAlpine 3.24, 4 MBapk addboots fastest
debianDebian 13 (trixie), 74 MBapt installthe most launcher apps, GPU apps
archArch Linux ARM (aarch64), 141 MBpacman -Syrolling; built from ALARM's packages, no systemd

Pick one in the setup menu, in Settings, Distro, or with ?distro=arch. Images over 25 MB are stored in 4 MB parts and served as one file, with HTTP Range requests, by a Pages Function (/distros/<name>-<hash>.erofs).

#Settings in the URL

Besides the SDK page's own (?mem=, ?cpus=, ?data=0, ?distro=, ...):

ParameterEffect
?setup=1show the setup menu again (it shows by itself once per browser)
?desktop=1boot into the distro's own Xfce desktop, filling the page (Settings, Display and sound, Native desktop)
?routes=0no package mirrors through the site
?net=0no network at all

A URL with any parameter skips the setup menu for that load.

#Resources

By default the guest gets 3 GB of memory on a desktop that reports 8 GB (the most a browser reports), 2 GB below that, and less on phones. It gets all of the browser's threads but two (from 6 threads; half below that), up to 6 CPUs, on the SMP kernel. The page itself stays out of the way: the top bar hides until the pointer reaches the top edge, and its live numbers (which run a small reader in the guest) stop while it is hidden.

#Internet

The guest has no relay or proxy. Every name it looks up resolves to an address inside the page, and the page answers the connection:

  • HTTP and HTTPS: the page fetches https://NAME/PATH with the browser's own fetch(), which checks the real site's certificate. For HTTPS the guest talks TLS to a server in the page (kw-tls), with a certificate for NAME from this browser's own certificate authority, which the guest trusts.
  • Sites without CORS (nodejs.org, files.pythonhosted.org, GitHub archives and git clones, rustup, crates.io files, Go downloads): the browser cannot read them, so the page asks the site's function instead: GET /pkg/<host>/<path> on a fixed list of hosts and paths. Nothing else goes through Cloudflare.
  • Distro mirrors (dl-cdn.alpinelinux.org, deb.debian.org, mirror.archlinuxarm.org) also go through /pkg/<host>/...; the package managers check every package's signature.

So these work as on any machine:

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.41.0/install.sh | bash
nvm install --lts
npm install express
git clone https://github.com/nvm-sh/nvm.git
python3 -m venv ~/venv && ~/venv/bin/pip install requests   # Debian: apt install python3-venv first

Limits: only TCP to ports 80 and 443, by name; a site that sends no CORS headers and is not on the list fails with a clear error; git push and other uploads to sites without CORS are not passed on.

#Trust in the guest

At every boot, a few seconds after the prompt, the page puts its CA in the guest: /usr/local/share/kw-ca.crt, the system bundle (between # kw-ca begin and # kw-ca end), NODE_EXTRA_CA_CERTS, SSL_CERT_FILE, REQUESTS_CA_BUNDLE, GIT_SSL_CAINFO (/etc/profile.d/kw-ca.sh), npm's cafile (~/.npmrc) and pip's cert (/etc/pip.conf). npm, pip, curl, wget and git read those files on every run; Python's requests and Node scripts read the variables, so a terminal opened before the CA arrived needs a new terminal (or . /etc/profile.d/kw-ca.sh) for them. With files kept between visits the CA is already there at boot. The CA's private key stays in this browser (localStorage kw.netca) and is replaced every 25 days; the guest never sees it.

#kw-tls

kw-tls is rustls (TLS 1.2 and 1.3) and rcgen, compiled to WebAssembly (/kw-tls/kw_tls.js, /kw-tls/kw_tls_bg.wasm):

import init, { Ca, Session } from "https://unkernel.alsopss.com/kw-tls/kw_tls.js";
await init();
const ca = Ca.generate();             // ECDSA P-256, valid 30 days: ca.cert_pem, ca.key_pem
const s = new Session(ca, "example.com"); // a server with a fresh certificate for example.com
s.feed(bytesFromClient);              // TLS records in
const plain = s.read_plain();         // decrypted bytes
s.write_plain(answer);                // bytes to encrypt
const out = s.take_out();             // TLS records to send back
s.close(); s.free();

#The SDK option

The network option is the SDK's fetchRoutes() with direct:

fetchRoutes(inner, routes, {
  direct: {
    ca: { cert, key },                       // PEM
    tls: { js: KW_TLS_JS_URL, wasm: KW_TLS_WASM_URL },
    fallback: "https://unkernel.alsopss.com/pkg",
    fallbackHosts: ["nodejs.org", "github.com", ".example.org"],
  },
});

and in a net spec: { kind: "net", backend: { kind: "wisp", servers: [], routes, direct } } (no Wisp server: names resolve only through the page).

#The native desktop

With the setting on, once user space runs the page installs Xfce with the distro's package manager (about 65 MB the first time) and starts it with Xwayland in fullscreen at the page's size, so the distro's own desktop is all you see. On Arch and Alpine the image carries wland's relay for this (Debian's always did). Off, Xfce is still in the launcher as a window.

#Page

  • Setup menu: distro, native desktop, memory, CPUs, and whether files are kept between visits, before the first boot; saved like Settings.
  • Top bar: hidden until needed; the Apps button and the Windows menu replace the Dock.
  • About This System (launcher): live details of the machine, and every project the site is built from.
  • Docs (launcher): these docs.

#Site endpoints

PathWhat
/the page
/distros/<name>-<hash>.erofsdistro images, with Range (206/416)
/pkg/<host>/<path>package mirrors and the no-CORS downloads above; GET and HEAD, and POST to github.com/*/git-upload-pack only
/kw-tls/kw_tls.js, /kw-tls/kw_tls_bg.wasmkw-tls