Development
Dependencies and locks
How uv.lock and each app's yarn.lock carry the contract from development to production, what a stale lock looks like, and how the node-locks fallback works.
On this page
Two kinds of lock file carry the contract between the developer's imperative commands and the declarative Nix build. You commit both.
| Developer (imperative) | Nix build (declarative) |
|---|---|
uv add and uv sync | uv2nix reads uv.lock. |
yarn add and yarn install | The app's yarn.lock becomes one fetchurl per tarball, then yarn install --offline. For an app that ships none, node-locks/<APP>/yarn.lock from bench-update --node-locks is used. |
bench build | builtBench runs bench build in the sandbox. |
edits to apps/* source | benchRoot and builtBench copy the source tree. |
bench-get-app, bench-remove-app, bench-update --pull | benchRoot regenerates sites/apps.{txt,json} from the members. |
Commit uv.lock, each app's yarn.lock (in the app), sites/apps.json, and node-locks/ for the apps that have no yarn.lock of their own. The production environment, node_modules, compiled assets, app registry, containers and NixOS deployment are all rebuilt from them.
In app mode the left column is the same, but the right one reads the inputs rather than the checkout. nix/uv.lock, and nix/node-locks/ for pins without a yarn.lock, are what you commit, and nix run .#relock is what writes them. The source builtBench copies is the pinned flake input, not the writable copy the dev shell put in .frappe-nix/bench/apps/. So an edit made inside that copy is a dev-only edit by construction. The app you are developing is the one exception, because it is your repository and nix build reads it the same way the shell does.
Python: uv.lock
apps/* are git submodules, and uv.lock is a committed, resolved snapshot of what they all declare. When an app gains a dependency, run uv lock in the shell. bench-update --pull does it for you when any app's pyproject.toml moved, so the pull that causes the drift also resolves it. Commit uv.lock together with the submodule bumps.
A stale uv.lock is an evaluation error
Move an app to a commit whose pyproject.toml gained a dependency and the two disagree. uv2nix then looks up a name the lock never recorded, and the bench fails to evaluate:
error: attribute 'json-repair' missing
at …/uv2nix/build/lib/resolvers.nix:123:23Three things keep that from being a puzzle:
bench-update --pullre-locks. It runsuv lockwhen any app'spyproject.tomlmoved, and regenerates the fallback lock of any app without ayarn.lockwhosepackage.jsonmoved.The error says so. Before uv2nix resolves anything, frappe-nix audits every declared requirement against the set the resolver will index (
lib/python.nix, on python-devops-nix'slib.python.lockAudit) and names the app, the requirement and the fix. Marker-gated and direct-URL requirements are left alone, because they can sit outside a resolution legitimately and a false alarm would be worse than the raw error it replaces. The production environment is audited without the root'sbench-devgroup, which it does not install (see Apps' dev dependencies).nix run .#relockworks when nothing else does. This class of failure blocks evaluation, so the dev shell that carriesuvis exactly what you cannot open. Therelockapp is deliberately outside every other output's dependency graph and takes itsuvfrom nixpkgs, so it still runs.
relock
relock is frappe-nix's one command for re-locking. It regenerates everything a repository commits on frappe-nix's behalf, uv.lock (with the managed build-dependency block) and the fallback locks in node-locks/. Outside the shell it is nix run .#relock. Inside a bench's shell it is also relock, the same program, run from the bench root wherever you type it.
nix run .#relock # uv.lock, then node-locks/
nix run .#relock -- --uv-only # only the Python half
nix run .#relock -- --node-locks # only the fallback locks
nix run .#relock -- --node-locks hrms/frontend # force a fallback over the yarn.lock a target ships
nix run .#relock -- --upgrade-package frappe # any other flag goes to `uv lock`In a bench, nix run .#relock must run from the bench root (it checks for pyproject.toml and apps/). Before it locks, it reconciles pyproject.toml with what this frappe-nix expects of a bench root, as the shell does on entry: it adds what is missing and changes nothing already there. Every lock frappe-nix runs (relock, bench-update --pull, update-deps and the shell-entry reconcile) is uv lock --upgrade-package frappe-runtime, so the runtime's dependency ranges never stay at the revision the bench first locked. The refresh lands on the frappe-nix revision flake.lock pins, not on the head of frappe-nix's branch: for that one lock the runtime's git source gets that rev, and it is taken back out of pyproject.toml and uv.lock afterwards. Locking the same flake.lock twice gives the same uv.lock, and the runtime's entry moves with nix flake update frappe-nix. Without a GitHub frappe-nix input in flake.lock (a path: override, a fork) the lock takes the branch head, as before. In app mode it assembles the workspace itself, writes nix/uv.lock and the fallback locks back into the repository, and stages them.
The other commands that re-lock do a part of this. bench-update --pull re-locks what a pull moved, bench-update --node-locks is relock --node-locks, and update-deps is relock --uv-only followed by uv sync, yarn install in every app, and the fallback locks.
In app mode the cause is nix flake update and not a submodule bump, and the fix is nix run .#relock and not uv lock. The workspace root there is generated into the store, so there is no bench root of yours to run uv in. The audit says that instead. relock is also how the first lock is produced: a repository with no nix/uv.lock cannot evaluate the dev shell either, and the error names the command.
Corrected upstream metadata
When a published package declares requirements that cannot be met alongside Frappe, the bench template carries a [[tool.uv.dependency-metadata]] entry that corrects them, and the reconcile adds it to existing benches by package name. If a bench has its own entry for the same package, that entry wins. App mode renders its root from the same template.
There is one entry today, for pypika-stubs. It is reached through frappe's dev extra, which uv locks for every workspace member. Its only release caps pypika<0.49, and Frappe 16.53 moved its PyPika fork to 0.51.1. The entry drops the cap and keeps the package, which holds only type hints. Without it, uv lock fails with "frappe[dev] depends on pypika>=0.48.9,<0.49.0".
Apps' dev dependencies
An app lists what its tests need beyond its runtime requirements under [tool.bench.dev-dependencies], a table of name = "specifier". Frappe lists freezegun, Faker, hypothesis, responses and a few more, and ERPNext's tests import freezegun, so an app whose tests import theirs needs them too. A conventional bench installs them with bench setup requirements --dev. Here a package has to be in uv.lock to be in the environment, so the bench root declares them as a dependency group of its own, bench-dev, and uv resolves them with everything else:
[dependency-groups]
dev = [ … ] # yours, and frappe-nix's dev tools
bench-dev = [ # derived from the apps; do not edit
"faker~=18.10.1",
"freezegun~=1.5.5",
"hypothesis~=6.77.0",
]Each specifier is read the way bench reads it: a bare version is an exact pin ("1.5.5" is ==1.5.5), anything else is used as written, an environment marker after a ; included. A name may carry extras ("moto[s3]"). When two apps name the same package, the entry carries both specifiers and the extras of both. Under different markers they stay two entries. A package the dev group already names (coverage, responses, unittest-xml-reporting) is left to that group's pin. An entry that is not a package name and a string of version specifiers, such as a direct URL or a table, is skipped with a warning that names the app. The dev environment installs every group of the root, an entry behind a marker only where the marker holds, and the production environment installs none.
When two apps pin a package in ways no version satisfies, uv lock fails. In a bench the shell-entry reconcile then puts pyproject.toml and uv.lock back on every entry, so nothing else it would change lands either. Editing bench-dev does not help, because the next reconcile rewrites it. Pin the package in dev instead: bench-dev leaves out any package that dev names. An entry in [tool.uv].override-dependencies works too, and also reaches the apps' own requirements.
The group is rewritten from the apps whenever they change: by bench-get-app, bench-new-app and bench-remove-app, before the lock in bench-update --pull, update-deps and nix run .#relock, and otherwise by the shell-entry reconcile, which re-locks when it moved. Keep a bench's own dev tools in dev, which nothing rewrites. While an app registered in the workspace is missing from apps/, or has no pyproject.toml there (a submodule that is not checked out), the group is left as it is, with a warning naming the app.
In app mode the generated root has the group when the app has opted in to the app standards. The root of an app that has not opted in keeps only the entries its committed nix/uv.lock already lists in that group, which for any lock frappe-nix wrote before the group existed is none (spec S35). That app's root and lock stay as they were.
Build dependencies
A package uv.lock has no wheel for is built from its sdist, in the Nix sandbox, with only the build dependencies uv2nix is told about. An old sdist often declares none, so pyproject.toml names them under [tool.uv.extra-build-dependencies]. That table is derived from uv.lock rather than kept by hand (python-devops-nix's lib.python.buildDeps, wrapped by lib/build-deps.nix):
[tool.uv.extra-build-dependencies]
# >>> frappe-nix: sdist build deps (managed) >>>
"cairocffi" = ["setuptools", "cffi", "pycparser"]
"docopt" = ["setuptools"]
"frappe-runtime" = ["hatchling"]
# <<< frappe-nix: sdist build deps (managed) <<<Every package the lock has no wheel for gets
setuptools.frappe-nix adds two entries whatever the lock says:
frappe-runtime(hatchling) andcairocffi(cffiandpycparser).A bench adds its own with the
pythonBuildDependenciesoption, for a sdist that needs more than setuptools, such asfuuid = [ "poetry-core" ];. An entry there replaces the derived one.
The lines between the markers are rewritten after every uv lock frappe-nix runs: nix run .#relock, bench-update --pull, update-deps, bench-get-app, bench-new-app, bench-remove-app, the shell-entry reconcile and frappe-init. After a uv lock of your own, run frappe-nix-build-deps update (it is on the shell's PATH); frappe-nix-build-deps check exits 1 when the block is out of date. uv.lock itself does not record these entries, so it does not change.
In app mode the root pyproject.toml is generated, and its block is derived from nix/uv.lock at evaluation.
Moving a bench to the derived list
A bench scaffolded before the block keeps the list it was given, about 100 hand-kept entries, untouched: a relock prints a one-line hint and changes nothing. The list keeps working. Most of its entries are for packages that now ship wheels, so it is mostly noise, and it never gains an entry for a new sdist-only dependency.
To move:
Note the entries in
[tool.uv.extra-build-dependencies]that are not["setuptools"]and that frappe-nix does not add itself (frappe-runtime,cairocffi). Put each in the flake aspythonBuildDependencies, for examplejsonata = [ "setuptools" "pybind11" ];. Leave out one whose package has a wheel inuv.lock: uv2nix does not build it.Replace every entry of the table with the two marker lines:
[tool.uv.extra-build-dependencies] # >>> frappe-nix: sdist build deps (managed) >>> # <<< frappe-nix: sdist build deps (managed) <<<An entry left outside the markers for a package the block also lists makes
pyproject.tomlinvalid TOML (a key defined twice).nix run .#relock, then commitpyproject.toml.
The derivations of packages installed from a wheel change once (uv2nix adds a package's extra build dependencies to a wheel's build inputs too, and the stock list named many wheels), so the next deploy rebuilds the environment.
Packages built from a source tree
The apps, and any other package the lock installs from a directory, are built by frappe-nix itself (lib/python.nix), not from an index, and a few things hold for them that do not for a wheel or an sdist.
editables. The development virtualenv installs each one editable. hatchling's editable build importseditablesbut reports it only at build time, so neither the package's[build-system].requiresnoruv.locknames it, and a package built with hatchling died onNo module named 'editables'. frappe-nix provides it to every editable install, so a hatchling-built app needs no[tool.uv.extra-build-dependencies]entry for it. Frappe's flow harness (frappe-flow, atflow/harnessin the Frappe checkout from 16.60, and on develop) is the first such package, and any local package gets it, adirectorysource as much as aneditableone.A web UI built by a build hook. The production build has no network, so a hook that runs
npm cicannot. frappe-nix builds the flow harness's UI on its own (lib/flow-web-ui.nix), offline, fromflow/harness/ui/package-lock.json, with the samenpm run build -w appthe hook runs, and gives the package the result with a minimalPKG-INFO(its name and version), which the hook takes for a source distribution that already carries its UI. It is built from the manifests and the UI's own sources, so an edit to the harness's Python does not rebuild it. The development virtualenv builds no UI. A harness that is not laid out this way is left as the lock has it.Node and npm. Node (
frappe-nix.nodejs) and npm are in the production build of each of these packages, as a fallback for a build hook that works from what the tree already holds. There is still no registry: a hook that installs fails, and the fix is to build what it needs beforehand, as above. Wheels and sdists from an index do not get Node, so their derivations do not change. Changingfrappe-nix.nodejsrebuilds these packages.App mode. A package nested inside an app, such as the flow harness inside Frappe, is taken from the same input as the app (
apps/frappeis a mirror there, whose links dangle in the sandbox).
macOS wheels for a newer macOS
A wheel's macosx_<major>_<minor> tag is the oldest macOS it runs on, and the Python build takes a macOS wheel only up to nixpkgs' SDK (stdenv.targetPlatform.darwinSdkVersion, 14.4 in 2026-12). Some packages publish their macOS wheels for recent releases only: plutoprint 0.23 (which Frappe 16 requires on Apple silicon) and opencv-python-headless 5.1 ship macosx_15_0_arm64 alone. Without a wheel it accepts, the build falls back to the sdist, and those are native builds the sandbox cannot do, so the dev shell failed to build on every Mac.
So on a Mac, a package whose lock has no wheel the SDK accepts, but has one for a newer macOS on the same architecture and Python, is installed from that wheel (python-devops-nix's lib.python.newerMacosWheels, composed in lib/python.nix). It always applies on a Mac and never elsewhere. It is the same choice the build makes, with no macOS floor, and it comes from the lock's tags alone: no package is named. A package with a wheel the SDK takes, or with no macOS wheel at all, is built as before, and nothing changes on Linux. A Mac older than such a wheel's tag fails when it imports the package rather than when it builds the environment; it could not build that environment before either.
Node: each app's yarn.lock
Each app with a package.json, and each nested frontend under it, is a node target. A nested frontend is an immediate subdirectory with its own package.json, such as erpnext/banking, hrms/frontend or commit/dashboard. A directory one level further down, such as frappe/studio/frontend, is a target only when it ships a yarn.lock or pnpm-lock.yaml of its own beside its package.json. A subdirectory the app tracks as a git submodule, such as hrms/frappe-ui, is a project of its own and is skipped.
Each target gets a node_modules in the bench package, built from the target's own yarn.lock, or its pnpm-lock.yaml for an app that has moved to pnpm (below). Nothing about it is committed to the bench or computed by hand.
python-devops-nix's
lib.node.yarnLock(it waslib/yarn-lock.nixhere) reads the lock at evaluation time and turns every tarball in it into onefetchurl, by the URL and theintegritythe lock already states, or the#sha1on the URL in an older lock. A git dependency is fetched by its commit withbuiltins.fetchGitat evaluation time, so a cold cache needs the repository reachable the first time anything forces the package,nix flake check --no-buildincluded. It is then packed the way nixpkgs'prefetch-yarn-depspacks it.The fetched tarballs are linked into an offline mirror under the names nixpkgs'
fixup-yarn-lockrewrites the lock to, and nixpkgs' ownyarnConfigHookinstalls from it:yarn install --offline --frozen-lockfile --ignore-scripts --ignore-engines --ignore-platform. This is what nixpkgs does for any yarn 1 project, minusfetchYarnDeps, the one fixed-output derivation over the whole mirror whose hash had to be mined out of a failing build.The derivation sees only the target's
package.json,yarn.lock,.yarnrcand.npmrc. A change to anything else in the app does not rebuild itsnode_modules, and an upstreamyarn.lockbump refetches only what moved.
Lifecycle scripts are not run in the sandbox. Every native piece a Frappe frontend needs is a platform package or a prebuilt binary, and all platforms' optional binaries are fetched, since they are in the lock.
nodeOverrides.<TARGET> is merged into that target's derivation: postPatch, nativeBuildInputs, preInstall, or a yarnOfflineCache of your own. The install flags are the hook's.
In the bench tree each target's node_modules is a real directory of links into the store, not a link to the store's directory. Vite creates node_modules/.vite-temp while bundling an ESM vite.config, and only a permission error is tolerated: the sandbox's read-only store answers EROFS.
link: dependencies
A target may depend on a directory of the source tree instead of a package: "@framework/ui": "link:../ui" in frappe/flow, "link:../../frappe/ui" in erpnext/islands. yarn installs such a dependency as a symlink, and the store's node_modules cannot hold a link to the bench tree. For a target with one:
The install sees the linked package's
package.jsonat the path the link names, as well as the target's own manifests. yarn installs a linked package's dependencies into the target, and without that file it leaves them out without a word. The file is cut down to the name and the dependencies the target's lock has an entry for. An upstream lock can be older than the linked package's newest dependency, and offline one missing entry fails the install. A dependency left out this way is named in the build log. The linked package still resolves it, from its ownnode_modules, since it is a target too.The link is made in the bench tree, with the relative text yarn writes (
node_modules/@framework/ui -> ../../../ui), and its scope is a real directory there. The store's copy carries no link.The link has to stay inside
apps/, in an app the bench has.erpnext/islandsneedsfrappe; a bench without the linked app is an evaluation error that says so.A
patch-packagepostinstall that reads its patches through a link is applied by the install. Forpatch-package --patch-dir node_modules/<LINK>/<DIR>, the patches in that directory are applied to the target'snode_moduleswithpatch, and a patch that does not apply fails the derivation. It is the one lifecycle script that is honoured, because nothing else can do it: in the bench tree the packages are the store's.node_modules/.yarn-integritynames the lock as the app ships it. The offline install runs on a copy of the lock rewritten to mirror file names, and yarn records what it installed from. Each entry'sresolvedis put back, and the derivation then runsyarn check --integrityagainst the app's lock and fails if yarn disagrees. Frappe's build asks yarn the same question.
A target with a link: dependency cannot take a generated lock from node-locks/: it builds from the yarn.lock it ships.
bench build is unchanged: yarn run production, then yarn build in every app with a build script. The dev shell is unchanged too. Its node_modules is a plain online yarn install, as upstream tooling expects. See The development shell.
pnpm apps
An app whose lockfile is pnpm-lock.yaml is installed with pnpm, by python-devops-nix's lib.node (its JavaScript conventions, the rules odoo-nix follows too). frappe/pilot's deploys follow the same rules (frappe/pilot#617).
The pnpm version.
package.json'spackageManager, ordevEngines.packageManager(the form a pnpm app uses, since yarn 1 refusespackageManager), names the major, and nixpkgs provides thatpnpm_<major>. Without either, the currentpnpmis used. The same pnpm is on the dev shell's PATH. pnpm never switches itself to the exact versiondevEnginesnames, in the sandbox or in the shell (pnpm_config_pm_on_fail=ignore).The install. It is offline and frozen. pnpm2nix-nzbr turns the lock into one fetch per package, by the integrity the lock records. pnpm 11+ writes two YAML documents into the lock when
devEnginespins pnpm; only the project's document, the last one, is read. The derivation sees only the manifests:package.json, the lock,pnpm-workspace.yaml(itsoverridesandallowBuildsincluded),.npmrcand each workspace member'spackage.json.Workspace members. A nested frontend without a lock of its own that the app's
pnpm-lock.yamllists underimporters:is a member of the app's workspace. It is installed with the app, once, and is not a target of its own. A member's links to another member point at that member's code in the bench tree.Two lockfiles. A
pnpm-lock.yamlnext to ayarn.lockis an evaluation error, and the dev shell refuses it too. Delete the one the app no longer uses.Building.
bench buildstill runsyarn buildin the app. That works for a pnpm app whose build script is a plain command (suite's isvite build), because the node_modules is already there. A build script that callspnpmfinds it on PATH.
The node-locks/ fallback below is yarn's: an app that has no lockfile of its own is resolved with yarn.
pnpm2nix reads the lock by import-from-derivation (a derivation converts it to JSON at evaluation time). Only a pnpm app pays that cost. CI's nix flake check --no-build has to realise it first, the same way it does for the dev shell's own IFD.
The fallback: node-locks/
An app that ships a package.json but no yarn.lock has nothing to build from, and evaluation says so. bench-update --node-locks resolves one for it: yarn install in a scratch directory holding nothing but the manifests, on the developer's machine, with the network. It writes the result to node-locks/<APP>/yarn.lock, or nix/node-locks/ in app mode from nix run .#relock, with a stamp of the package.json it came from.
Commit it. The target builds from it exactly as it would from its own lock.
bench-updateandbench-update --pullregenerate the fallbacks whosepackage.jsonmoved during the pull. The stamp makes the others free.update-depsrefreshes them after itsyarn installruns.Evaluation warns about a fallback that is older than its manifest.
An app that ships a
yarn.lockgets no fallback. One it once needed is reported as unused when the app grows a lock upstream. Remove it withgit rm -r.
After a migration, if any app ships a package.json without a yarn.lock, run bench-update --node-locks inside the dev shell before the first nix build. The migration does not generate the fallback, because it needs the network and yarn.
A yarn.lock that cannot resolve offline
Occasionally an upstream lock does not cover its own package.json, for example a dependency bump that never regenerated the transitive entries. The offline install then fails with:
Couldn't find any versions for "<PACKAGE>" that matches "<RANGE>" in our cacheThe build log names the remedies next to that line. There are two.
Leave the frontend out. Set nodeNestedFrontendExcludes = [ "<APP>/<SUBDIR>" ];. The frontend gets no node_modules and no assets. A nested frontend is usually built by its parent app's build script (cd banking && yarn build), and Frappe's esbuild runs every app's build script with no opt-out, so the parent's build and postinstall scripts that name the frontend are dropped from the bench tree's package.json too. The build log says so per script.
Force a fallback. Run bench-update --node-locks <APP>/<SUBDIR>. It resolves a lock seeded from upstream's own: its pins stay and only the gap is filled from the registry. The lock is stamped forced, and that target builds from node-locks/<APP>/<SUBDIR>/yarn.lock instead of the upstream file. A forced lock follows the upstream yarn.lock on --pull, the way the others follow package.json.
Nested frontends are discovered one level deep, and one level further when they ship their own lockfile. Excluding a directory also leaves out the targets under it.
Excluding a frontend disarms a package.json script that names it. It does not disarm a build that Frappe starts itself: Frappe 16.60 and later install and build frappe/flow, frappe/island-toolchain and frappe/studio/frontend from its own build code, whatever the excludes say.
Coming from the earlier schemes
nodeOfflineHashes and node-offline-hashes.json are gone. The option is an error, so it cannot linger silently. So are the node-locks/<APP>/package-lock.json directories of the interim npm-based scheme: bench-update --node-locks removes those for every app that ships a yarn.lock, and generates the yarn.lock fallback for any that does not. nodeOverrides entries carrying yarnFlags or npm attributes should go too. yarnFlags was never read, and a warning says so.