Packaging

One command with ordered stages: on macOS crust build assembles and ad-hoc signs an app, then --sign replaces that signature with a Developer ID, --notarize submits the app and staples its ticket, and --dmg wraps the already-stapled app for handing over. crust dmg, crust sign and crust notarize are no longer commands. On Linux and Windows build produces the flat compiled binary only — no bundle, no signing — and the stages below do not apply.

crust build

crust build
crust build --dir my-app
crust build app.tsx          # single-file mode

It runs build.beforeBuildCommand first, reads build.assets, compiles the backend with Bun, then — only on macOS — assembles the bundle and signs it ad-hoc. Off darwin the compiled binary is the whole product and build reports sign none — codesign is macOS-only. A failed frontend build stops the command instead of packaging stale bytes.

outputwhat it is
dist/crust-appthe compiled binary
dist/<app.name>.appthe assembled bundle (macOS only)
dist/crust-assets.ts, dist/crust-entry.tsgenerated inputs for that build

On macOS the two sizes are printed separately because they answer different questions: the binary is what Bun produced, the bundle is what a recipient's disk gives up. Off darwin only the binary line prints. LSMinimumSystemVersion defaults to 13.0; set build.minimumSystemVersion to raise it. A missing node_modules fails here with a plain "run bun install" rather than inside a bundler.

build.assets defaults to public/. The React template names dist/web, the Next template out/, because a static export is where Next puts its page. Whatever the directory holds is embedded in the binary — there is no server at run time.

The --dmg stage

crust build --dmg                         # image from the app built in this run
crust build --sign --notarize --dmg       # full release order in one command

Stages the freshly built bundle beside an /Applications symlink and compresses that folder into a drag-to-Applications image at dist/<app.name>-<app.version>.dmg. The volume name is app.name. The stage runs last, so with --notarize the image holds the already-stapled app. The dmg itself is not notarized: the notary plan zips and staples the .app, so the app's ticket travels inside the image.

The --sign stage

CRUST_SIGNING_IDENTITY="Developer ID Application: Name (TEAMID)" crust build --sign

Reads the identity from the environment and fails naming it when unset. Signs with --options runtime, seals the entitlements below, verifies with codesign --verify --strict, and prints what spctl says. It replaces the ad-hoc signature crust build just applied. Declared build.sidecars are re-signed first, deepest path first, with the same identity, hardened-runtime options and entitlements; an ad-hoc sidecar left inside a Developer ID bundle is a notarization rejection. Developer ID signatures carry a secure --timestamp, while ad-hoc builds keep --timestamp=none. Local verification uses codesign --verify --strict --deep, so nested code is checked instead of reading as clean under a shallow verify. On Windows crust package --format nsis creates each sidecar's parent directory before installing the file.

It does not notarise: that needs notarytool credentials and a stapler staple afterwards, and until the ticket is stapled spctl still refuses the bundle. Add --notarize for that; it requires --sign, because an ad-hoc signature cannot be submitted.

Why ad-hoc is the default on macOS

On macOS crust build signs with codesign --sign -. That works on the machine that built it and cannot be notarised, because an ad-hoc signature has no certificate chain to notarise against. So Gatekeeper refuses the app on every other Mac: spctl rejects it with exit 3, and the recipient sees "damaged and can't be opened".

The way out is on their side:

xattr -dr com.apple.quarantine "my-app.app"

or right-click → Open. A Developer ID signature is the only thing that removes the step, and it needs a certificate this repository does not ship.

A related consequence: macOS keys privacy grants to the app's designated requirement, which for an ad-hoc build is the binary's own cdhash. Every rebuild looks like a new app and re-prompts. A Developer ID gives the bundle a stable requirement.

Entitlements

The hardened runtime is off by default. With the --sign stage it is on, and two entitlements are sealed:

entitlementwhy
com.apple.security.cs.allow-jitthe one Apple documents; it permits MAP_JIT pages
com.apple.security.cs.allow-unsigned-executable-memorythe TinyCC inside Bun writes machine code into ordinary unsigned executable memory, which allow-jit alone does not permit

Both are required, and the second is easy to miss. Sealed with allow-jit only, a signed app launches, creates no page, prints nothing and exits 0 — which reads as a packaging bug for as long as you look in the wrong place. crust build's ad-hoc signature carries no entitlements, because it does not enable the hardened runtime.