Skip to content

Instantly share code, notes, and snippets.

@o-az
Last active February 7, 2024 06:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save o-az/027d34b896e50a5cd50400e911d4bae9 to your computer and use it in GitHub Desktop.
Save o-az/027d34b896e50a5cd50400e911d4bae9 to your computer and use it in GitHub Desktop.
All possible fields

Based on the Nix expression from https://github.com/NixOS/nixpkgs/blob/master/pkgs/build-support/node/build-npm-package/default.nix, the buildNpmPackage function takes the following fields as inputs:

  • name: The name of the package. It defaults to a combination of pname and version from args.
  • src: The source of the package if it's a single source. Defaults to null.
  • srcs: The sources of the package if there are multiple. Defaults to null.
  • sourceRoot: The root directory of the source. Defaults to null.
  • prePatch: Commands to run before applying patches. Defaults to an empty string.
  • patches: A list of patches to be applied to the source. Defaults to an empty list.
  • postPatch: Commands to run after applying patches. Defaults to an empty string.
  • nativeBuildInputs: A list of native build dependencies. Defaults to an empty list.
  • buildInputs: A list of build dependencies. Defaults to an empty list.
  • npmDepsHash: The output hash of the dependencies for the project. It can be calculated in advance with prefetch-npm-deps. Defaults to an empty string.
  • forceGitDeps: Whether to force the usage of Git dependencies that have install scripts but not a lockfile. Use with care. Defaults to false.
  • makeCacheWritable: Whether to make the cache writable prior to installing dependencies. Defaults to false.
  • npmBuildScript: The script to run to build the project. Defaults to "build".
  • npmFlags: Flags to pass to all npm commands. Defaults to an empty list.
  • npmInstallFlags: Flags to pass to npm ci. Defaults to an empty list.
  • npmRebuildFlags: Flags to pass to npm rebuild. Defaults to an empty list.
  • npmBuildFlags: Flags to pass to npm run ${npmBuildScript}. Defaults to an empty list.
  • npmPackFlags: Flags to pass to npm pack. Defaults to an empty list.
  • npmPruneFlags: Flags to pass to npm prune. Defaults to the same as npmInstallFlags.
  • npmWorkspace: Value for npm --workspace flag and directory in which the files to be installed are found. Defaults to null.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment