Reference
The Bedrock build (v3)
On this page
How a v3 site repository becomes the read-only tree production serves: lib/mk-bedrock-site.nix (lib.mkBedrockSite), driven by wordpress-nix.site in a site flake (modules/site.nix), with nix run .#relock (lib/relock.nix) keeping nix/vendor-hash current.
The two derivations
The vendor FOD,
php.mkComposerVendor. Its source iscomposer.jsonandcomposer.lockonly, so committed premium code and everything else in the repository never perturbs its hash. It runs nixpkgs' vendor hook (composer install --no-autoloader) with Composer plugins enabled (composerNoPlugins = false):composer/installersplaceswp-plugin/*,wp-theme/*and mu-plugins underweb/app/, androots/wordpress-core-installerplaces core inweb/wp.The hook keeps
vendor/and theextra.installer-pathsprefixes, notextra.wordpress-install-dir, sopostInstallcopiesweb/wpitself.It then removes everything Composer generates from the packages:
vendor/autoload.php,vendor/composer/{autoload_*,ClassLoader,platform_check}.php,LICENSE,installed.phpandInstalledVersions.php. What stays is the packages andinstalled.json.Its store path is its name and its hash, so CI, Attic and the cluster nodes share it even where the package derivations differ.
The package,
php.buildComposerProject2withcomposerVendorset to the FOD. nixpkgs' install hook restoresvendor/and the installer paths, then runs an offlinecomposer install, which writes the autoloader;postBuildthen runscomposer dump-autoload --no-dev --optimize.installPhasecopies the tree to$out(not the hook'sshare/php/<pname>), and:refuses to install
.env*,auth.jsonor.gitinto the store;links
web/app/uploads→/var/lib/wordpress/uploadsand.env→/run/wordpress/bedrock.env, and dropsweb/app/{cache,upgrade};injects the platform mu-plugins as single files in
web/app/mu-plugins;writes the FOD's path to
share/wordpress-nix/vendor-src, so the FOD is a runtime reference of every closure that holds the site;asserts
web/wp/wp-includes/version.php,vendor/autoload.php,vendor/composer/autoload_real.php,installed.phpandInstalledVersions.phpexist, and that the committed PHP underweb/appparses (php -l).
passthru.wordpressNix carries php (the nixpkgs base the runtime optimizes), wordpressVersion (from composer.lock), vendor, uploadsDir, envFile, productionOnlyPlugins, developmentOnlyPlugins and activeTheme.
Findings recorded in M1
The install hook rewrites
installed.phpandInstalledVersions.php. Confirmed: the FOD has neither (the build removes them), the package has both, and\Composer\InstalledVersionsanswers for the locked core.tests/bedrock-build.nix(bedrock-build) asserts all three, so the fallback (keeping them in the FOD, which ties the hash to Composer's version) is not needed. The install hook'scomposer installfinds every locked package installed ("Nothing to install, update or remove") and still writes the local repository files and the autoloader.The hook nests installer paths into committed ones. It restores each prefix with
cp -ar <vendor>/<prefix> <prefix>; when<prefix>already exists, asweb/app/{plugins,themes,mu-plugins}always do in a Bedrock repository, GNU cp copies into it (web/app/plugins/plugins/…).preBuildtherefore moves the committed directories aside before the hook runs (stdenv runs thepreBuildattribute ahead ofpreBuildHooks), andpostBuildmoves them back beside Composer's. A committed directory named like a Composer package fails the build (bedrock-build-collision).The vendor hash is stable across two clean builds (
bedrock-build-rebuild: the FOD built again under another name, against the same committed hash;nix build --rebuildof the fixture's and the template's FOD) and across nixpkgs revisions: the fixture's committed hash built unchanged with Composer 2.9.8 (nixos-25.11), 2.10.3 (this flake's nixpkgs) and 2.11.2 (a later nixos-unstable). nixos-25.11's vendor hook still wrote the autoloader into the FOD; removing the generated files inpostInstallis what makes that revision agree.composer validate --strict --no-check-all --no-check-publish --check-lockpasses on stock Bedrock with exact pins (roots/wordpress7.1.5,roots/wp-config1.0.0):templates/bedrock-siteand the fixture.A plugin bump plus
nix run .#relockbuilds: verified on a copy of the template (composer require wp-plugin/two-factor:0.9.1 --no-install, relock,nix build,nix flake check).
Relock
nix run .#relock (from the site's root) writes lib.fakeHash to nix/vendor-hash, builds .#vendor, takes the got: hash from the failure,
writes it, and builds again to confirm. On any failure the old hash is put
back. In a git work tree the file is staged, since a flake sees only what git
tracks.
The site flake's checks
All pure (nix flake check reaches no network beyond fixed-output fetches):
| check | what |
|---|---|
composer-validate | composer validate --strict --no-check-all --no-check-publish --check-lock |
vendor-hash | nix/vendor-hash is one sha256 SRI hash, not lib.fakeHash |
build | the package, with the assertions above |
verify-wp-checksums (nix run .#verify-wp-checksums) needs the network and
runs as a CI step: core and wp-plugin/* against wordpress.org's checksum
APIs, wp-theme/* against the locked zip. A PHP file that differs, or that
wordpress.org never shipped, fails it.
wordpress-nix's own checks
| check | what |
|---|---|
bedrock-build, -rebuild, -collision, -eval | tests/bedrock-build.nix over tests/fixtures/bedrock-site |
bedrock-template | the template's and the fixture's Bedrock files equal the pinned bedrock input |
verify-wp-checksums | pristine passes; a tampered plugin file, an extra core or theme PHP file, an unknown plugin version fail |
The fixture resolves from a local Composer artifact repository
(tests/fixtures/bedrock-site/artifacts, written by make-artifacts.py):
the real composer/installers, roots/wordpress-core-installer, roots/wordpress and roots/bedrock-disallow-indexing, plus small stand-ins
for core, a plugin, a theme and a PSR-4 library. composerRepositoryPaths puts artifacts/ in the FOD's source.