commit ccc8a1f8e8aeb5710cfbffaef7a28f402079ce32
parent e70597462a7cf35a0e2840e2001c1cf06b60bac0
Author: Divan Visagie <me@divanv.com>
Date: Fri, 20 Nov 2026 19:41:39 +0100
Image: install patina-desktop's own .deb; a root Makefile; nifl's services and nvme.noacpi=1 in the base
The desktop is now the .deb that patina-desktop's packaging builds (build/deb), installed with apt, instead of a hand-picked list of binaries copied in. The builder gets rustup's Rust (the lockfile needs 1.95) and the libraries the whole workspace builds against.
The base gains what nifl runs: Bluetooth, power profiles, bolt, fwupd, CUPS, fprintd, Tailscale (from its repository), OpenVPN, Avahi, ModemManager, sensors, QEMU, fastfetch, intel-microcode and linux-firmware, with a kargs.d entry for nvme.noacpi=1. Not yet booted.
Diffstat:
7 files changed, 180 insertions(+), 104 deletions(-)
diff --git a/Makefile b/Makefile
@@ -0,0 +1,58 @@
+# Patina OS: build the Linux (Ubuntu bootc) image and run it in a VM.
+# These wrap the scripts in linux/vm/ (see linux/vm/README.md).
+# Needs Docker, QEMU with KVM and OVMF.
+
+VM := linux/vm/vm.sh
+DISK := linux/out/disk.raw
+
+.DEFAULT_GOAL := help
+.PHONY: help build disk run console stop ssh view screenshot log upgrade rollback clean distclean
+
+help: ## List the targets
+ @grep -E '^[a-zA-Z_-]+:.*## ' $(MAKEFILE_LIST) | \
+ awk 'BEGIN{FS=":.*## "} {printf " %-12s %s\n", $$1, $$2}'
+
+build: ## Build the desktop and the image, and push it to the local registry
+ linux/vm/build.sh
+
+disk: ## Install the image onto linux/out/disk.raw (replaces the disk)
+ linux/vm/disk.sh
+
+$(DISK):
+ linux/vm/disk.sh
+
+run: $(DISK) ## Boot the built image in a VM (installs it first if there is no disk)
+ $(VM) start
+ $(VM) wait
+ @echo "Up. GDM shows on 'make view' (VNC localhost:5901); log in as patina / patina."
+ @echo "make ssh for a root shell, make stop to power off."
+
+console: $(DISK) ## Boot the image on this terminal instead (Ctrl-a x quits)
+ $(VM) console
+
+stop: ## Power the VM off
+ $(VM) stop
+
+ssh: ## A root shell in the running VM (or: make ssh CMD='uname -a')
+ $(VM) ssh $(CMD)
+
+view: ## Show the VM's screen over VNC (localhost:5901)
+ $(VM) view
+
+screenshot: ## Save the VM's screen to linux/out/screen.png
+ $(VM) screenshot
+
+log: ## Follow the VM's serial console
+ $(VM) log
+
+upgrade: ## In the running VM: fetch the latest build from the registry and stage it
+ $(VM) ssh bootc upgrade
+
+rollback: ## In the running VM: boot the previous build at the next reboot
+ $(VM) ssh bootc rollback
+
+clean: ## Stop the VM and delete linux/out/
+ linux/vm/clean.sh
+
+distclean: ## Also delete the local registry and the image
+ linux/vm/clean.sh --all
diff --git a/linux/.dockerignore b/linux/.dockerignore
@@ -3,5 +3,5 @@
# podman, disk images) never goes to the daemon.
*
!system/
-!build/desktop/
+!build/deb/
!vm/registries.conf
diff --git a/linux/Containerfile b/linux/Containerfile
@@ -5,7 +5,7 @@
# dev the system plus what the test VM needs: a user to log in as, and
# trust in the development registry (vm/README.md)
#
-# The desktop is built first by desktop/build.sh into build/desktop/.
+# The desktop is built first by desktop/build.sh, as the .deb in build/deb/.
# apt's database as a fresh Ubuntu has it: the base image empties /var, so
# derived images restore it to use apt (as the base's AGENTS.md describes).
@@ -29,6 +29,16 @@ RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | \
cd /src && . "$HOME/.cargo/env" && \
make bin install-all DESTDIR=/output
+# Tailscale's apt signing key, for its repository (Tailscale isn't in Ubuntu's
+# archive). Fetched over https from Tailscale, as its install instructions do;
+# the system stage keeps only the key file.
+FROM docker.io/library/ubuntu@sha256:f144425ff09be612d6d9ad965196e9cdc23dae1f42110a8a11a3e9a8198759f7 AS tailscale-key
+
+RUN apt-get update && \
+ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends ca-certificates curl && \
+ curl -fsSL https://pkgs.tailscale.com/stable/ubuntu/resolute.noarmor.gpg \
+ -o /tailscale-archive-keyring.gpg
+
# ubuntu-bootc's minimal 26.04 base, pinned by digest (docs/notes.md).
FROM ghcr.io/ubuntu-bootc/ubuntu-26.04-bootc@sha256:d50ac19557f0b5bc56a980178aa68e3675735ad06b3750b4c9af967901e966f4 AS system
@@ -55,11 +65,30 @@ COPY --from=bootc /output /
# none, nor a host ID (zfsutils makes one as it installs, which every machine
# would then share) or a pool cache: the installer makes those
# (vm/zfs-home.sh stands in for it).
+#
+# And the Patina desktop itself: the .deb patina-desktop's own packaging builds
+# (desktop/build.sh), installed here with apt so its dependencies come with it
+# (no recommends: firefox, one of them, is a snap on Ubuntu). It is what `make
+# install` puts in place: every binary and app, the default apps list, the
+# session entry ("Patina" at the login screen), portal and PAM config. It has
+# to go in before /var is emptied below, while dpkg's database exists.
+#
+# And what nifl, the ThinkPad X1 Carbon this is meant to run on, needs from the
+# base (checked by comparing its installed packages and services): Bluetooth,
+# power profiles, Thunderbolt authorisation (bolt), firmware updates (fwupd),
+# printing, the fingerprint service, Tailscale (from its own repository) and
+# OpenVPN, Avahi, ModemManager, sensors, QEMU, and fastfetch. The CPU
+# microcode and linux-firmware go in with the kernel, before the initramfs is
+# built, so the microcode is in it. nifl's drivers are all in Ubuntu's kernel.
+COPY --from=tailscale-key /tailscale-archive-keyring.gpg /usr/share/keyrings/tailscale-archive-keyring.gpg
+COPY build/deb/patina-desktop.deb /tmp/patina-desktop.deb
RUN mkdir -p /var/cache/apt/archives/partial /var/lib/apt/lists/partial /var/log/apt \
/var/tmp /var/roothome && \
+ echo 'deb [signed-by=/usr/share/keyrings/tailscale-archive-keyring.gpg] https://pkgs.tailscale.com/stable/ubuntu resolute main' \
+ > /etc/apt/sources.list.d/tailscale.list && \
apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
- dracut linux-image-generic && \
+ dracut linux-image-generic intel-microcode linux-firmware && \
kver=$(ls /usr/lib/modules | sort -V | tail -1) && \
for k in /usr/lib/modules/*; do [ "${k##*/}" = "$kver" ] || rm -rf "$k"; done && \
cp "/boot/vmlinuz-$kver" "/usr/lib/modules/$kver/vmlinuz" && \
@@ -75,20 +104,26 @@ RUN mkdir -p /var/cache/apt/archives/partial /var/lib/apt/lists/partial /var/log
fonts-dejavu-core fonts-ubuntu hicolor-icon-theme adwaita-icon-theme \
xdg-user-dirs foot \
xdg-desktop-portal xdg-desktop-portal-gtk shared-mime-info xdg-utils \
- zfsutils-linux zfs-zed && \
- rm -f /etc/hostid /etc/zfs/zpool.cache && \
+ zfsutils-linux zfs-zed \
+ bluez bluez-cups power-profiles-daemon bolt fwupd thermald iio-sensor-proxy \
+ cups cups-browsed cups-filters printer-driver-hpcups \
+ fprintd libpam-fprintd \
+ tailscale openvpn network-manager-openvpn avahi-daemon modemmanager \
+ qemu-system-x86 fastfetch \
+ /tmp/patina-desktop.deb && \
+ rm -f /tmp/patina-desktop.deb /etc/hostid /etc/zfs/zpool.cache && \
apt-get clean && \
rm -rf /var && mkdir /var
# Files the system adds to the base, as laid out under system/.
COPY system/ /
-# The Patina desktop and Files, and "Patina" as GDM's session.
-COPY build/desktop/ /
-
RUN systemctl enable gdm.service NetworkManager.service \
zfs-import-cache.service zfs-mount.service zfs-zed.service \
- zfs-import.target zfs.target && \
+ zfs-import.target zfs.target \
+ bluetooth.service power-profiles-daemon.service thermald.service \
+ cups.socket cups.service cups-browsed.service avahi-daemon.service \
+ ModemManager.service tailscaled.service fwupd-refresh.timer && \
systemctl set-default graphical.target
RUN bootc container lint
@@ -109,6 +144,6 @@ RUN useradd -M -d /var/home/patina -s /bin/bash -G sudo patina && \
# Which build this is, so an upgrade can be seen to have happened.
ARG BUILD_ID=unknown
-RUN echo "$BUILD_ID" > /usr/lib/patina-os/build
+RUN mkdir -p /usr/lib/patina-os && echo "$BUILD_ID" > /usr/lib/patina-os/build
RUN bootc container lint
diff --git a/linux/desktop/build.sh b/linux/desktop/build.sh
@@ -1,101 +1,46 @@
#!/usr/bin/env bash
-# Builds the Patina desktop for the image, from the last commits of
-# patina-desktop, which holds the launcher and Files (not its working tree, so stray changes
-# don't ship), and lays out what the image adds in build/desktop/, as it goes
-# under /:
+# Builds the Patina desktop .deb for the image: patina-desktop's own
+# packaging/deb/build.py (ADR-0099), run in an Ubuntu 26.04 container. It is
+# `make deb` there, so the image gets what `make install-full` puts in place:
+# every binary, the apps packaging/bundle.toml pins, the default apps list, the
+# session entry, portal and PAM config. The .deb lands in build/deb/ as
+# patina-desktop.deb, which the Containerfile installs with apt, so its
+# dependencies come with it.
#
-# usr/bin/patina-* the desktop's binaries and the launcher
-# usr/share/wayland-sessions/patina.desktop "Patina" at the login screen
-# etc/pam.d/patina-lock the lock screen's PAM service
-# usr/bin/files, usr/share/applications/... Files, the file manager
-# usr/share/dbus-1/services/...portal.desktop.patina.service,
-# usr/share/xdg-desktop-portal/... Files as the session's file chooser
-# etc/xdg/patina-mimeapps.list folders open in Files, in Patina
-# usr/lib/patina-os/desktop which commit they were built from
+# PATINA_DESKTOP is the checkout (default: beside patina-os). It builds the
+# checkout's last commit, not its working tree, so stray changes don't ship.
+# PATINA_DESKTOP_WORKTREE=1 builds the working tree instead, uncommitted
+# changes and all, to try them in the VM; the package version then says
+# "dirty".
#
-# PATINA_DESKTOP is the checkout
-# (default: beside patina-os). PATINA_DESKTOP_WORKTREE=1 builds its working tree instead,
-# uncommitted changes and all, to try them in the VM; the image then says
-# "+dirty".
+# Needs the network: the apps from other repositories are fetched from GitHub
+# at the commits bundle.toml pins, and cargo downloads crates. Cargo's
+# downloads and the build's work folder are kept in Docker volumes, so
+# rebuilds are incremental. Build output (target/deb) goes into the checkout,
+# as `make deb` there puts it.
set -euo pipefail
ROOT=$(cd "$(dirname "$0")/.." && pwd)
-SRC=${PATINA_DESKTOP:-$ROOT/../../patina-desktop}
+SRC=$(cd "${PATINA_DESKTOP:-$ROOT/../../patina-desktop}" && pwd)
BUILD="$ROOT/build"
-STAGE="$BUILD/desktop"
BUILDER=patina-os-desktop-builder
say() { printf '==> %s\n' "$*"; }
-worktree=${PATINA_DESKTOP_WORKTREE:-}
-
-# Copies checkout $1 into $2, vendors its crates (so the container builds
-# offline, git dependencies included), and prints the commit it came from.
-stage() {
- local src=$1 dest=$2 commit dirty
- [[ -d "$src/.git" ]] || { echo "error: no checkout at $src" >&2; exit 1; }
- commit=$(git -C "$src" rev-parse HEAD)
- dirty=$(git -C "$src" status --porcelain)
- rm -rf "$dest" && mkdir -p "$dest"
- if [[ -n "$worktree" ]]; then
- # What git would commit: tracked files and new ones it doesn't ignore.
- git -C "$src" ls-files -z --cached --others --exclude-standard |
- tar -c -C "$src" --null -T - | tar -x -C "$dest"
- [[ -z "$dirty" ]] || commit="$commit+dirty"
- else
- [[ -z "$dirty" ]] || say "$(basename "$src") has uncommitted changes; building its last commit" >&2
- git -C "$src" archive HEAD | tar -x -C "$dest"
- fi
- mkdir -p "$dest/.cargo"
- (cd "$dest" && cargo vendor --locked vendor > .cargo/config.toml.vendor 2> .cargo/vendor.log) ||
- { cat "$dest/.cargo/vendor.log" >&2; exit 1; }
- mv "$dest/.cargo/config.toml.vendor" "$dest/.cargo/config.toml"
- echo "$commit"
-}
+[[ -d "$SRC/.git" ]] || { echo "error: no checkout at $SRC" >&2; exit 1; }
say "the build environment"
docker build -q -f "$ROOT/desktop/builder.Containerfile" -t "$BUILDER" "$ROOT/desktop" >/dev/null
-mkdir -p "$BUILD/target"
-commit=$(stage "$SRC" "$BUILD/src")
-# Cargo's downloads are kept in a volume, and its target folder in build/, so
-# rebuilds are incremental. As the user, so build/ stays theirs.
-for project in src; do
- say "building $project"
- docker run --rm --user "$(id -u):$(id -g)" \
- -e CARGO_HOME=/cargo -e HOME=/tmp \
- -v patina-os-cargo:/cargo \
- -v "$BUILD/$project:/src:ro" -v "$BUILD/target:/target" \
- -w /src "$BUILDER" \
- cargo build --release --locked --target-dir /target
-done
-
-say "laying out build/desktop"
-rm -rf "$STAGE"
-binaries=(patina-hud patina-compositor patina-lock patina-menu
- patina-volume patina-wallpaper patina-wifi patina-launcher)
-install -d "$STAGE/usr/bin"
-for b in "${binaries[@]}"; do
- install -m 755 "$BUILD/target/release/$b" "$STAGE/usr/bin/"
-done
-install -d "$STAGE/usr/share/wayland-sessions" "$STAGE/etc/pam.d" "$STAGE/usr/lib/patina-os"
-sed 's|@BINDIR@|/usr/bin|' "$BUILD/src/packaging/linux/patina.desktop" \
- > "$STAGE/usr/share/wayland-sessions/patina.desktop"
-install -m 644 "$BUILD/src/packaging/linux/patina-lock.pam" "$STAGE/etc/pam.d/patina-lock"
-echo "$commit" > "$STAGE/usr/lib/patina-os/desktop"
-
-# Files, a crate of patina-desktop: the file manager, the session's file chooser through the portal,
-# and what opens folders in the Patina session (Files' ADR-0004).
-F="$BUILD/src/files"
-install -m 755 "$BUILD/target/release/files" "$STAGE/usr/bin/"
-install -D -m 644 "$F/packaging/linux/files.svg" \
- "$STAGE/usr/share/icons/hicolor/scalable/apps/com.sectorflabs.Files.svg"
-install -D -m 644 "$F/packaging/linux/com.sectorflabs.Files.desktop" \
- "$STAGE/usr/share/applications/com.sectorflabs.Files.desktop"
-service=org.freedesktop.impl.portal.desktop.patina.service
-install -d "$STAGE/usr/share/dbus-1/services"
-sed 's|@BINDIR@|/usr/bin|' "$F/packaging/portal/$service" > "$STAGE/usr/share/dbus-1/services/$service"
-install -D -m 644 "$F/packaging/portal/patina.portal" "$STAGE/usr/share/xdg-desktop-portal/portals/patina.portal"
-install -D -m 644 "$F/packaging/portal/patina-portals.conf" "$STAGE/usr/share/xdg-desktop-portal/patina-portals.conf"
-install -d "$STAGE/etc/xdg"
-printf '[Default Applications]\ninode/directory=com.sectorflabs.Files.desktop\n' > "$STAGE/etc/xdg/patina-mimeapps.list"
+say "building the .deb from $(basename "$SRC") $(git -C "$SRC" rev-parse --short HEAD)"
+rm -f "$SRC"/target/deb/*.deb
+docker run --rm --user "$(id -u):$(id -g)" \
+ -e CARGO_HOME=/cargo -e HOME=/tmp -e XDG_CACHE_HOME=/cache \
+ -v patina-os-cargo:/cargo -v patina-os-cache:/cache \
+ -v "$SRC:/src" -w /src "$BUILDER" \
+ python3 packaging/deb/build.py ${PATINA_DESKTOP_WORKTREE:+--worktree}
+
+deb=$(ls -t "$SRC"/target/deb/patina-desktop_*.deb | head -1)
+rm -rf "$BUILD/deb" && mkdir -p "$BUILD/deb"
+cp "$deb" "$BUILD/deb/patina-desktop.deb"
+say "build/deb/patina-desktop.deb ($(basename "$deb"))"
diff --git a/linux/desktop/builder.Containerfile b/linux/desktop/builder.Containerfile
@@ -1,11 +1,38 @@
# The Patina desktop's build environment: Ubuntu 26.04, as the image is, with
-# its own Rust and the libraries patina-desktop builds against (its `make
-# deps`). desktop/build.sh runs cargo in it.
+# rustup's Rust and what patina-desktop's `make deps` lists, plus what its
+# packaging/deb/build.py needs to make the .deb (python3, dpkg-dev, binutils,
+# make, git). desktop/build.sh runs build.py in it, and the image installs the
+# .deb, so the image gets exactly what `make install` puts in place: every
+# binary and app, the default apps list, session entry, portal and PAM config.
+#
+# Rust comes from rustup, not the archive: patina-desktop's lockfile needs newer
+# Rust than the archive has (26.04's 1.93.1 can't build sysinfo 0.39, which
+# needs 1.95). Pinned, so builds repeat; raise RUST_VERSION when the lockfile
+# asks for more.
FROM docker.io/library/ubuntu@sha256:f144425ff09be612d6d9ad965196e9cdc23dae1f42110a8a11a3e9a8198759f7
+ARG RUST_VERSION=1.95.0
+
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
- ca-certificates git cargo rustc pkg-config \
+ ca-certificates curl git make gcc libc6-dev pkg-config python3 dpkg-dev binutils \
+ cmake clang glslc \
libxkbcommon-dev libpixman-1-dev libudev-dev libinput-dev libseat-dev \
- libgbm-dev libegl-dev libdrm-dev libwayland-dev libpam0g-dev && \
+ libgbm-dev libegl-dev libdrm-dev libwayland-dev libpam0g-dev \
+ libasound2-dev libvulkan-dev libwebkitgtk-6.0-dev \
+ libssl-dev libfontconfig-dev libsqlite3-dev libsoup-3.0-dev libclang-dev && \
rm -rf /var/lib/apt/lists/*
+
+# System-wide, so the build can run as an ordinary user (build.sh gives it its
+# own CARGO_HOME and cache folders as volumes; the toolchain stays here).
+ENV RUSTUP_HOME=/usr/local/rustup \
+ PATH=/usr/local/cargo/bin:$PATH
+RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | \
+ CARGO_HOME=/usr/local/cargo sh -s -- -y --profile minimal \
+ --default-toolchain "$RUST_VERSION" --no-modify-path && \
+ chmod -R a+rX /usr/local/rustup /usr/local/cargo
+
+# Mount points for the volumes build.sh attaches (cargo's downloads, the .deb
+# build's work folder). A new volume takes its owner and mode from here, and
+# the build is not root.
+RUN mkdir -m 1777 /cargo /cache
diff --git a/linux/system/usr/lib/bootc/kargs.d/10-nvme-noacpi.toml b/linux/system/usr/lib/bootc/kargs.d/10-nvme-noacpi.toml
@@ -0,0 +1,7 @@
+# nifl (ThinkPad X1 Carbon Gen 9) never reaches deep sleep with the lid closed
+# unless the NVMe driver ignores the firmware's StorageD3Enable flag, and drains
+# about 0.8% of its battery an hour: nvme.noacpi=1 fixes it (Resources/Suspend
+# on nifl.md). It only changes how the NVMe driver suspends the drive; despite
+# the name it doesn't turn ACPI off. It applies to every machine this image goes
+# on, which it should be harmless for; remove it if a machine's drive misbehaves.
+kargs = ["nvme.noacpi=1"]
diff --git a/linux/vm/README.md b/linux/vm/README.md
@@ -1,5 +1,7 @@
# The test VM
+This is the bootc version, which ADR-0006 rules out; Patina OS is now Ubuntu updated with apt on a ZFS root (ADR-0007). It stays as the record of what bootc took, until a VM for ADR-0007 replaces it.
+
Builds the Patina desktop and the image, installs it onto a disk file the way it would go onto a real disk, and boots it
in QEMU, then lets the VM upgrade from a local registry and roll back. Needs Docker, QEMU with KVM,
and OVMF (`apt install qemu-system-x86 ovmf`); no root, no podman on the host. Paths here are
@@ -35,10 +37,12 @@ vm/vm.sh ssh bootc rollback # the previous one, at the next boot
## How it works
-- **The desktop** is built by `desktop/build.sh` from patina-desktop's last commit (beside this
- checkout, or `PATINA_DESKTOP`), in an Ubuntu 26.04 container with the archive's Rust, so it
- links what the image has. It lands in `build/desktop/` as it goes under `/`, with the session
- file and the PAM service; the commit is in `/usr/lib/patina-os/desktop`.
+- **The desktop** is patina-desktop's own `.deb`, built by `desktop/build.sh` (it runs that
+ repository's `packaging/deb/build.py`, as `make deb` does there) from its last commit (beside this
+ checkout, or `PATINA_DESKTOP`), in an Ubuntu 26.04 container with rustup's Rust (pinned in
+ `desktop/builder.Containerfile`). It lands in `build/deb/patina-desktop.deb`, and the
+ Containerfile installs it with apt, so the image gets what `make install` puts in place and
+ the package's dependencies come with it. Its version names the commit.
- **The image** has two stages: `system`, the real one, and `dev`, which adds the test user and
trust in the registry. vm/build.sh builds `dev`.
- **The registry** (`vm/registry.sh`, started by the others) is Docker's `registry:2` on