commit 0e7b6533facd0607ee67e02114a1fb478d2b1f33
parent c33a512c3b88ae16d0963f5edfac11692428d1ba
Author: Divan Visagie <me@divanv.com>
Date: Thu, 15 Oct 2026 23:43:16 +0200
Apps are folders on an image base, run in thin jails (proposed)
ADR-0002: an app is ~/Applications/Name.app with an app.toml, on an OCI
base named by digest, so the base it was built on is its contract.
ADR-0003: a small, strict runner gives it that base in namespaces (a
jail on FreeBSD), with the GPU drivers from the running system. The
notes say why folders failed on Linux before, what AppImage is
underneath, and what's still open.
Diffstat:
4 files changed, 173 insertions(+), 14 deletions(-)
diff --git a/README.md b/README.md
@@ -16,7 +16,13 @@ Nothing is built yet; these are notes. See [docs/adr](docs/adr) for decisions an
- **Built like any container.** The image comes from a Containerfile, built and pushed with
the same tools and registries as Docker images, and as reproducible as we pin it. No
from-scratch distro to maintain: Ubuntu provides the packages, we choose and arrange them.
+- **An app is a folder.** `~/Applications/Name.app`, with an `app.toml` saying how to run it:
+ copy it in to install, delete it to uninstall, never touch the system. It runs on the base
+ image it names by digest, in a thin jail, so system updates never break it (ADR-0002,
+ ADR-0003).
- **Opinionated.** One desktop (Patina), one way to add apps, one way to keep data (ZFS).
+- **Something new.** Not a copy of another distro: fix what's missing on Linux, starting with
+ the blurred line between the system's packages and the user's.
## The shape of it
diff --git a/docs/adr/0002-an-app-is-a-folder-on-an-image-base.md b/docs/adr/0002-an-app-is-a-folder-on-an-image-base.md
@@ -0,0 +1,78 @@
+# 0002. An app is a folder, run on a base image named by digest
+
+Date: 2026-10-15
+
+## Status
+
+Proposed
+
+## Context
+
+On Linux the line between the system's packages and the user's is blurred: running a user's
+app often means installing something system-wide first (a library, a runtime, FUSE for an
+AppImage). Patina OS locks the system in an image (ADR-0001), so the user's apps have to live
+in their home folder and must never need the system changed.
+
+What the existing answers are underneath:
+
+- **AppImage**: a SquashFS image with an ELF runtime in front. Run, it mounts itself with FUSE
+ and runs `AppRun` inside an AppDir (a folder: AppRun, a .desktop file, an icon, `usr/`). So
+ it's a folder packed into one file, and it needs libfuse on the system to unpack: a user
+ package that needs a system package.
+- **macOS's .app**: just a folder of a known shape (Info.plist, the binary, resources), found
+ where apps are expected. It works because Apple guarantees the base it runs on (libSystem,
+ AppKit, Metal) and keeps it stable.
+- **Earlier folder apps on Linux** (NeXTSTEP's heirs: GNUstep's .app, ROX's AppDirs) didn't
+ fail for being folders. They failed because Linux has no guaranteed base: which glibc, which
+ Mesa, whether PipeWire is there. Every format since makes up for it with its own world:
+ Flatpak's runtimes, AppImage bundling everything, snap's bases.
+
+Patina OS has a guaranteed base already: the image the machine boots is an OCI image, versioned
+by digest, the same for everyone who runs it.
+
+## Decision
+
+- **An app is a folder** in `~/Applications`, named `Name.app`. Copying it in installs it,
+ deleting it uninstalls it, and the app can update itself by writing to its own folder.
+ Nothing is installed anywhere else and nothing needs root.
+- **`app.toml` says how to run it**: its name, the binary to run (`exec`, relative to the
+ folder), its icon, categories, the file types and URL schemes it opens, the commands it
+ offers on the command line, and its base. Anyone can package any binary by putting it in a
+ folder and writing those few lines.
+- **The base is an OCI image named by digest**: `base = "patina-os:1@sha256:..."`, a Patina OS
+ release. That digest *is* the contract: the app is promised exactly the base it was built on,
+ for as long as it's kept, rather than a hand-written list of libraries promised forever.
+ What isn't in the base, the app carries in its folder (libraries found through `$ORIGIN`).
+- **The launcher reads `app.toml`.** The Patina desktop's launcher already reads .desktop files
+ (patina-desktop ADR-0010); this grows there (patina-desktop ADR-0027), it isn't a new place.
+- To start with, only Patina OS bases may be named. The format allows any image, so other bases
+ can be allowed later.
+
+```
+~/Applications/Teleprinter.app/
+ app.toml # name, exec = "bin/teleprinter", icon, categories,
+ # file types, URL schemes, commands, base
+ bin/teleprinter
+ lib/ # its own libraries, found through $ORIGIN
+ icon.svg
+```
+
+## Consequences
+
+- The system and the user's apps are separate: the system changes only by booting another
+ image, and never knows which apps there are; an app never changes the system.
+- The system can move on (patina-os:2) without breaking apps built on :1: they keep their base
+ (ADR-0003 runs them on it).
+- One format, one registry and one set of build tools for both the system and the bases apps
+ run on.
+- Something has to do what macOS's Launch Services does: know which app opens which files and
+ links, from the `app.toml` files. Without it apps feel bolted on.
+- Commands an app offers need putting on PATH (linked into `~/.local/bin`, or added by the
+ session).
+- A downloaded folder runs as the user. Whether to say anything the first time one runs (macOS
+ marks downloads as quarantined and checks signatures) is still to decide.
+- Flatpak and .desktop files can still work beside it, since the launcher reads them; the
+ folder is the native and simplest way, not the only one.
+- An app's binaries are for one platform. For FreeBSD (ADR-0003), `app.toml` should allow more
+ than one, as a macOS app can carry Intel and Arm binaries together:
+ `bin/linux-x86_64/`, `bin/freebsd-amd64/`.
diff --git a/docs/adr/0003-apps-run-in-thin-jails.md b/docs/adr/0003-apps-run-in-thin-jails.md
@@ -0,0 +1,51 @@
+# 0003. Apps run in thin jails on their base
+
+Date: 2026-10-15
+
+## Status
+
+Proposed
+
+## Context
+
+An app names the base it was built on, by digest (ADR-0002). Something has to run it on that
+base, whatever image the machine itself has booted, without root.
+
+FreeBSD has done this for 25 years with thin jails (as Bastille and iocage build them): a
+release (`14.3-RELEASE`) kept once and shared read-only into every jail with nullfs, each jail
+only its own files on top (often a ZFS clone), and upgrading the host leaves each jail on the
+release it was made with until it's moved. That is the shape wanted here: the base is the
+release, the app folder is the jail.
+
+On Linux the same is built from parts: user and mount namespaces, bind mounts and overlayfs, as
+bubblewrap, toolbox and rootless podman do. Unlike a jail, which is one kernel feature with its
+edge built in, the parts make it easy to leave holes.
+
+## Decision
+
+- **A small, strict runner** starts each app in its own namespaces: the base's `/usr` as its
+ system, its own folder, the user's home, and a fixed list of what else it gets: the Wayland,
+ PipeWire and D-Bus sockets, fonts, the cursor and theme, locale, `/etc/resolv.conf`. Anything
+ not on the list isn't there.
+- **On the base the machine booted**, the app's `/usr` is the system's own: nothing to fetch,
+ no extra disk, next to no cost.
+- **On an older base**, its layers are fetched once into a user-level store
+ (`~/.local/share/patina/layers` or similar) and shared by every app that names it. Stored with
+ composefs (which bootc uses already), so two bases share every file they have in common, not
+ just whole layers.
+- **GPU drivers always come from the running system**, whatever the base: Mesa has to be new
+ enough for the hardware, and NVIDIA's userspace must match the kernel module exactly. Flatpak
+ and nvidia-container-toolkit do the same.
+- **On FreeBSD the runner can be a jail**: the same `app.toml`, a jail there and namespaces on
+ Linux. The base there is a FreeBSD release, so the app needs a FreeBSD binary (ADR-0002), or
+ runs its Linux one through the Linuxulator.
+
+## Consequences
+
+- Apps never break when the system updates; old bases are kept as long as an app names them.
+- Ubuntu (since 24.04) allows unprivileged user namespaces only to programs with an AppArmor
+ profile that permits them; the runner ships with one in the image.
+- The list of what reaches an app is the security boundary, so it's short and changes only on
+ purpose. A sandbox with permissions (as Flatpak's portals) can grow from it later.
+- Setting up the namespaces costs milliseconds, and mounts can be kept per base.
+- Old bases cost disk until no app names them; something has to notice and remove them.
diff --git a/docs/notes.md b/docs/notes.md
@@ -28,20 +28,44 @@ Research for Patina OS, and what's still open. Dated, since this moves quickly.
## Apps in the home folder
-The system is locked, so apps go where the user can write: their home folder, on the ZFS pool,
-snapshotted with the rest of their data. Ways to get them there, all needing nothing from root:
-
-- **Flatpak, per user** (`flatpak --user`, in `~/.local/share/flatpak`): the usual answer for
- desktop apps on image-based systems. Sandboxed; the launcher already reads the .desktop files
- it exports (in `~/.local/share/flatpak/exports/share/applications`, on XDG_DATA_DIRS; check).
-- **AppImages in `~/Applications`**: one file per app. patina-desktop's ADR-0010 already lists
- "an `~/Applications` folder of AppImages joins the launcher's list" as a revisit trigger.
-- **Distrobox / toolbox containers**: a mutable Ubuntu (or anything) in a container, with apt,
- for tools that want a normal distro; their apps can be exported to the launcher.
-- **Per-user language tools**: cargo, rustup, npm in `~/.cargo`, `~/.local`; Homebrew is what
- Universal Blue uses for command-line tools (it needs a home of its own, `/home/linuxbrew`).
-- Open: which of these is *the* way (opinionated: probably Flatpak for desktop apps, a distrobox
- for development), and whether the launcher should know about each.
+The aim isn't to copy what's there but to fix what's missing. On Linux the user's packages and
+the system's are blurred: a user's app often needs something installed system-wide first. Here
+the system is locked, and apps live in the home folder, on the ZFS pool, snapshotted with the
+rest of the user's data, never needing the system changed.
+
+**The native way** (proposed): an app is a folder, `~/Applications/Name.app`, with an
+`app.toml` saying how to run it, run on an OCI base image named by digest (ADR-0002), in a thin
+jail (ADR-0003). In short: thin jails for desktop apps, with OCI images as the base.
+
+- **What's new**: the parts exist (Flatpak's shared runtimes, which can even come from OCI
+ registries; toolbox's containers; FreeBSD's thin jails), but not the booted system itself
+ being the app runtime, versioned by digest, with plain folders as apps. No separate runtime
+ world to keep up, as Flatpak has.
+- **Why folders failed on Linux before** (GNUstep, ROX AppDirs): no guaranteed base. macOS's
+ .app works because Apple guarantees its base; ours is guaranteed by the image digest.
+- **What AppImage is underneath**: an AppDir (a folder) packed into SquashFS with an ELF runtime
+ in front that mounts it with FUSE, so it needs libfuse on the system. The folder without the
+ packing is simpler and needs nothing.
+
+Other ways that still work beside it, all without root:
+
+- **Flatpak, per user** (`flatpak --user`, in `~/.local/share/flatpak`); the launcher reads the
+ .desktop files it exports (in `~/.local/share/flatpak/exports/share/applications`, on
+ XDG_DATA_DIRS; check).
+- **Distrobox / toolbox**: a mutable distro in a container, with apt, for development tools.
+- **Per-user language tools**: cargo, rustup, npm in `~/.cargo`, `~/.local`.
+
+Open, roughly in order:
+
+1. The `app.toml` format: fields, and binaries for more than one platform
+ (`bin/linux-x86_64/`, `bin/freebsd-amd64/`).
+2. Opening files and links: something like Launch Services, reading `app.toml`'s file types and
+ URL schemes. Where it lives: the launcher, or a small service beside it.
+3. Commands on PATH: linked into `~/.local/bin`, or added by the session.
+4. Trust: anything to say the first time a downloaded app runs.
+5. The runner's list of what reaches an app, and fetching and removing old bases.
+6. How an app is built: a tool that takes a base, a binary and an `app.toml` and checks the
+ binary needs nothing the base and folder don't have (`ldd` against the base).
## Reproducible builds