···375375 pnpmRoot = "frontend";
376376```
377377378378+### Yarn {#javascript-yarn}
379379+380380+Yarn based projects use a `yarn.lock` file instead of a `package-lock.json` to pin dependencies. Nixpkgs provides the Nix function `fetchYarnDeps` which fetches an offline cache suitable for running `yarn install` before building the project. In addition, Nixpkgs provides the hooks:
381381+382382+- `yarnConfigHook`: Fetches the dependencies from the offline cache and installs them into `node_modules`.
383383+- `yarnBuildHook`: Runs `yarn build` or a specified `yarn` command that builds the project.
384384+385385+An example usage of the above attributes is:
386386+387387+```nix
388388+{
389389+ lib,
390390+ stdenv,
391391+ fetchFromGitHub,
392392+ fetchYarnDeps,
393393+ yarnConfigHook,
394394+ yarnBuildHook,
395395+ nodejs,
396396+ npmHooks,
397397+}:
398398+399399+stdenv.mkDerivation (finalAttrs: {
400400+ pname = "...";
401401+ version = "...";
402402+403403+ src = fetchFromGitHub {
404404+ owner = "...";
405405+ repo = "...";
406406+ rev = "v${finalAttrs.version}";
407407+ hash = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";
408408+ };
409409+410410+ yarnOfflineCache = fetchYarnDeps {
411411+ yarnLock = finalAttrs.src + "/yarn.lock";
412412+ hash = "sha256-mo8urQaWIHu33+r0Y7mL9mJ/aSe/5CihuIetTeDHEUQ=";
413413+ };
414414+415415+ nativeBuildInputs = [
416416+ yarnConfigHook
417417+ yarnBuildHook
418418+ # Needed for executing package.json scripts
419419+ nodejs
420420+ npmHooks.npmInstallHook
421421+ ];
422422+423423+ meta = {
424424+ # ...
425425+ };
426426+})
427427+```
428428+429429+Note that there is no setup hook for installing yarn based packages - `npmHooks.npmInstallHook` should fit most cases, but sometimes you may need to override the `installPhase` completely.
430430+431431+#### `yarnConfigHook` arguments {#javascript-yarnconfighook}
432432+433433+By default, `yarnConfigHook` relies upon the attribute `${yarnOfflineCache}` (or `${offlineCache}` if the former is not set) to find the location of the offline cache produced by `fetchYarnDeps`. To disable this phase, you can set `dontYarnInstallDeps = true` or override the `configurePhase`.
434434+435435+#### `yarnBuildHook` arguments {#javascript-yarnbuildhook}
436436+437437+This script by default runs `yarn --offline build`, and it relies upon the project's dependencies installed at `node_modules`. Below is a list of additional `mkDerivation` arguments read by this hook:
438438+439439+- `yarnBuildScript`: Sets a different `yarn --offline` subcommand (defaults to `build`).
440440+- `yarnBuildFlags`: Single string list of additional flags to pass the above command, or a Nix list of such additional flags.
441441+378442### yarn2nix {#javascript-yarn2nix}
443443+444444+WARNING: The `yarn2nix` functions have been deprecated in favor of the new `yarnConfigHook` and `yarnBuildHook`. Documentation for them still appears here for the sake of the packages that still use them. See also a tracking issue [#324246](https://github.com/NixOS/nixpkgs/issues/324246).
379445380446#### Preparation {#javascript-yarn2nix-preparation}
381447