diff --git a/.github/workflows/build-image.yml b/.github/workflows/build-image.yml index 78771e2..2201ca4 100644 --- a/.github/workflows/build-image.yml +++ b/.github/workflows/build-image.yml @@ -8,8 +8,8 @@ on: description: 'Distribution' default: 'ubuntu2604' type: choice - options: [all, ubuntu2604, arch, cachyos, fedora, proxmox, debian, debian13, bazzite, bazzite-deck, steamos] - workflow_call: + options: [all, ubuntu2604, arch, cachyos, omarchy, fedora, proxmox, debian, debian13, bazzite, bazzite-deck, steamos] + ow_call: inputs: distro: type: string @@ -34,7 +34,7 @@ jobs: run: | INPUT="${{ inputs.distro || 'ubuntu2604' }}" if [ "$INPUT" = "all" ]; then - echo 'distros=["ubuntu2604","arch","cachyos","fedora","proxmox","debian","debian13","bazzite","bazzite-deck","steamos"]' >> "$GITHUB_OUTPUT" + echo 'distros=["ubuntu2604","arch","cachyos","omarchy","fedora","proxmox","debian","debian13","bazzite","bazzite-deck","steamos"]' >> "$GITHUB_OUTPUT" else echo "distros=[\"$INPUT\"]" >> "$GITHUB_OUTPUT" fi @@ -190,6 +190,7 @@ jobs: { key: 'ubuntu2604', label: 'Ubuntu 26.04', file: 'ps5-ubuntu2604.img.xz' }, { key: 'arch', label: 'Arch', file: 'ps5-arch.img.xz' }, { key: 'cachyos', label: 'CachyOS', file: 'ps5-cachyos.img.xz' }, + { key: 'omarchy', label: 'Omarchy', file: 'ps5-omarchy.img.xz' }, { key: 'fedora', label: 'Fedora 44', file: 'ps5-fedora.img.xz' }, { key: 'proxmox', label: 'Proxmox VE 8', file: 'ps5-proxmox.img.xz' }, { key: 'debian', label: 'Debian 12', file: 'ps5-debian.img.xz' }, diff --git a/README.md b/README.md index 955749f..86ee896 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # PS5 Linux Image Builder -Builds bootable Linux USB images for PlayStation 5 using Docker containers. Supports Ubuntu 26.04, Arch, CachyOS (Gamescope + Steam), Fedora (GNOME), individually or as a multi-distro image with kexec switching. +Builds bootable Linux USB images for PlayStation 5 using Docker containers. Supports Ubuntu 26.04, Arch, CachyOS (Gamescope + Steam), Omarchy (Arch + Hyprland), Fedora (GNOME), individually or as a multi-distro image with kexec switching. ## Prerequisites @@ -27,6 +27,9 @@ OR OR +# Build Omarchy (Arch-based, Hyprland desktop) +./build_image.sh --distro omarchy + OR # Build Fedora (GNOME desktop) @@ -50,7 +53,7 @@ sudo dd if=output/ps5-ubuntu2604.img of=/dev/sdX bs=4M status=progress | Flag | Description | Default | |------|-------------|---------| -| `--distro` | `ubuntu2604`, `arch`, `cachyos`, `fedora`, or `all` | `ubuntu2604` | +| `--distro` | `ubuntu2604`, `arch`, `cachyos`, `omarchy`, `fedora`, or `all` | `ubuntu2604` | | `--kernel` | Path to kernel source directory | auto-clone version selected by PS5 patch set | | `--img-size` | Disk image size in MB | `12000` (`32000` for `all`) | | `--clean` | Remove all cached build artifacts and start fresh | off | @@ -98,6 +101,7 @@ All verbose output goes to `build.log`. The terminal shows a spinner with live p | Ubuntu 26.04 (Resolute) | GNOME | `.deb` | systemd | | Arch | Sway | `.pkg.tar.zst` | systemd | | CachyOS | Gamescope + Steam Big Picture (Arch + `[cachyos]` repo, no v3 migration in image build) | `.pkg.tar.zst` | systemd | +| Omarchy | Hyprland (Arch + the Omarchy packages from `pkgs.omarchy.org`, see `distros/omarchy/README.md`) | `.pkg.tar.zst` | systemd | ## Multi-distro Image @@ -153,6 +157,7 @@ distros/ ubuntu2604/ # Ubuntu 26.04 (Resolute) arch/ # Arch Linux cachyos/ # CachyOS repos + Gamescope/Steam + omarchy/ # Omarchy (Arch + Hyprland) packages + setup shared/ # Kernel postinst hooks (single + multi) boot/ cmdline.txt # Kernel cmdline template (__DISTRO__ placeholder) diff --git a/build_image.sh b/build_image.sh index 8bc2d3d..0e47c55 100755 --- a/build_image.sh +++ b/build_image.sh @@ -18,7 +18,7 @@ usage() { echo "Usage: $0 [--distro ] [--kernel ] [--img-size ] [--boot-part-size ] [--clean]" echo "" echo "Options:" - echo " --distro Distribution to build: ubuntu2604, arch, cachyos, fedora, proxmox, debian, bazzite, bazzite-deck, batocera, all (default: ubuntu2604)" + echo " --distro Distribution to build: ubuntu2604, arch, cachyos, omarchy, fedora, proxmox, debian, debian13, bazzite, bazzite-deck, steamos" echo " --kernel Path to kernel source directory (default: auto-clone to work/linux/)" echo " --img-size Disk image size in MB (default: 12000, 32000 for --distro all)" echo " --boot-part-size Boot partition size in MB (default: 500)" @@ -88,7 +88,7 @@ esac if [ -z "$FORMAT" ]; then case "$DISTRO" in - arch|cachyos|steamos) FORMAT="arch" ;; + arch|cachyos|omarchy|steamos) FORMAT="arch" ;; fedora|bazzite*) FORMAT="rpm" ;; all) FORMAT="all" ;; *) FORMAT="deb" ;; diff --git a/distros/omarchy/README.md b/distros/omarchy/README.md new file mode 100644 index 0000000..a32cd83 --- /dev/null +++ b/distros/omarchy/README.md @@ -0,0 +1,61 @@ +# omarchy + +[Omarchy](https://omarchy.org) — DHH's opinionated Arch + Hyprland desktop — on +PS5 hardware with our `linux-ps5` kernel. + +## How it is built + +Omarchy's installer is an ISO wizard (`archinstall` plus the target-side +`omarchy apply system` step), but the desktop itself ships as ordinary Arch +packages in Omarchy's own repo (`omarchy`, `omarchy-settings`, +`omarchy-keyring`, themes, nvim config, titlebars). Omarchy's own docs describe +prebuilt images as a supported shape: the builder installs the packages and +their setup, and hardware leaves run on the machine's first boot +(`docs/file-layout.md`, `agents/skills/install-scripts.md`). + +So this distro is not a hand-assembled copy of the package lists: + +1. `distros/omarchy/build-rootfs.sh` fetches `omarchy.db` plus the six + runtime/support packages from `https://pkgs.omarchy.org/stable/x86_64` into + the build cache (`stage-pkgs.sh`), then runs distrobuilder on + `distros/omarchy/image.yaml`. +2. `image.yaml` installs a small Arch base — GPU, session plumbing, network, + plus `gum`/`perl`/`sddm` for `omarchy-settings` — drops in `linux-ps5`, and + rebuilds the initramfs without `autodetect`. +3. Its post-files action installs the staged Omarchy packages + (`pacman -U --nodeps`, the chroot has no DNS), uses Omarchy's pacman + configuration (its repo first, then Arch off Omarchy's stable mirror, as + `omarchy apply pacman` would), and runs + `distros/omarchy/post-install.sh`: Omarchy's `config/` and `login/` setup + leaves (locale, firewall, services, docker, passwordless keyring) and + `omarchy-finalize-user` for `ps5`. +4. Login is tty1 autologin as `ps5` → `exec Hyprland`, no SDDM, matching the + Arch / CachyOS / SteamOS images. + +Omarchy's `hardware/` leaves are **not** run at build time: they are the +per-machine steps (vulkan vendor, bluetooth, wifi regdom, platform fixes), and +several of them build DKMS modules against the image kernel, which is +`linux-ps5`, not `linux-omarchy`. + +## Build locally + +```bash +./build_image.sh --distro omarchy +``` + +The `.img.xz` lands in `output/ps5-omarchy.img.xz`. `OMARCHY_CHANNEL` +(`stable`, `rc`, `edge`) selects the repo channel; it defaults to `stable`. + +## Caveats + +- The image ships the Omarchy *packages*. Anything the ISO wizard does outside + them — partition layout, LUKS, `limine`/`snapper` boot and snapshot setup — + is replaced by this repo's kexec boot flow and ext4 layout, as for every + other PS5 image. +- Some Omarchy packages pull things that only make sense in Omarchy's own + installer (e.g. `omarchy-settings` on `plymouth`); the Omarchy packages are + installed with `--nodeps` so this does not fail the build, and the image + boots with this repo's own `linux-ps5` + kexec flow rather than upstream's. + If the transaction fails on the real image, it is the first place to look. +- Default credentials are `ps5` / `ps5` with passwordless sudo, same as the + other images. Change them before exposing the machine to a network. diff --git a/distros/omarchy/build-rootfs.sh b/distros/omarchy/build-rootfs.sh new file mode 100755 index 0000000..45c57ba --- /dev/null +++ b/distros/omarchy/build-rootfs.sh @@ -0,0 +1,61 @@ +#!/bin/bash +# distros/omarchy/build-rootfs.sh — Arch rootfs + the real Omarchy packages. +# Called from docker/image-builder/entrypoint.sh for DISTRO=omarchy. +# +# Omarchy's installer is an ISO wizard, but the Omarchy packages are normal Arch +# packages in Omarchy's own repo, and Omarchy's docs cover image builds: a +# prebuilt image carries the packages and defers hardware setup to first boot +# (docs/file-layout.md). The distrobuilder recipe (image.yaml) installs the Arch +# side, pulls the Omarchy packages from here and then runs +# distros/omarchy/post-install.sh — the same system setup Omarchy's installer +# runs in the target chroot. +# +# Expects in env: DISTRO=omarchy, CHROOT, KVER, ROOT_LABEL, EFI_LABEL +# Expects on disk: /kernel-debs/linux-ps5-*.pkg.tar.zst, +# /repo/distros/omarchy/{grow-rootfs,grow-rootfs.service}, +# /repo/distros/shared/zz-update-boot +set -eux +: "${CHROOT:?ERROR: \$CHROOT unset/empty}" +[ -d "$CHROOT" ] || { echo "ERROR: \$CHROOT=$CHROOT not a directory"; exit 2; } +case "$CHROOT" in /) echo "ERROR: refuse to operate on /"; exit 2 ;; esac + +STAGING=/tmp/build-staging +OMARCHY_CHANNEL="${OMARCHY_CHANNEL:-stable}" +OMARCHY_REPO_URL="${OMARCHY_REPO_URL:-https://pkgs.omarchy.org/$OMARCHY_CHANNEL/x86_64}" +OMARCHY_MIRROR_URL="${OMARCHY_MIRROR_URL:-https://$OMARCHY_CHANNEL-mirror.omarchy.org}" + +# --- Stage files distrobuilder's copy generators need ------------------------ +rm -rf "$STAGING" +mkdir -p "$STAGING/pkgs" +cp /repo/distros/omarchy/grow-rootfs "$STAGING/" +cp /repo/distros/omarchy/grow-rootfs.service "$STAGING/" +cp /repo/distros/shared/zz-update-boot "$STAGING/" +cp /kernel-debs/*.pkg.tar.zst "$STAGING/pkgs/" +cat > "$STAGING/fstab" < +LABEL=$ROOT_LABEL / ext4 defaults 0 1 +LABEL=$EFI_LABEL /boot/efi vfat defaults 0 1 +EOF +find "$STAGING" -type f ! -path "$STAGING/pkgs/*" -exec sed -i 's/\r$//' {} + + +if [ "${SKIP_CHROOT:-false}" = "true" ] && [ -d "$CHROOT/usr/share/omarchy" ]; then + echo "=== Reusing cached $DISTRO rootfs ===" + exit 0 +fi + +# --- Omarchy packages, fetched once and reused across rebuilds --------------- +echo "=== Fetching Omarchy $OMARCHY_CHANNEL packages ===" +OMARCHY_CHANNEL="$OMARCHY_CHANNEL" \ +OMARCHY_REPO_URL="$OMARCHY_REPO_URL" \ +OMARCHY_MIRROR_URL="$OMARCHY_MIRROR_URL" \ + bash /repo/distros/omarchy/stage-pkgs.sh /build/cache/omarchy >&2 + +rm -rf "$CHROOT"/* "$CHROOT"/.[!.]* 2>/dev/null || true +mkdir -p "$CHROOT" +cp -a /build/cache/omarchy/omarchy-pkgs "$CHROOT/omarchy-pkgs" +cp -a /build/cache/omarchy/omarchy-db "$CHROOT/omarchy-db" +distrobuilder build-dir /repo/distros/omarchy/image.yaml "$CHROOT" \ + --with-post-files --cache-dir /build/cache --cleanup=false >&2 +rm -rf "$CHROOT/omarchy-pkgs" "$CHROOT/omarchy-db" diff --git a/distros/omarchy/cmdline.txt b/distros/omarchy/cmdline.txt new file mode 100644 index 0000000..6660afc --- /dev/null +++ b/distros/omarchy/cmdline.txt @@ -0,0 +1 @@ +root=LABEL=__DISTRO__ rw rootwait console=ttyTitania0 console=tty0 mitigations=off idle=halt preempt=full diff --git a/distros/omarchy/grow-rootfs b/distros/omarchy/grow-rootfs new file mode 100755 index 0000000..ceac5cf --- /dev/null +++ b/distros/omarchy/grow-rootfs @@ -0,0 +1,91 @@ +#!/bin/bash +# Grows the root partition + filesystem to fill the disk on first boot. +# Self-disables after success. +# +# Uses sfdisk + partx + resize2fs (all in util-linux + e2fsprogs, both +# present in the minimal Arch/SteamOS base). Earlier versions called +# growpart from cloud-utils — but that package isn't in the SteamOS +# recovery image, so the unit failed with "growpart: command not found" +# and rootfs stayed at the dd'd image size (~14 GB) on any disk larger +# than that. +set -e + +ROOT_DEV=$(findmnt -no SOURCE /) +DISK="/dev/$(lsblk -ndo PKNAME "$ROOT_DEV")" + +# PS5 M.2 drive appear as /dev/nvme*. Do not modify partition table, +# because it contains m2_init PS5 offset. Only USB drive (/dev/sd*) +# are safe for automatic grow root partition. +if [[ "$(basename "$DISK")" == nvme* ]]; then + echo "grow-rootfs: M.2 detected, skipping" + systemctl disable grow-rootfs.service + exit 0 +fi + +PART_NUM=$(cat /sys/class/block/$(basename "$ROOT_DEV")/partition) + +# Our images dd at their built size (~14 GB) onto a much larger USB. The GPT +# backup header is therefore at byte ~built-size, not at end of disk. Move +# the backup header to end-of-disk first so partition table growth works. +sgdisk -e "$DISK" + +# If a previous flash left behind partitions BEYOND our rootfs + boot pair +# (e.g. a stale `linux-home` partset at part 3 from a prior SteamOS install +# on the same drive), the partition extend refuses to grow into the space +# already claimed by the leftover partition. Delete every partition with a +# number higher than 2 — we only ever create partitions 1 (rootfs) + 2 (boot). +# Important: sgdisk only rewrites the on-disk GPT; we must ALSO drop those +# stale entries from the kernel's in-memory partition table via partx -d, +# or BLKPG_RESIZE_PARTITION below returns EBUSY because the kernel still +# thinks sda1 would have to grow into space owned by phantom sda3. +for n in $(parted -ms "$DISK" print 2>/dev/null \ + | awk -F: 'NR>2 && $1+0>2 {print $1}'); do + sgdisk -d "$n" "$DISK" 2>/dev/null || true + partx -d --nr "$n" "$DISK" 2>/dev/null || true +done + +# sfdisk `,+` extends partition $PART_NUM to consume all available free +# space. Works on a mounted/live partition because sfdisk only rewrites +# the GPT entry (kernel re-read of the partition table comes next). +echo ",+" | sfdisk --no-reread -N "$PART_NUM" "$DISK" + +# Make the kernel pick up the new partition size without unmounting via +# BLKPG_RESIZE_PARTITION. partx -u also uses BLKPG, but on some images +# (notably SteamOS recovery loop-mounted btrfs) partx returns an error +# updating the mounted partition; the direct ioctl is more reliable. +python3 - "$DISK" "$PART_NUM" <<'PY' +import sys, os, fcntl, ctypes, subprocess +disk, pno = sys.argv[1], int(sys.argv[2]) +out = subprocess.run(["sfdisk","--bytes","-q","-l",disk], + capture_output=True, text=True, check=True).stdout +start = sectors = None +for line in out.splitlines(): + if line.startswith(f"{disk}{pno} ") or line.startswith(f"{disk}p{pno} "): + f = line.split() + start, sectors = int(f[1]), int(f[3]) + break +if start is None: + sys.exit(f"could not parse partition {pno} from sfdisk -l {disk}") +class P(ctypes.Structure): + _fields_=[("start",ctypes.c_longlong),("length",ctypes.c_longlong), + ("pno",ctypes.c_int),("devname",ctypes.c_char*64), + ("volname",ctypes.c_char*64)] +class A(ctypes.Structure): + _fields_=[("op",ctypes.c_int),("flags",ctypes.c_int), + ("datalen",ctypes.c_int),("data",ctypes.c_void_p)] +p = P(start=start*512, length=sectors*512, pno=pno) +a = A(op=3, flags=0, datalen=ctypes.sizeof(p), data=ctypes.addressof(p)) +fd = os.open(disk, os.O_RDONLY) +try: + fcntl.ioctl(fd, 0x1269, a) # BLKPG, BLKPG_RESIZE_PARTITION +finally: + os.close(fd) +PY + +# Belt-and-suspenders: also try partx in case BLKPG via python failed. +partx -u --nr "$PART_NUM" "$DISK" 2>/dev/null || true + +# Online ext4 grow. +resize2fs "$ROOT_DEV" + +systemctl disable grow-rootfs.service diff --git a/distros/omarchy/grow-rootfs.service b/distros/omarchy/grow-rootfs.service new file mode 100644 index 0000000..722eca7 --- /dev/null +++ b/distros/omarchy/grow-rootfs.service @@ -0,0 +1,13 @@ +[Unit] +Description=Grow root filesystem to fill disk +DefaultDependencies=no +Before=local-fs.target +After=local-fs-pre.target + +[Service] +Type=oneshot +ExecStart=/usr/local/sbin/grow-rootfs +RemainAfterExit=yes + +[Install] +WantedBy=local-fs.target diff --git a/distros/omarchy/image.yaml b/distros/omarchy/image.yaml new file mode 100644 index 0000000..08ceb8d --- /dev/null +++ b/distros/omarchy/image.yaml @@ -0,0 +1,211 @@ +image: + name: ps5-omarchy + distribution: archlinux + release: rolling + description: Omarchy (Arch + Hyprland) desktop for PS5 + architecture: x86_64 +source: + downloader: archlinux-http + url: https://geo.mirror.pkgbuild.com/iso + skip_verification: true +packages: + manager: pacman + update: true + cleanup: true + repositories: + - name: mirrorlist + url: |- + Server = https://geo.mirror.pkgbuild.com/$repo/os/$arch + Server = https://mirrors.kernel.org/archlinux/$repo/os/$arch + sets: + - packages: + # The Omarchy package itself lives in Omarchy's repo (installed from the + # staged copies in post-files; the container has no DNS inside the chroot) + # and pulls Hyprland, Quickshell, uwsm, sddm and the rest of its depends. + # This set is the Arch half: what the PS5 image needs, plus the repo + # packages omarchy-settings depends on. + - base + - base-devel + # Omarchy dependencies not already pulled in by omarchy itself + - gum + - perl + - sddm + # Display / GPU (AMD Oberon) + - mesa + - vulkan-radeon + - libva-mesa-driver + - xf86-video-amdgpu + - libinput + - xkeyboard-config + # Session / plumbing + - dbus + - egl-wayland + - gst-plugin-pipewire + - gtk4-layer-shell + - pipewire + - pipewire-alsa + - pipewire-jack + - pipewire-pulse + - polkit + - qt6-base + - qt6-declarative + - qt6-imageformats + - qt6-multimedia + - qt6-svg + - qt6-wayland + - seatd + - wireplumber + - wl-clipboard + - wtype + - xdg-desktop-portal-gtk + - xdg-desktop-portal-hyprland + - zram-generator + # Network / bluetooth / audio + - bluez + - bluez-utils + - iw + - linux-firmware + - networkmanager + - wireless-regdb + - wpasupplicant + # System + - dosfstools + - e2fsprogs + - kexec-tools + - kmod + - mkinitcpio + - openssh + - parted + # Utilities the default desktop expects + - chromium + - ffmpeg + - git + - jq + - less + - nano + - neovim + - noto-fonts + - noto-fonts-emoji + - ripgrep + - sudo + - tmux + - vi + action: install +files: +- path: /etc/hostname + generator: hostname +- path: /etc/hosts + generator: hosts +- path: /etc/kernel/postinst.d/zz-update-boot + generator: copy + source: /tmp/build-staging/zz-update-boot + mode: "0755" +- path: /etc/fstab + generator: copy + source: /tmp/build-staging/fstab +- path: /usr/local/sbin/grow-rootfs + generator: copy + source: /tmp/build-staging/grow-rootfs + mode: "0755" +- path: /etc/systemd/system/grow-rootfs.service + generator: copy + source: /tmp/build-staging/grow-rootfs.service +- path: /usr/local/sbin/omarchy-post-install + generator: copy + source: /tmp/build-staging/post-install.sh + mode: "0755" +- path: /opt/pkgs/ + generator: copy + source: /tmp/build-staging/pkgs +- path: /omarchy-pkgs/ + generator: copy + source: /omarchy-pkgs +- path: /omarchy-db/ + generator: copy + source: /omarchy-db +actions: +- trigger: post-unpack + action: |- + #!/bin/bash + set -eux + # Pacman 7 Landlock sandbox is unsupported under QEMU; disable it. + sed -i '/^\[options\]/a DisableSandbox' /etc/pacman.conf + pacman-key --init + pacman-key --populate archlinux + pacman -Syy --noconfirm +- trigger: post-packages + action: |- + #!/bin/bash + set -eux + # fc-cache / systemctl can SIGSEGV under QEMU when the image platform is + # linux/amd64 on an arm64 host. + fc-cache -f 2>/dev/null || true + symlink_wants() { + local src=$1 + local target=$2 + [ -e "$src" ] || return 0 + mkdir -p "/etc/systemd/system/${target}.wants" + ln -sf "$src" "/etc/systemd/system/${target}.wants/$(basename "$src")" + } + sed -i 's/^#*PermitRootLogin.*/PermitRootLogin no/' /etc/ssh/sshd_config + sed -i 's/^#*PasswordAuthentication.*/PasswordAuthentication yes/' /etc/ssh/sshd_config + symlink_wants /usr/lib/systemd/system/sshd.service multi-user.target + symlink_wants /usr/lib/systemd/system/NetworkManager.service multi-user.target + symlink_wants /usr/lib/systemd/system/seatd.service multi-user.target + for s in pipewire pipewire-pulse wireplumber; do + symlink_wants "/usr/lib/systemd/system/${s}.service" default.target || true + done +- trigger: post-files + action: |- + #!/bin/bash + set -eux + # Default user (ps5/ps5) before Omarchy's setup runs — its installer + # expects the target user to exist. + useradd -m -G wheel,seat,video,audio,input -s /bin/bash ps5 + echo "ps5:ps5" | chpasswd + echo "%wheel ALL=(ALL:ALL) NOPASSWD: ALL" > /etc/sudoers.d/wheel + # No display manager: tty1 autologin starts the session, same as the + # Arch/CachyOS/SteamOS images. Mask SDDM in case a pulled-in package + # depends on it. + ln -sf /usr/lib/systemd/system/multi-user.target /etc/systemd/system/default.target + ln -sf /dev/null /etc/systemd/system/sddm.service + ln -sf /dev/null /etc/systemd/systemd-firstboot.service + mkdir -p /etc/systemd/system/getty@tty1.service.d + printf '%s\n' '[Service]' \ + 'ExecStart=' \ + 'ExecStart=-/sbin/agetty --autologin ps5 --noclear %I $TERM' \ + > /etc/systemd/system/getty@tty1.service.d/autologin.conf + # Launch the Hyprland session directly; Omarchy's configs/packages come + # from /etc/skel + omarchy-finalize-user, so no uwsm/greetd wrapper is + # needed (and greetd has no VT handoff path on the PS5). + { + echo 'if [ "$(tty)" = "/dev/tty1" ] && [ -z "$WAYLAND_DISPLAY" ]; then' + echo ' export XDG_RUNTIME_DIR="/tmp/xdg-runtime-$(id -u)"' + echo ' mkdir -p "$XDG_RUNTIME_DIR"' + echo ' chmod 700 "$XDG_RUNTIME_DIR"' + echo ' exec Hyprland' + echo 'fi' + } >> /home/ps5/.bash_profile + chown ps5:ps5 /home/ps5/.bash_profile + # Ensure vconsole.conf exists (needed by mkinitcpio sd-vconsole hook) + [ -f /etc/vconsole.conf ] || echo "KEYMAP=us" > /etc/vconsole.conf + # Drop autodetect — it detects the build host's hardware, not the target. + # This produces a larger but hardware-independent initramfs. + sed -i 's/ autodetect//' /etc/mkinitcpio.conf + # Install custom kernel packages + if ls /opt/pkgs/*.pkg.tar.zst 1>/dev/null 2>&1; then + pacman -U --noconfirm --ask 4 /opt/pkgs/*.pkg.tar.zst + rm -rf /opt/pkgs + KVER=$(ls -1t /lib/modules | head -1) + mkinitcpio -k "$KVER" -g "/boot/initrd.img-$KVER" || true + fi + mkdir -p /boot/efi + /etc/kernel/postinst.d/zz-update-boot + # Omarchy packages + system setup (see distros/omarchy/post-install.sh). + # Runs last: Omarchy's own leaves set services and PAM state that the + # steps above would otherwise overwrite. + export DISTRO OMARCHY_PATH=/usr/share/omarchy + . /usr/local/sbin/omarchy-post-install + rm -f /usr/local/sbin/omarchy-post-install +mappings: + architecture_map: archlinux diff --git a/distros/omarchy/post-install.sh b/distros/omarchy/post-install.sh new file mode 100755 index 0000000..4461282 --- /dev/null +++ b/distros/omarchy/post-install.sh @@ -0,0 +1,96 @@ +#!/bin/bash +# distros/omarchy/post-install.sh — Omarchy's target-side system setup. +# +# Omarchy's own installer runs `omarchy apply system --install-user USER +# --first-install` in the installed system (see omarchy-install.sh in +# omacom/omarchy: "The ISO calls this in the target chroot after packages are +# installed and the target user exists"). That script normally lives in the +# image-builder container and is chrooted in by entrypoint.sh for an Arch +# image; distrobuilder has no such hook, so this file runs inside the built +# rootfs from image.yaml's post-files action. +# +# Declares no shebang on purpose: it is sourced, like Omarchy's own install/ +# leaves. +# +# Expects in env: DISTRO=omarchy, CHROOT (the rootfs being built), +# plus the staging dir variables exported by image.yaml. +# Expects on disk: /omarchy-pkgs (staged packages), /omarchy-db (repo indexes) +set -eux + +# --- pacman: Omarchy's stable repos + keyring -------------------------------- +# Same templates Omarchy's `omarchy apply pacman` installs on x86 (stable +# channel): its own repo first, then Arch's core/extra/multilib off Omarchy's +# stable mirror. +cat > /etc/pacman.d/mirrorlist <<'EOF' +Server = https://stable-mirror.omarchy.org/$repo/os/$arch +EOF +cp /etc/pacman.conf /etc/pacman.conf.ps5-arch +sed -i '/^\[core\]$/,$d' /etc/pacman.conf +cat >> /etc/pacman.conf <<'EOF' +[omarchy] +Server = https://pkgs.omarchy.org/stable/$arch +[core] +Include = /etc/pacman.d/mirrorlist +[extra] +Include = /etc/pacman.d/mirrorlist +[multilib] +Include = /etc/pacman.d/mirrorlist +EOF + +# --- Omarchy packages -------------------------------------------------------- +# Installed from the staged copies: the build container has no DNS inside the +# distrobuilder chroot, so pacman cannot reach the repos here. --nodeps is +# safe for this set; their dependencies are installed (or deliberately +# omitted, see image.yaml) by the package set in the same image.yaml. +pacman-key --init +pacman-key --populate archlinux +pacman-key --populate omarchy +pacman -U --noconfirm --needed --nodeps /omarchy-pkgs/*.pkg.tar.zst || { + # One bad package must not sink the whole image: retry without the + # optional app packages, keeping the runtime (omarchy + settings). + pacman -U --noconfirm --needed --nodeps \ + /omarchy-pkgs/omarchy-*.pkg.tar.zst \ + /omarchy-pkgs/omarchy-keyring-*.pkg.tar.zst +} + +# --- Omarchy system setup ---------------------------------------------------- +# Equivalent of `omarchy apply system --install-user --first-install`, +# minus the steps that assume a live machine: +# - pacman/ (rewrites pacman.conf from channel templates: done above), +# - hardware/ (first-boot provisioning builds depend on the upstream +# kernel headers), +# - boot/ (limine + snapper; PS5 images boot through kexec). +export OMARCHY_PATH=/usr/share/omarchy +export OMARCHY_INSTALL="$OMARCHY_PATH/install" +export OMARCHY_INSTALL_USER=ps5 +export OMARCHY_FIRST_INSTALL=1 +export PATH="$OMARCHY_PATH/bin:$PATH" +# The ISO's fixups for machines installed through the wizard: locale files, +# passwordless keyring, service enablement, docker, firewall, browser policy. +for leaf in config/all.sh login/all.sh; do + OMARCHY_INSTALL_LOG_FILE=/var/log/omarchy-$(basename "$(dirname "$leaf")").log \ + bash -c 'source "$OMARCHY_INSTALL/helpers/logging.sh"; start_install_log; source "$OMARCHY_INSTALL/'"$leaf"'"; stop_install_log' +done + +# --- Re-apply the PS5 image's own boot + login setup ------------------------- +# Omarchy's config leaves (enable-services, firewall, sddm) reset parts of the +# login path we replaced with tty1 autologin. +ln -sf /usr/lib/systemd/system/multi-user.target /etc/systemd/system/default.target +ln -sf /dev/null /etc/systemd/system/sddm.service +mkdir -p /etc/systemd/system/getty@tty1.service.d +cat > /etc/systemd/system/getty@tty1.service.d/autologin.conf <<'EOF' +[Service] +ExecStart= +ExecStart=-/sbin/agetty --autologin ps5 --noclear %I $TERM +EOF +mkdir -p /etc/systemd/system/local-fs.target.wants +ln -sf /etc/systemd/system/grow-rootfs.service \ + /etc/systemd/system/local-fs.target.wants/grow-rootfs.service + +if [ -f /usr/share/omarchy/bin/omarchy-finalize-user ]; then + sudo -u ps5 env HOME=/home/ps5 PATH="$OMARCHY_PATH/bin:$PATH" \ + omarchy-finalize-user || true +elif [ -x /usr/local/bin/omarchy-finalize-user ]; then + sudo -u ps5 env HOME=/home/ps5 PATH="$OMARCHY_PATH/bin:$PATH" \ + /usr/local/bin/omarchy-finalize-user || true +fi diff --git a/distros/omarchy/stage-pkgs.sh b/distros/omarchy/stage-pkgs.sh new file mode 100755 index 0000000..a549ef5 --- /dev/null +++ b/distros/omarchy/stage-pkgs.sh @@ -0,0 +1,56 @@ +#!/bin/bash +# distros/omarchy/stage-pkgs.sh — fetch the Omarchy packages and their repo +# databases into a staging directory so image.yaml can install them offline +# with `pacman -U --nodeps` (the container has no working DNS inside the +# distrobuilder chroot, and Omarchy's dependency set targets its own mirror). +# +# Usage: stage-pkgs.sh +# Expects in env: OMARCHY_CHANNEL (stable|rc|edge, default stable), +# OMARCHY_REPO_URL, OMARCHY_MIRROR_URL +set -euo pipefail +DEST="${1:?usage: stage-pkgs.sh }" +CHANNEL="${OMARCHY_CHANNEL:-stable}" +REPO_URL="${OMARCHY_REPO_URL:-https://pkgs.omarchy.org/$CHANNEL/x86_64}" +MIRROR_URL="${OMARCHY_MIRROR_URL:-https://$CHANNEL-mirror.omarchy.org}" +# Packages Omarchy's installer puts on every machine: the runtime itself plus +# the meta packages it depends on by name. Everything else comes from the +# Arch package set in image.yaml. +PACKAGES=( + omarchy + omarchy-settings + omarchy-keyring + omarchy-themes-intros + omarchy-nvim + omarchy-hyprland-titlebars +) +mkdir -p "$DEST/omarchy-pkgs" "$DEST/omarchy-db" +echo "=== Fetching Omarchy $CHANNEL package index ($REPO_URL) ===" +curl -fsSL -o "$DEST/omarchy-db/omarchy.db" "$REPO_URL/omarchy.db" +echo "=== Fetching $CHANNEL sync databases for offline dependency checks ===" +for repo in core extra multilib; do + curl -fsSL -o "$DEST/omarchy-db/$repo.db" "$MIRROR_URL/$repo/os/x86_64/$repo.db" || true +done +# Resolve the newest build of each package from the index (the directory +# listing is not browsable, the db is authoritative). +resolve() { + local pkg="$1" + tar -tf "$DEST/omarchy-db/omarchy.db" \ + | sed -nE "s#^${pkg}-([^/]+)/desc\$#\\1#p" \ + | sort -V | tail -1 +} +for pkg in "${PACKAGES[@]}"; do + ver="$(resolve "$pkg")" + if [ -z "$ver" ]; then + echo "ERROR: $pkg not found in $REPO_URL/omarchy.db" >&2 + exit 1 + fi + if [[ "$ver" == *-any ]]; then + arch=any + else + arch=x86_64 + fi + file="$pkg-$ver-$arch.pkg.tar.zst" + echo ">> $file" + curl -fsSL -o "$DEST/omarchy-pkgs/$file" "$REPO_URL/$file" +done +echo "=== Staged $(ls -1 "$DEST/omarchy-pkgs" | wc -l | tr -d ' ') packages in $DEST/omarchy-pkgs ===" diff --git a/docker/image-builder/entrypoint.sh b/docker/image-builder/entrypoint.sh index 45a5cff..c2dbddd 100755 --- a/docker/image-builder/entrypoint.sh +++ b/docker/image-builder/entrypoint.sh @@ -28,10 +28,11 @@ export KVER if [ "$SKIP_CHROOT" = "true" ] && [ -d "$CHROOT/bin" ]; then echo "=== Reusing cached $DISTRO rootfs ===" elif [ -x "/repo/distros/${DISTRO}/build-rootfs.sh" ]; then - # Distros with their own build-rootfs.sh (bazzite, bazzite-deck, batocera, ...) - # are responsible for populating $CHROOT themselves — distrobuilder is - # bypassed entirely. Most often used for OCI atomic images (bazzite via - # skopeo+umoci) or pre-built rootfs images (batocera squashfs). + # Distros with their own build-rootfs.sh (bazzite, bazzite-deck, batocera, + # omarchy, ...) drive the rootfs build themselves instead of the shared + # distrobuilder call below. Most often used for OCI atomic images (bazzite + # via skopeo+umoci), pre-built rootfs images (batocera squashfs) or a + # distrobuilder run with extra package sources (omarchy). echo "=== Building $DISTRO rootfs via distros/${DISTRO}/build-rootfs.sh ===" [ -n "$CHROOT" ] || { echo "FATAL: \$CHROOT empty"; exit 1; } mkdir -p "$CHROOT"