feat(nix): Ladybird / Servo のビルド用 devShell を追加 - #465
Merged
Conversation
WebKit 以外のブラウザエンジンを母艦でビルドするための devShell を nix/shells/browser-engines.nix に宣言する。どちらも Xcode の clang と macOS SDK を参照するので darwin 限定。 Homebrew を使わないのは darwin.nix が cleanup = "uninstall" で brew を 管理しているため。各プロジェクトの bootstrap が入れたパッケージは次の rebuild で消えるので、必要なツールは nix 側から供給する。 実際に踏んだ罠を3つコメントとして残した: - nixpkgs の libtool は GNU 版を素の `libtool` として入れるため Apple の /usr/bin/libtool を覆い隠す。skia が `libtool -static` を呼んで落ちるので、 Homebrew と同じく GNU 側を glibtool に退避する shim を挟む - Ladybird の find_compiler.py は macOS 上の clang 21 を明示的に拒否するため、 mkShellNoCC で nix の clang を PATH に出さない - bindgen は libclang を直接叩くので macOS SDK の sysroot が渡らず `#include <array>` で死ぬ。BINDGEN_EXTRA_CLANG_ARGS で明示する 両方ともビルドと実ページの描画まで確認済み。
vcpkg は curl と libpsl を自前でビルドするが、nix の curl を PATH に 置くとそちらが勝ち、liblagom-url が /nix/store の libpsl に、vcpkg の libcurl が /nix/store の nghttp2 にリンクされていた。 devShell を抜けるとその store path を参照するものが無くなるため、次の GC で消える。実際に消えて Ladybird が dyld の "Library not loaded" で 起動しなくなった。ダウンロードは /usr/bin/curl で足りる。
devShell に依存を足すと成果物が /nix/store を参照し、GC 後に起動不能に なる件と、重いビルドを macmini に投げる手順。
GStreamer 公式 pkg は sudo でのシステム install になるため macmini 側に だけ入れた。mach package が dylib を .app に同梱するので、母艦は成果物を 受け取るだけでよい。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
何を
WebKit 以外のブラウザエンジン (Ladybird / Servo) を母艦でビルドするための devShell を
nix/shells/browser-engines.nixに宣言した。どちらも Xcode の clang と macOS SDK を絶対パスで参照するので darwin 限定。なぜ nix で囲うか
darwin.nix が Homebrew を
cleanup = "uninstall"で管理しているので、各プロジェクトの bootstrap スクリプトが brew 経由で入れたパッケージは次の rebuild で黙って消える。必要なツールは最初から nix 側から供給する。Servo の
mach bootstrapが brew を叩く唯一の経路なので、これは呼ばない運用にした (Brewfile の中身は cmake と pkg-config だけで、どちらも devShell にある)。踏んだ罠
実際にビルドを通す過程で3回落ちた。それぞれ原因をコメントとして残してある。
libtool の名前衝突 — nixpkgs は GNU libtool を素の
libtoolとして入れるので Apple の/usr/bin/libtoolを覆い隠す。両者は名前が同じだけの別物で、skia がlibtool -static -o libwuffs.a ...という Apple のアーカイバとしての呼び方をしてunrecognised option: '-static'で死ぬ。Homebrew と同じく GNU 側をglibtoolに退避する shim を挟んだ。autoreconf が要る m4 マクロは名前だけの shim に乗らないのでACLOCAL_PATHで別途通す。clang 21 の拒否 — Ladybird の
Meta/Utils/find_compiler.pyは macOS 上の clang 21 を明示的に弾く (LLVM の libc++ とリンクするとstd::__1::__hash_memoryで落ちるため)。mkShellNoCCにして nix の clang を PATH に出さず、Xcode の clang を使わせる。bindgen の sysroot — mozangle / mozjs は libclang を直接叩くので clang ドライバ経由の sysroot が渡らず
#include <array>で死ぬ。BINDGEN_EXTRA_CLANG_ARGSで-isysrootを明示し、libclang も Xcode 側に揃えた。検証
両方ビルドして実ページの描画まで確認した。
Build/release/bin/Ladybird.appが完成、example.com を GUI で正常描画。プロセス構成も設計通り (Ladybird / RequestServer / ImageDecoder / WasmCompiler / Compositor / WebContent x2)--headless --exit -oで example.com を正しく描画Ladybird の headless は 2026-08 時点の master で壊れている (headless では Compositor プロセスが起動しないのに WebContent が閉じた接続を叩いて落ちる)。こちらの環境の問題ではないので、CHEATSHEET に注記だけ残した。
確認済み
nix evalでdevShells.aarch64-darwin.{ladybird,servo,default}が評価できる (既存のdefaultを潰していない)just fmt/ pre-commit (deadnix, gitleaks, nixfmt, shellcheck) 通過just docsで生成ブロックに差分なし