UnixBuilderImpl
Defined in: packages/core/src/builder.ts:336
Concrete implementation of UnixBuilder.
Remarks
Section titled “Remarks”Produced by Unix — do not instantiate directly. Exported so
implementation code inside @fishnet/* (runtimes, test helpers) can type
fresh builder instances; consumer code should reach this class only
through Unix or UnixImage.extend.
Immutable: every method (use, mount, bin, env, file, service,
run, catalog) returns a new UnixBuilderImpl with the extension
appended. The original is never modified, so forking a base builder to
produce variants is safe. .build() is the terminal operation — it
merges all accumulated extensions, builds the frozen root filesystem,
replays every .run() step (memoized via the build cache), and returns
a UnixImageImpl.
Method-level contracts (use, mount, …) are documented on
UnixBuilder. This class inherits those contracts and adds the
immutability / cache-reuse guarantees described above.
Example
Section titled “Example”import { Unix, stdSystem } from '@fishnet/core'
const base = Unix().use(stdSystem()) // UnixBuilderImplconst withDb = base.use(sqlite()) // base is untouchedconst image = await withDb.build() // UnixImageImplImplements
Section titled “Implements”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new UnixBuilderImpl(
init?):UnixBuilderImpl
Defined in: packages/core/src/builder.ts:345
Parameters
Section titled “Parameters”BuilderInit
Returns
Section titled “Returns”UnixBuilderImpl
Methods
Section titled “Methods”bin(
name,fn):UnixBuilder
Defined in: packages/core/src/builder.ts:380
Sugar for .use({ bins: { [name]: fn } }).
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Implementation of
Section titled “Implementation of”boot()
Section titled “boot()”boot(
runtime,opts?):Promise<UnixInstance>
Defined in: packages/core/src/builder.ts:452
Boot an instance from the built image. Requires a runtime (e.g. testRuntime(), nodeRuntime()).
Parameters
Section titled “Parameters”runtime
Section titled “runtime”Returns
Section titled “Returns”Promise<UnixInstance>
Implementation of
Section titled “Implementation of”build()
Section titled “build()”build():
Promise<UnixImage>
Defined in: packages/core/src/builder.ts:404
Returns
Section titled “Returns”Promise<UnixImage>
Implementation of
Section titled “Implementation of”catalog()
Section titled “catalog()”catalog(
name,factory):UnixBuilder
Defined in: packages/core/src/builder.ts:400
Parameters
Section titled “Parameters”string
factory
Section titled “factory”() => Extension
Returns
Section titled “Returns”Implementation of
Section titled “Implementation of”env(
key,value):UnixBuilder
Defined in: packages/core/src/builder.ts:384
Sugar for .use({ env: { [key]: value } }).
Parameters
Section titled “Parameters”string
string
Returns
Section titled “Returns”Implementation of
Section titled “Implementation of”file()
Section titled “file()”file(
path,content):UnixBuilder
Defined in: packages/core/src/builder.ts:388
Sugar for .use({ files: { [path]: content } }).
Parameters
Section titled “Parameters”string
content
Section titled “content”string
Returns
Section titled “Returns”Implementation of
Section titled “Implementation of”mount()
Section titled “mount()”mount(
path,server):UnixBuilder
Defined in: packages/core/src/builder.ts:376
Sugar for .use({ mounts: { [path]: server } }).
Parameters
Section titled “Parameters”string
server
Section titled “server”Returns
Section titled “Returns”Implementation of
Section titled “Implementation of”run(
command):UnixBuilder
Defined in: packages/core/src/builder.ts:396
Record a shell command to execute at build time. Executed sequentially by .build().
Parameters
Section titled “Parameters”command
Section titled “command”string
Returns
Section titled “Returns”Implementation of
Section titled “Implementation of”service()
Section titled “service()”service(
def):UnixBuilder
Defined in: packages/core/src/builder.ts:392
Sugar for .use({ services: [def] }).
Parameters
Section titled “Parameters”Returns
Section titled “Returns”Implementation of
Section titled “Implementation of”use(
ext):UnixBuilder
Defined in: packages/core/src/builder.ts:372
Compose an Extension into the builder. Returns a new builder.