From 384b1e5b91172cd9a031745266779389f6e31e02 Mon Sep 17 00:00:00 2001 From: Doron Behar Date: Mon, 2 Oct 2023 17:07:31 +0300 Subject: [PATCH] docs/javascript/buildNpmPackage: Document bin, man and npm pack behavior --- doc/languages-frameworks/javascript.section.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/doc/languages-frameworks/javascript.section.md b/doc/languages-frameworks/javascript.section.md index fb1dd898c8a2..861db3679dee 100644 --- a/doc/languages-frameworks/javascript.section.md +++ b/doc/languages-frameworks/javascript.section.md @@ -161,6 +161,8 @@ git config --global url."https://github.com/".insteadOf git://github.com/ `buildNpmPackage` allows you to package npm-based projects in Nixpkgs without the use of an auto-generated dependencies file (as used in [node2nix](#javascript-node2nix)). It works by utilizing npm's cache functionality -- creating a reproducible cache that contains the dependencies of a project, and pointing npm to it. +Here's an example: + ```nix { lib, buildNpmPackage, fetchFromGitHub }: @@ -191,6 +193,8 @@ buildNpmPackage rec { } ``` +In the default `installPhase` set by `buildNpmPackage`, it uses `npm pack --json --dry-run` to decide what files to install in `$out/lib/node_modules/$name/`, where `$name` is the `name` string defined in the package's `package.json`. Additionally, the `bin` and `man` keys in the source's `package.json` are used to decide what binaries and manpages are supposed to be installed. If these are not defined, `npm pack` may miss some files, and no binaries will be produced. + #### Arguments {#javascript-buildNpmPackage-arguments} * `npmDepsHash`: The output hash of the dependencies for this project. Can be calculated in advance with [`prefetch-npm-deps`](#javascript-buildNpmPackage-prefetch-npm-deps).