Skip to content

Plugin builder

pkgs.piBoltPlugins.buildPiBoltPlugin { ... } returns a derivation containing the extension’s source tree. See packaging plugins for recipes. The implementation is nix/plugins/build-plugin.nix.

ArgumentDefaultMeaning
pnameRequiredDerivation name; also the default plugin ID.
srcRequiredSource directory or archive, unpacked by stdenv.
entryRequiredFile relative to the plugin root with the default extension factory export. Must exist in the installed tree.
version"0"Derivation version only; does not rewrite package.json.
pluginNamepnameStaging directory/extension ID, used as builtin:<pluginName>.
packageNamenullnpm import name for links from dependent plugins. Not checked against the manifest.
dependencies[ ]Other plugin derivations imported by this plugin. Their sources are staged transitively; registration remains explicit.
packageLocknullPath to the plugin’s npm lock, with its matching package.json beside it. Installs private dependencies offline.
nodeModulesnullPrepared node_modules directory, for custom installation. Mutually exclusive with packageLock.
runtimeInputs[ ]Programs needed at runtime. Declared plugin dependencies’ tools are included.
workers[ ]Worker entry files relative to the plugin root; passed to Pi-Bolt as separate compile entries.
builtintrueRegister as a named, replaceable built-in. false opts out of that mechanism and cannot be disabled by a selection.

Standard derivation fields such as patches, postPatch, meta, nativeBuildInputs and passthru are accepted. The builder preserves caller inputs/passthru and defaults dontConfigure, dontBuild and dontFixup to true; callers can override them. A build step is not run unless enabled explicitly.

packageLock and its adjacent manifest must be readable at evaluation time. Installation omits dev dependencies, disables lifecycle scripts and does not auto-install peers. packageLock and nodeModules cannot both be set.

The installed or supplied modules are copied; declared plugin dependencies with a non-null packageName are linked into them. Root copies of @earendil-works/pi-* and typebox are removed because Pi supplies them. The compile staging also excludes these names; see host-package aliases.

AttributeMeaning
extensionPathStore path to the installed entry file, suitable for -e or an explicit extension path.
piBolt.namePlugin ID.
piBolt.entry, .packageName, .dependencies, .workers, .builtinBuilder metadata consumed by the payload.
piBolt.runtimeInputsDeduplicated plugin/dependency tool list.

piBolt is generated metadata, not an alternative authoring API. Normal Pi manifests remain stock-Pi-compatible; do not add Pi-Bolt-specific fields to package.json for this builder.

pkgs.piBoltPlugins.fetchNpmPackage { pname, version, hash, registry ? "https://registry.npmjs.org"; } fetches one package from the npm registry and unpacks it, for a plugin published to npm. hash is the registry’s own integrity value (npm view <pname>@<version> dist.integrity) or any SRI hash of the tarball; registry selects a mirror.

The result is the package directory, so its package.json is at the derivation root and a plugin’s entry is relative to that root. passthru.packageName carries the npm name, which the builder uses when linking it as a dependency.

Both builders sit in the scope because a published plugin set reads them from it:

inherit (pkgs.piBoltPlugins) buildPiBoltPlugin fetchNpmPackage;