nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at python-updates 88 lines 3.7 kB view raw view rendered
1> [!IMPORTANT] 2> There is currently an active project to [remove packages from `nodePackages`](https://github.com/NixOS/nixpkgs/issues/229475). 3> Please consider adding new packages using [another method](https://nixos.org/manual/nixpkgs/unstable/#javascript-tool-specific). 4 5This folder contains a generated collection of [npm packages](https://npmjs.com/) that can be installed with the Nix package manager. 6 7As a rule of thumb, the package set should only provide _end-user_ software packages, such as command-line utilities. 8Libraries should only be added to the package set if there is a non-npm package that requires it. 9 10When it is desired to use npm libraries in a development project, use the `node2nix` generator directly on the `package.json` configuration file of the project. 11 12The package set provides support for the official stable Node.js versions. 13The latest stable LTS release in `nodePackages`, as well as the latest stable current release in `nodePackages_latest`. 14 15If your package uses native addons, you need to examine what kind of native build system it uses. Here are some examples: 16 17- `node-gyp` 18- `node-gyp-builder` 19- `node-pre-gyp` 20 21After you have identified the correct system, you need to override your package expression while adding the build system as a build input. 22For example, `dat` requires `node-gyp-build`, so we override its expression in [pkgs/development/node-packages/overrides.nix](https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/node-packages/overrides.nix): 23 24```nix 25{ 26 dat = prev.dat.override (oldAttrs: { 27 buildInputs = [ 28 final.node-gyp-build 29 pkgs.libtool 30 pkgs.autoconf 31 pkgs.automake 32 ]; 33 meta = oldAttrs.meta // { 34 broken = since "12"; 35 }; 36 }); 37} 38``` 39 40### Adding and updating JavaScript packages in Nixpkgs 41 42To add a package from npm to Nixpkgs: 43 441. Modify [pkgs/development/node-packages/node-packages.json](https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/node-packages/node-packages.json) to add, update or remove package entries to have it included in `nodePackages` and `nodePackages_latest`. 452. Run the script: 46 47 ```sh 48 ./pkgs/development/node-packages/generate.sh 49 ``` 50 513. Build your new package to test your changes: 52 53 ```sh 54 nix-build -A nodePackages.<new-or-updated-package> 55 ``` 56 57 To build against the latest stable current Node.js version (e.g. 18.x): 58 59 ```sh 60 nix-build -A nodePackages_latest.<new-or-updated-package> 61 ``` 62 63 If the package doesn't build, you may need to add an override as explained above. 644. If the package's name doesn't match any of the executables it provides, add an entry in [pkgs/development/node-packages/main-programs.nix](https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/node-packages/main-programs.nix). This will be the case for all scoped packages, e.g., `@angular/cli`. 655. Add and commit all modified and generated files. 66 67For more information about the generation process, consult the [README.md](https://github.com/svanderburg/node2nix) file of the `node2nix` tool. 68 69To update npm packages in Nixpkgs, run the same `generate.sh` script: 70 71```sh 72./pkgs/development/node-packages/generate.sh 73``` 74 75#### Git protocol error 76 77Some packages may have Git dependencies from GitHub specified with `git://`. 78GitHub has [disabled unencrypted Git connections](https://github.blog/2021-09-01-improving-git-protocol-security-github/#no-more-unauthenticated-git), so you may see the following error when running the generate script: 79 80``` 81The unauthenticated git protocol on port 9418 is no longer supported 82``` 83 84Use the following Git configuration to resolve the issue: 85 86```sh 87git config --global url."https://github.com/".insteadOf git://github.com/ 88```