Ledgeline development
Ledgeline is a single-binary app. The ledgeline binary is an axum HTTP
server plus a wry/tao desktop webview (the default-on gui cargo feature),
with the built SvelteKit SPA embedded into the binary through rust-embed.
Build with --no-default-features --features watcher,external-tools for a
headless, server-only binary, which is what Linux servers build. watcher is
live reload from a file watcher, and external-tools runs hledger and git
subprocesses (for imports). Bare --no-default-features drops both. A
sandboxed host such as the iOS app needs that build, where it picks up external
edits by calling AppState::refresh() and imports are unavailable.
You build the SPA into web/build. crates/ledgeline-server/build.rs mirrors
that into crates/ledgeline-server/spa/, and that is what rust-embed
embeds. The extra step makes the crate publishable, because cargo package
will not include files outside the package root. It is also why
cargo install ledgeline gets a real UI. See that build.rs for the three
cases it handles, and releasing.md for the rest.
The whole toolchain is provided by Nix. Do not install anything globally.
Dev shell
direnv allow # auto-loads the flake dev shell (.envrc)
# or, without direnv:
nix develop path:.
The dev shell provides the pinned Rust toolchain, pkg-config, nodejs_24,
bun, hledger, hledger-web, just, and the Playwright browsers, plus the
Linux GUI libraries (webkitgtk_4_1, gtk3, libsoup_3). It also exports
LEDGELINE_FIXTURE and the Playwright env vars. Common tasks are in the
justfile (just --list).
nix develop path:. --command bash -c 'cargo --version && node --version && bun --version && hledger --version'
The pre-push hook
Entering the dev shell installs a pre-push hook (git-hooks.nix, configured
in flake.nix under gitHooks). It runs the two formatters CI cares about
against the whole tree, then just pre-push:
| Hook | Runs | Fires when |
|---|---|---|
rustfmt (workspace) | cargo fmt --all -- --check, from the pinned toolchain | any .rs file changed |
alejandra | alejandra | any .nix file changed |
just pre-push | everything CI gates on that a laptop can run (see Continuous integration) | every push |
just pre-push takes minutes, not seconds. It used to be a command you had to
remember to type, and the failures it checks for kept reaching CI. A push
from outside the dev shell enters it first. The hook tests the working tree, not
just the commits being pushed, because pre-push hooks get no stash.
The hook runs at push time rather than commit time on purpose. A pre-commit
hook fires on every WIP and fixup commit, where half-formatted code is normal,
and that friction leads people to use --no-verify. That flag then also skips
the hook in the case it was meant to catch. A push is when code stops being
private, and it is the last point before CI spends twenty minutes reporting the
same failure.
rustfmt comes from rust-toolchain.toml rather than nixpkgs’ cargo on
purpose. Two rustfmt versions differ enough that one can reject a push over a
file CI accepts, and people bypass a hook that reports false failures.
It does not replace CI, because a hook runs on one machine and --no-verify
skips it. It does catch the mechanical cases before they cost a CI round trip.
For example, renaming ledgeline-server to ledgeline changed how rustfmt
sorts use statements (ledgeline sorts before ledgeline_core where
ledgeline_server sorted after), and cargo check and cargo test both pass
on mis-sorted imports.
The generated .pre-commit-config.yaml is a symlink into /nix/store and is
git-ignored. Edit flake.nix to change the hooks. To bypass once:
git push --no-verify
The crane caching model (why rebuilds/retests are fast)
flake.nix uses crane. It works in two steps:
cargoArtifacts = craneLib.buildDepsOnly …compiles only the third-party dependencies (including the entire wry/tao GUI stack) from a dummy source. This is a single cached layer in the Nix store.- Every real output, meaning the binary and each check, is built on top of a layer, so they reuse it instead of recompiling dependencies.
There are two layers, one per cargo profile, because cargo only reuses artifacts built with the same profile and the same resolved features:
| Layer | Profile | Used by |
|---|---|---|
.#cargoArtifacts | release (fat LTO, codegen-units = 1) | what ships: .#ledgeline, .#ledgelineWithSpa, macApp/macDist, linuxDist |
.#cargoArtifactsCi | ci (release minus LTO, codegen-units = 16; see Cargo.toml) | the checks: .#tests, .#clippy |
.#cargoArtifactsInvoicer | release, chained on .#cargoArtifacts | Ledgeline Invoicer: .#invoicerWithSpa, .#invoicerMacApp, linuxDist’s invoicer |
The invoicer’s layer starts from Ledgeline’s and adds only what build -p ledgeline-invoicer needs beyond it (MBR and its tree, ~130 crates, and shared
crates whose features differ). It is a third layer rather than a second pass in
.#cargoArtifacts so that nothing that builds only Ledgeline compiles the
invoicer’s dependencies.
buildDepsOnly cannot start from another layer, so it is a cargoBuild over
the same mkDummySrc source.
The checks run without LTO because under release every one of the ~150
integration-test binaries did a whole-program LTO link. That took about 50 of the Linux
tests job’s 54 minutes, and over two hours of the macOS job (CI run
45465085877).
Each layer also runs the same cargo commands, with the same feature flags and
the same -p selection, as the outputs that reuse it, because cargo unifies
features over the packages a command selects. The ci layer runs
--features ledgeline-ffi/mobile over the workspace (what tests and clippy
pass), and the release layer runs build -p ledgeline, like .#ledgeline and
.#ledgelineWithSpa.
When either one doesn’t match, the output recompiles every crate whose features
differ. CI run 45513409069 hit that: 122 crates for the old spaShellCsp
check (a test -p ledgeline), and ~220 for each ledgeline build when the
release layer built the whole workspace. That is why nothing on the ci layer
tests a -p subset, and the real-SPA CSP tests run inside .#tests.
Because the dependency layer’s hash depends only on Cargo.toml / Cargo.lock
(not on your source), editing a .rs file or a fixture recompiles only the
workspace crates, and the dependency layer is fetched from the store unchanged.
The first build populates the layer, which takes minutes, and later builds and
tests are much faster. Push that layer to Cachix (below) and CI and other
developers skip it entirely.
Outputs
| Command | What it does |
|---|---|
nix build .#ledgeline | The ledgeline binary (proves the GUI deps link: webkitgtk on Linux, system WebKit on macOS). It is .#default on Linux. |
nix build .#clippy | cargo clippy --all-targets -- -D warnings |
nix build .#tests | cargo test over the whole workspace (crates/* and invoicer/crates/*) |
nix build .#fmt | cargo fmt --all --check (crane’s cargoFmt; --all is required because the workspace root has no targets of its own) |
nix build .#macApp | macOS only. Just the result/Applications/Ledgeline.app bundle, real SPA embedded (see below). |
nix build .#invoicerMacApp | macOS only. result/Applications/Ledgeline Invoicer.app, the invoicer’s real SPA embedded (no hledger); what the release signs. macDist installs it. |
nix build .#invoicerWithSpa | The ledgeline-invoicer binary with its real SPA (macOS and Linux). linuxDist and macDist (each .#default) install it beside Ledgeline. |
nix build (bare, macOS) | macOS only .#default, the combined result/{bin/ledgeline, bin/ledgeline-invoicer, Applications/Ledgeline.app, Applications/Ledgeline Invoicer.app} (CLIs on PATH and both apps). |
nix flake check | Runs all of the checks above |
nix run . | Build and run the real app (Ledgeline only). On macOS runs ledgelineWithSpa; on Linux runs linuxDist’s wrapped ledgeline (see below). |
The bare attribute (.#clippy, .#tests, …) resolves to the current system
automatically (x86_64-linux, aarch64-darwin, …), which is how CI invokes
them on each runner.
nix run runs the real app (both platforms)
apps.default, which is what nix run . and nix run github:zmre/ledgeline execute,
builds the SPA (the bun install FOD, then vite build) and opens the real desktop
window on the given journal:
- On macOS it runs
ledgelineWithSpa, the binary with the actual SvelteKit UI baked in. - On Linux it runs
linuxDist, which wraps that same real-SPA binary with the EGL/GBM search-path suffixes and ships the desktop entry and icons. The wrapper is required, because an unwrapped run aborts in the WebKit web process on any host without/run/opengl-driver.
.#ledgeline still embeds the CI placeholder SPA on every platform, and apps.default
does not use it, on purpose. The checks keep using it, which keeps Mesa and
the whole bun/SPA build out of the CI closure.
The spaNodeModules hash is per-system
spaNodeModules is a fixed-output derivation, and its tree contains
platform-specific native binaries (esbuild, rollup, @tailwindcss/oxide), so the
recursive hash differs per system. spaNodeModulesHashes in flake.nix maps
each system to its hash. A system with no entry throws a build-time error that
names the system, rather than failing as a confusing mismatch against another
platform’s hash.
To add one: build on that system with a placeholder hash and copy the got: value
Nix prints.
nix build .#spaNodeModules # → error: ... specified: sha256-AAAA… got: sha256-<real>
A stale pin is invisible until the cache drops the path
Re-pin every hash in the same commit that changes bun.lock. Forgetting
produces no error. A fixed-output derivation’s store path is derived from its
outputHash, so while the OLD path is still in your store or on
zmre.cachix.org, Nix substitutes it and never runs bun install, so nothing
notices that the pin is out of date. Every machine keeps building.
The failure appears when the cache evicts the path, which it does within days (see
the Nix binary cache playbook). It then appears on whatever PR
happened to be open at the time, which is never the PR that caused it. That
happened on 2026-08-30: Dependency updates changed bun.lock
and package.json without touching flake.nix, all three hashes went stale,
and CI stayed green for a fortnight before failing on an unrelated branch.
To check a pin, force the build rather than relying on a green run:
nix build .#spaNodeModules --rebuild
spaBuild handles two Linux-specific problems:
patchShebangs node_modulesis required. The.binshims carry#!/usr/bin/env node, and the Linux build sandbox has no/usr/bin/env(the darwin one does, which is the only reason this path worked there first).- It must patch the whole tree, not
node_modules/.bin. Those entries are symlinks andpatchShebangsonly rewrites regular files, so pointing it at.binreports success and changes nothing.
The embedded SPA and the Nix sandbox
crates/ledgeline-server/src/lib.rs embeds crates/ledgeline-server/spa/ and
hands it to the shared shell (ledgeline_shell::spa) to serve:
#[derive(RustEmbed)]
#[folder = "$CARGO_MANIFEST_DIR/spa"]
struct SpaAssets;
crates/ledgeline-server/build.rs fills spa/ by mirroring web/build, or
writes a placeholder when there is none (rust-embed refuses to compile against
a missing folder). Neither directory is in the Nix source, so the flake’s
preBuild drops a placeholder web/build/index.html before every cargo phase of
.#ledgeline and .#clippy.
As a result, those two embed a script-less placeholder SPA. That is enough to
prove the Rust compiles, links and passes tests, but it says nothing about the
real UI. The SvelteKit SPA IS built inside Nix (spaNodeModules, then spaBuild), and
the outputs that need it copy it into web/build instead: ledgelineWithSpa
(what macDist, linuxDist and nix run ship, and what the CI e2e job runs
for web/e2e/csp.same-origin.e2e.ts), and .#tests, which embeds both
spaBuild and invoicerSpaBuild and sets LEDGELINE_REQUIRE_REAL_SPA=1, so
tests/spa_shell_csp.rs and the invoicer’s app::spa_shell_csp_tests check
the CSP’s inline-script hashes against what actually ships (and fail on a
placeholder). Locally, build the SPA first (next section).
All of this needs a pinned spaNodeModules hash for the system. On one without
(aarch64-linux today) the real-SPA outputs are absent, .#tests embeds the
placeholder, and packages.default / apps.default fall back to
.#ledgeline, so the flake still evaluates there (nix flake check --all-systems).
The crane source filter also keeps the repo
fixtures/tree in the build source, because the integration tests read it at runtime (CARGO_MANIFEST_DIR/../../fixtures).web/buildis excluded on purpose so the Nix build stays reproducible (always the placeholder, never a stale local SPA).
Building the real single binary (SPA embedded)
Build the SPA first, so the Rust binary can embed it:
cd web && bun run build # writes web/build/
cd .. && cargo build --release # embeds web/build/ into target/release/ledgeline
(Or run both from the dev shell.) A plain cargo build without a prior
bun run build still works, but it embeds the placeholder shell.
The macOS app bundle (Ledgeline.app)
nix build .#macApp (macOS only) produces result/Applications/Ledgeline.app.
This is the standard nix-darwin app layout, so it can be dragged to /Applications
or picked up by home-manager / nix-darwin. The bundle holds
Contents/MacOS/ledgeline (the binary), Contents/MacOS/hledger (see below),
Contents/Info.plist (version taken from the workspace Cargo.toml), and two
icons in Contents/Resources/:
Assets.caris the layered macOS 26+ icon (light, dark, clear and tinted), compiled from the Icon Composer documentassets/Ledgeline.icon. Info.plist names it withCFBundleIconName.ledgeline.icnsis the flat fallback for older macOS (CFBundleIconFile), built by the flake fromassets/ledgeline.png.
Logo and icon assets
The sources are in graphics-sources/ (the logo SVGs and the Illustrator
file) and assets/Ledgeline.icon/ (layer SVGs cut from
ledgeline-logo-no-word-no-bg.svg, with the indigo #524ED2 background set as
the document fill in icon.json). Open the .icon in Icon Composer (bundled
with Xcode 26) to adjust glass, shadows or per-appearance colours.
Everything else is derived from those sources and committed: assets/Assets.car,
assets/ledgeline.png, assets/ledgeline-small.png,
web/static/ledgeline-icon.svg (the README logo),
web/static/ledgeline-icon-small.svg, docs/images/ledgeline-icon.svg and
docs/.mbr/favicon.png. Regenerate them with just icons after changing a
source.
At 32px and below the full design is unreadable, so there’s a small
variant: the same artwork zoomed in on the arrow (the crop is
SMALL_VIEWBOX in scripts/gen-icons.sh). It’s the app’s navbar logo, the
browser-tab icon, the docs favicon, and the 16–48px slots of ledgeline.icns
and the Linux hicolor icons. It is not in Assets.car: Icon Composer has no
per-size variants, and a .icon overrides a .appiconset of the same name
completely. On macOS 26 and later, Finder’s list view therefore shows the full
design at 16px. We accepted that to keep the tuned dark, clear and tinted
appearances. It needs Xcode (actool and Icon Composer’s ictool aren’t available
in the Nix sandbox), so it runs by hand on a Mac rather than in the flake.
The bundled hledger
The bundle ships hledger’s own macOS release binary (bundledHledger in
flake.nix, pinned by version and hash) as a sibling of our binary. That is
where hledger::sibling_hledger, resolution step 4, looks for it.
It has to be bundled because the steps before and after it both fail in a
downloaded app. The baked LEDGELINE_HLEDGER_PATH is a /nix/store/… path that
does not exist on a user’s Mac. A Finder-launched app inherits launchd’s
$PATH rather than the one your shell exports, so a user with Homebrew hledger
working in their terminal still gets “hledger was not found”.
It uses the upstream release binary rather than pkgs.hledger because that binary links only
/usr/lib/* and system frameworks. The Nix build pulls five dylibs out of the
store that would each need vendoring. flake.nix asserts that rather than
assuming it. See releasing.md for how to bump the pin.
On macOS the default package, built by a bare nix build (or nix profile install),
is the combined result/{bin/ledgeline, Applications/Ledgeline.app}, plus
bin/ledgeline-invoicer and Applications/Ledgeline Invoicer.app. An
install puts the CLIs on PATH (through bin/) AND the apps where nix-darwin or
home-manager link them (through Applications/). Each CLI is a link to its app’s
real-SPA binary. On Linux the default is linuxDist: both binaries, wrapped
for Mesa, with their desktop entries and icons.
just package-mac wraps .#macApp and copies a writable copy to dist/Ledgeline.app.
just package-dmg goes one step further and builds an unsigned
dist/Ledgeline-<version>-arm64.dmg for inspecting the packaging locally. The
signed, notarized, distributable DMG is built only by the release workflow.
See releasing.md.
Opening journals from Finder
Info.plist.in registers two exported UTIs so double-clicking a journal launches
Ledgeline with that file open:
| Extensions | UTI | Rank |
|---|---|---|
.journal, .hledger | com.zmre.ledgeline.journal | Owner |
.journal, .ledger, .hledger, others | org.ledger-cli.journal | Owner |
.ledger, .j | com.zmre.ledgeline.ledger | Alternate |
Owner makes Ledgeline the system default for the hledger-specific extensions.
.ledger and .j are shared with Ledger CLI tooling (and .j is generic enough
that other toolchains claim it), so Alternate keeps Ledgeline available in
Open With without replacing an existing default. Both types conform to
public.plain-text, so Quick Look, Spotlight and text editors still work.
Ledgeline does not export org.ledger-cli.journal. It claims it because
other apps (text editors, typically) import it for the same extensions. When
two bundles declare a type for one extension, Launch Services picks one, and the
pick can flip each time either app is re-registered (every Nix/Home Manager
rebuild re-registers at a new path). A file typed as the other UTI used to list
only the importer under Open With, so Ledgeline disappeared from the menu and
double-click went to the editor. Claiming the alias keeps Ledgeline in the menu.
Rank only breaks ties between claimants, and an editor claiming the alias at
Owner too leaves the default to chance. The user’s own choice outranks every
claim: Ledgeline ▸ Make Ledgeline the Default for Journal Files
(DefaultHandler in crates/ledgeline-shell/src/gui/file_assoc.rs, set up in
the server’s gui.rs) re-registers the running bundle, then records Ledgeline as
the user’s handler for each Owner-ranked type (the entry Finder’s Get Info ▸
Change All… writes) and reads it back. A unit test keeps the plist’s
Owner types and the command’s list identical.
To see the type Spotlight has cached for a file (what Finder goes by):
mdls -name kMDItemContentType path/to/file.journal # Spotlight's cached type
macOS does not pass the document in argv. It calls
application:openURLs:, which tao delivers as Event::Opened { urls } and
the server’s gui.rs handles. That event arrives after startup has already parsed a journal
from $LEDGELINE_FIXTURE or the recents list, so the app may briefly show the previous
journal before switching. The app skips re-opening a journal that is already open.
Launch Services caches bundle registrations, so a freshly built bundle in a scratch location is often not picked up. Register it explicitly:
/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -f dist/Ledgeline.app
For the association to persist, the app has to stay in one place. Move it
to /Applications (or let nix-darwin / home-manager link it there). Launch
Services records the path it registered, so a default pointing at a dist/ or
result/ copy breaks as soon as that build is replaced or garbage-collected.
Unlike .#ledgeline (which embeds the CI placeholder SPA), .#macApp embeds
the real SvelteKit UI. The flake builds the SPA inside Nix. A fixed-output
bun install derivation (spaNodeModules, its hash pinned from the workspace root’s bun.lock)
feeds an offline vite build (spaBuild), whose output is embedded in a
dedicated crane build of the binary. No prior bun run build is required. If
bun.lock changes, re-pin spaNodeModules.outputHash (build once with a
fake hash, and Nix prints the real one). The pinned hash captures the host
platform’s native deps (esbuild/rollup/@tailwindcss/oxide), so it is
aarch64-darwin-specific.
The icon is assembled with imagemagick and png2icns (libicns) instead of macOS
iconutil, so it builds in the pure Nix sandbox. The bundle is self-contained
apart from macOS system libraries. It links nothing from /nix/store, so it runs
on a Mac that has never had Nix installed. nixpkgs’ darwin stdenv adds a phantom
-liconv to every link (the binary imports no iconv symbols), so the build
retargets that one load command to /usr/lib/libiconv.2.dylib and re-signs the
binary ad-hoc, because install_name_tool invalidates the linker’s signature and arm64
macOS won’t exec a Mach-O with a broken one. Any other /nix/store dependency
fails the build rather than shipping, because it may be a real one, which needs
vendoring into Contents/Frameworks, not a blind rewrite. Note that ad-hoc
signing is not Developer ID signing or notarization. A publicly distributed
.dmg still needs that separate work, and without it Gatekeeper will warn on a
downloaded copy.
Cachix binary cache
The flake declares three substituters in nixConfig: cache.nixos.org,
nix-community.cachix.org (both public, so pulls work right away), and
zmre.cachix.org, the shared cache we reuse from
zmre/mbr-markdown-browser. Its
real public key is already committed in flake.nix, and .envrc passes
--accept-flake-config so the dev shell trusts all three. Pulls need no
setup, so everyone (and every fork) can use the cache right away.
One-time setup the maintainer must do by hand
Only one thing is required, and only to enable CI pushes:
- Add the
zmrecache’s push auth token to GitHub as a repository secret namedCACHIX_AUTH_TOKEN(repo Settings → Secrets and variables → Actions → New repository secret). This is the same token used by mbr.
Until that secret is set (and on forks), CI still runs. The cache pushes are skipped when the secret is absent, and pulls from all three caches still work.
Push a build manually:
nix build --json .#ledgeline | jq -r '.[].outputs | to_entries[].value' | cachix push zmre
What has to be pushed for a consumer to skip the build
.#ledgeline alone is not enough, because it is not what everyone resolves to:
| What the user runs | darwin resolves to | linux resolves to |
|---|---|---|
nix build / nix profile install | macDist (→ macApp + invoicerMacApp) | linuxDist (→ ledgelineWithSpa + invoicerWithSpa) |
nix run | ledgelineWithSpa | linuxDist |
So the macos job pushes .#macDist and .#ledgelineWithSpa (plus .#bundledHledger).
They are listed separately on purpose. macApp cps the binaries into the bundle instead of
symlinking them, so neither store path is a reference of macDist and neither would be
included in its closure. On Linux the build job pushes .#linuxDist and .#ledgelineWithSpa.
spaNodeModules and spaBuild are build-time inputs only. A consumer who substitutes
macDist never needs them, and CI no longer pushes them (see below).
What CI pushes
Every cachix/cachix-action block sets skipPush: true, so the action’s daemon pushes
nothing. Without it the daemon uploads every path a job builds, including test and clippy outputs,
per-commit binaries and source trees. On the free plan (5 GB, LRU, shared with mbr) those
uploads kept evicting the one path that saves CI time. Pushes are now explicit:
| What | Pushed by | When | Why |
|---|---|---|---|
.#cargoArtifactsCi (the ci-profile deps layer) | tests (Linux), macos | pushes and PRs | The 45+ minute part of a cold build; a Cargo.lock bump lands on a PR first, and that PR’s runs are the cold ones. Not pinned. |
.#cargoArtifacts (the release-profile deps layer) | build (Linux), macos | pushes and PRs | Same, for the shipped binaries. Not pinned. Two layers per platform is more of the 5 GB LRU than one. |
.#cargoArtifactsInvoicer (the invoicer’s release delta) | build (Linux), macos | pushes and PRs | Same, for the invoicer; holds only what it adds to .#cargoArtifacts. Not pinned. |
.#linuxDist, .#ledgelineWithSpa | build (Linux) | pushes to main | What a Linux user substitutes (linuxDist holds both apps). Pinned. |
.#macDist, .#ledgelineWithSpa, .#bundledHledger | macos | pushes to main | What a Mac user substitutes. Pinned. |
.#invoicerMacApp, .#invoicerWithSpa | macos | pushes to main | nix build …#invoicerMacApp. Not pinned itself, but macDist (pinned) holds invoicerMacApp by symlink. |
Both layers are exposed under packages for this purpose. Push them by hand with:
cachix push zmre "$(nix build --no-link --print-out-paths .#cargoArtifacts .#cargoArtifactsCi)"
The macos job also keeps a second-tier cache: nix-community/cache-nix-action saves a whole
/nix/store snapshot (GC’d to ~8 GiB, with the deps layer GC-rooted) to the repo’s own GitHub
Actions cache, keyed on flake.lock, flake.nix, Cargo.lock and every Cargo.toml, which
is everything that can change a deps layer. Only pushes to main save it (and purge the older
nix-macOS-* entries); PRs restore main’s copy. It covers the case where Cachix has already
evicted the darwin deps layers. The action never re-saves a key it restored, so a key built from
the lockfiles alone kept a snapshot with the old layers after a flake.nix change, and every
later run rebuilt them.
Pins (why the cache kept going empty)
The zmre cache is on the free 5 GB plan, which garbage-collects
least-recently-used. That works against us. Every CI run touches the crane
dependency layer, so it stays cached, while the release artifact nobody has
downloaded since the last push is evicted first. ci.yml has two mitigations:
- Pins. The
buildandmacosjobs runcachix pinon the consumer-facing outputs (.#linuxDist+.#ledgelineWithSpaon Linux;.#macDist+.#ledgelineWithSpaon macOS) with--keep-revisions 2. Pinned paths are exempt from GC. The dependency layer is not pinned, on purpose. It is multi-GB, it changes with everyCargo.lockbump, and it is what LRU should be reclaiming. - Explicit pushes only (
skipPush: true, see above). This replacedpushFilter: '-(source|vendor)$', which kept source trees out but still let every other built path in.
Paths already on cache.nixos.org (webkitgtk, gtk3, the whole GNOME stack)
don’t count. Cachix filters them out automatically and never counts them
against the 5 GB, which has been the default since 2020.
For the cross-project version of all this, see nix-binary-cache-playbook.md.
Verifying a path is actually in the cache
Store paths are content-addressed, so evaluating a revision anywhere reproduces exactly what CI built. That lets you check cache coverage without building anything:
p=$(nix eval --raw github:zmre/ledgeline/<rev>#packages.x86_64-linux.ledgeline.outPath)
curl -s -o /dev/null -w '%{http_code}\n' "https://zmre.cachix.org/$(basename "$p" | cut -d- -f1).narinfo"
# 200 = cached, 404 = a consumer would have to build it
Cachix garbage-collects, so a 404 for a path CI is known to have pushed means it has been
evicted since, not that the push failed. Check the cache’s retention/quota settings at
app.cachix.org/cache/zmre before assuming the workflow is
broken.
Continuous integration
.github/workflows/ci.yml runs on every push to main and on every PR.
Each job installs Nix with DeterminateSystems/determinate-nix-action@v3 and
sets up cachix/cachix-action@v17 (cache zmre, pulling nix-community
too). The jobs are:
| Job | Runner(s) | Command |
|---|---|---|
format-check | ubuntu | nix build -L .#fmt (runs first) |
clippy | ubuntu | nix build -L .#clippy |
tests | ubuntu | nix build -L .#tests, which also runs both shells’ CSP tests against the real SPAs (+ pushes the Linux ci-profile deps layer) |
build | ubuntu | nix build -L .#linuxDist (both apps) (+ pushes the Linux release and invoicer deps layers; pushes and pins release artifacts on main) |
macos | macos-15 | one nix build -L --no-link --keep-going .#tests .#clippy .#macDist .#invoicerMacApp (+ pushes the three darwin deps layers; pushes and pins release artifacts on main) |
spa | ubuntu | bun install --frozen-lockfile, then bun run build, bun run test:unit, bun run check and bun run lint in web/ and invoicer/web/, and test:unit, check and lint in packages/ui/ |
e2e | ubuntu | one nix build -L .#ledgelineWithSpa .#invoicerWithSpa, then the vitest contract suites against a live engine, bun run test:e2e in web/ and bun run test:e2e in invoicer/web/ (timeout-minutes: 120) |
No job builds the placeholder-SPA .#ledgeline. It is a separate release-profile
LTO compile from ledgelineWithSpa, and linuxDist / macDist already prove the GUI deps
link. nix flake check still builds it.
macOS is a single job because GitHub’s free macOS runners are slow (an M1 with 3 CPUs and
7 GB) and three separate macOS jobs each fetched, or rebuilt, the same deps layer. One
nix build realises it once and builds the rest in parallel on top of it.
clippy, tests, build, and macos depend on format-check and share the crane
dependency layer (populated once, then pulled from Cachix on later runs). The
e2e job builds .#ledgelineWithSpa and .#invoicerWithSpa in one invocation (they
share the release deps layer), runs the vitest contract suites against the engine, then
Ledgeline’s Playwright specs and then the invoicer’s (invoicer/web/e2e, what
just invoicer-e2e runs locally, on ports 5197–5199 and 4273). The invoicer’s suite runs
even when Ledgeline’s failed, so one red suite does not hide the other. Its 120-minute
timeout covers a cold release deps layer plus both suites. The invoicer’s suite is in CI
only, not just pre-push. versions, plus audit and spa-audit (called from audit.yml),
make up the rest of the ten jobs. All of them run on pull_request and none is conditional, so all of them gate merges.
.github/workflows/ci-rerun.yml runs every 30 minutes and re-runs CI runs that failed only
because GitHub never assigned a runner. That means every cancelled or failed job has no step that
started, the run is still the newest CI run for its branch, and it is on attempt 1 or 2. Real
failures and runs superseded by a newer push are left alone. Scheduled workflows run only
from the default branch, so it does nothing on an unmerged branch; trigger it by hand with
dry_run to see what it would do.
bun run test:unit runs BOTH of the SPA’s vitest projects, unit (node, pure
functions) and components (jsdom, mounted *.svelte.test.ts). Neither needs an
engine or a browser. See web/README.md for which to write and why.
just pre-push is the local version of that gate. It runs version-check, spa-hash-check, audit, engine-check, lint, check, test, test-integration, engine-test and e2e, cheapest first so it fails fast. It takes a couple of minutes on a warm cargo cache and several on a cold one, which is less than waiting twenty minutes for a red PR to report the same failure. The pre-push hook runs it (see above). just lint (prettier plus eslint over web/, packages/ui and invoicer/web) is also gated by CI’s spa job.
Two kinds of failure used to reach CI because a laptop couldn’t see them:
- New advisories. The
auditandspa-auditjobs go red when an advisory is published, with no commit from us. They are in.github/workflows/audit.yml.ci.ymlcalls it on every PR, and it also runs daily onmain, so drift shows up there first. The ignore lists, and the reason for each entry, are inscripts/audit.sh, whichjust auditshares. When a new advisory has a patch release, bump the lockfile instead of adding an ignore. See the note at the end of thespa_auditcomment in that script. - A stale
spaNodeModulespin. A Mac can’t build the Linux tree, sojust spa-hash-checkfails whenbun.lockchanged sinceorigin/mainbut the aarch64-darwin or x86_64-linux pin didn’t.just repin-spa-hashesfixes it. It builds aarch64-darwin locally and x86_64-linux on$LEDGELINE_LINUX_STORE(defaultssh-ng://avalon).