diff --git a/pkgbuilds/omarchy-mlx/.omarchy/package.json b/pkgbuilds/omarchy-mlx/.omarchy/package.json new file mode 100644 index 0000000..fe36a8c --- /dev/null +++ b/pkgbuilds/omarchy-mlx/.omarchy/package.json @@ -0,0 +1,14 @@ +{ + "source": "local", + "channels": ["edge"], + "min_release_age": "24h", + "rebuild_on": [ + "llvm" + ], + "upstream": { + "watch": { + "github": "joshuaswarren/omarchy-mlx", + "pattern": "v(?P[0-9]+(?:\\.[0-9]+)*)" + } + } +} diff --git a/pkgbuilds/omarchy-mlx/PKGBUILD b/pkgbuilds/omarchy-mlx/PKGBUILD new file mode 100644 index 0000000..b1865d5 --- /dev/null +++ b/pkgbuilds/omarchy-mlx/PKGBUILD @@ -0,0 +1,120 @@ +# Maintainer: Joshua Warren <816217+joshuaswarren@users.noreply.github.com> + +pkgbase=omarchy-mlx +pkgname=(omarchy-mlx omarchy-mlx-vulkan) +pkgver=0.7.24 +pkgrel=1 +arch=('aarch64') +url='https://github.com/joshuaswarren/omarchy-mlx' +# The two packages publish together, so the tested wheel and the Vulkan driver +# it was qualified on can never skew. +_wheel=mlx_omarchy-0.32.4.dev202610032142+eaa69723-cp314-cp314-linux_aarch64.whl +_vendor=omarchy-mlx-vendor-wheels-v$pkgver-cp314-aarch64.tar +# The Honeykrisp Vulkan driver: joshuaswarren/mesa-1 honeykrisp-omarchy-v3. +_mesa_commit=e7631595df6281748ea5e643d74db59c5f783b01 +# The driver reports this in driverInfo as "git-"; the runtime compares it. +_mesa_sha=${_mesa_commit:0:10} +makedepends=('clang' 'elfutils' 'expat' 'glslang' 'libclc' 'libdrm' 'llvm' 'meson' + 'python' 'python-mako' 'python-packaging' 'python-yaml' + 'spirv-llvm-translator' 'spirv-tools' 'zstd') +# check() imports the staged venv's mlx.core, which loads these shared +# libraries at import. Per-package depends are not installed at check() time +# in a fresh makepkg container, so they must come from pkgbase-level checkdepends. +checkdepends=('openblas' 'lapack' 'blas' 'vulkan-icd-loader') +options=('!debug' '!lto') +source=("omarchy-mlx-$pkgver.tar.gz::$url/archive/refs/tags/v$pkgver.tar.gz" + "$_wheel::$url/releases/download/v$pkgver/${_wheel//+/%2B}" + "$_vendor::$url/releases/download/v$pkgver/$_vendor" + "mesa-$_mesa_commit.tar.gz::https://github.com/joshuaswarren/mesa-1/archive/$_mesa_commit.tar.gz") +noextract=("$_wheel" "$_vendor") +sha256sums=('022489f1aa70eaafa85a015500a257f5817676e352b9ff2d4368e2c8cb1efac7' + 'c18ca23ccf8602f4bcceba5e3125b1c6cf67083d73fd8caa28ad26f8b4339dcb' + 'fbfad09877a45de7e8160b659ed55415f0df0c43e6ea3552c412d0ddd7ae4d0e' + 'ae00b9568f1c57a7be7518b6f508354bc86c4494d83a82ef79bd0a799835c4b2') + +prepare() { + rm -rf vendor + mkdir vendor + tar -xf "$_vendor" -C vendor --strip-components=1 + [[ -f vendor/$_wheel ]] || cp "$_wheel" vendor/ +} + +build() { + # Vulkan driver only: no GL, no gallium drivers, no window systems, no layers. + # The tarball has no .git; git_sha1.h is generated at compile time from this. + export MESA_GIT_SHA1_OVERRIDE=$_mesa_sha + meson setup "mesa-1-$_mesa_commit" build-mesa \ + --prefix=/usr \ + --libdir=lib \ + --buildtype=release \ + -Db_ndebug=true \ + -Dvulkan-drivers=asahi \ + -Dgallium-drivers= \ + -Dplatforms= \ + -Dvulkan-layers= \ + -Dopengl=false \ + -Dgles1=disabled \ + -Dgles2=disabled \ + -Degl=disabled \ + -Dgbm=disabled \ + -Dglx=disabled \ + -Dllvm=enabled \ + -Dshared-llvm=enabled \ + -Dvalgrind=disabled \ + -Dbuild-tests=false + meson compile -C build-mesa + DESTDIR="$srcdir/mesa-stage" meson install -C build-mesa + + # The system venv and launchers, built offline from the hash-locked wheels. + cd "omarchy-mlx-$pkgver" + MLX_OMARCHY_CONV_RING=0 bash install.sh --system \ + --dest-root "$srcdir/stage" \ + --vendor "$srcdir/vendor" \ + --lock "$srcdir/vendor/requirements-lock.txt" +} + +check() { + grep -aq "(git-$_mesa_sha)" "$srcdir/mesa-stage/usr/lib/libvulkan_asahi.so" + "$srcdir/stage/usr/lib/omarchy-mlx/venv/bin/python" \ + -c 'import mlx.core, mlx_omarchy_paths, mlx_omarchy_serve' + # Refuse a stage whose ANE bytes disagree with the wheel's runtime pin. + python3 "$srcdir/omarchy-mlx-$pkgver/scripts/verify_runtime_assets.py" \ + "$srcdir/stage/usr/lib/omarchy-mlx/venv/lib/python3.14/site-packages/mlx/share/mlx-omarchy/parakeet-1" +} + +package_omarchy-mlx() { + pkgdesc='MLX for Apple Silicon Macs: GPU inference through Vulkan, with ANE support' + license=('MIT') + groups=('omarchy-platform-apple-silicon') + depends=("omarchy-mlx-vulkan=$pkgver-$pkgrel" 'python>=3.14' 'python<3.15' + 'blas' 'gcc-libs' 'glibc' 'lapack' 'openblas' 'vulkan-icd-loader') + optdepends=('omarchy-ane-abi: Apple Neural Engine execution on qualified chips (omarchy-ane-dkms)') + cp -a "$srcdir/stage/usr" "$pkgdir/usr" +} + +package_omarchy-mlx-vulkan() { + pkgdesc='Honeykrisp Vulkan driver for omarchy-mlx only (private ICD, not used by other programs)' + license=('MIT AND BSD-3-Clause AND SGI-B-2.0') + groups=('omarchy-platform-apple-silicon') + depends=('expat' 'gcc-libs' 'glibc' 'libdrm' 'libelf' 'llvm-libs' 'spirv-tools' 'zstd') + conflicts=('mesa-honeykrisp-omarchy') + + local dir=/usr/lib/omarchy-mlx/vulkan + install -Dm755 "$srcdir/mesa-stage/usr/lib/libvulkan_asahi.so" "$pkgdir$dir/libvulkan_asahi.so" + # The ICD manifest stays out of the loader's search path; only omarchy-mlx + # names it. library_path is absolute. + python - "$srcdir/mesa-stage/usr/share/vulkan/icd.d/asahi_icd.aarch64.json" \ + "$pkgdir$dir/honeykrisp_icd.aarch64.json" "$dir/libvulkan_asahi.so" <<'PY' +import json, sys +src, dst, lib = sys.argv[1:] +manifest = json.load(open(src)) +manifest["ICD"]["library_path"] = lib +with open(dst, "w") as f: + json.dump(manifest, f, indent=4) + f.write("\n") +PY + chmod 644 "$pkgdir$dir/honeykrisp_icd.aarch64.json" + printf '%s\n' "$_mesa_sha" | install -Dm644 /dev/stdin "$pkgdir$dir/mesa-git-sha" + install -Dm644 "$srcdir/mesa-1-$_mesa_commit/docs/license.rst" \ + "$pkgdir/usr/share/licenses/$pkgname/license.rst" +}