Building with mkBunDerivation
mkBunDerivation
is provided as a library function to build bun packages from the file generated by the bun2nix command line tool.
Example
Currently, basic usage would look something like:
{mkBunDerivation, ...}:
mkBunDerivation {
pname = "simple-bun-app";
version = "1.0.0";
src = ./.;
bunNix = ./bun.nix;
index = "index.ts";
}
or, in the more implicit style:
{mkBunDerivation, ...}:
mkBunDerivation {
packageJson = ./package.json;
src = ./.;
bunNix = ./bun.nix;
}
NOTE: building with the implicit
package.json
values makes a number of basic assumptions about your project that it expects to hold true in the name of convenience. Approximately, these are:
name
is a field that is acceptable for use as the name of the binary produced by your package.version
is a field denoting your package version in proper semantic versioning.module
is a field pointing towards yourindex.ts file or equivalent. If you notice any strange errors while using the implict build scheme try specifying the values manually and contribute a new descriptive assert message to
mkBunDerivation`.
Arguments
The full list of accepted arguments is:
Argument | Purpose |
---|---|
packageJson | (Optional) Your project's package.json . If supplied can be used to complete pname , version and index instead of requiring them manually. |
pname | (Optional) The name of the package to build. Required if packageJson is not given. |
version | (Optional) Your package version. Required if packageJson is not given. |
src | The source code for your package |
bunNix | The file generated by the bun2nix cli |
index | (Optional) The index.{js,ts} file entry point to your bun application. If you do not have one, leave this empty and use a custom buildPhase . This should be a string containing the relative path from src . Required if packageJson is not given. |
buildFlags | Optional flags to pass into bun build in the default buildPhase . By default these flags are [ "--compile" "--minify" "--sourcemap" "--bytecode" ] . If you have issues with your build try removing some of them or read the bun documentation on single file executables. |
dontPatchShebangs | (Optional) Prevent patching shebangs in node_modules scripts. |