Merge pull request #171863 from malob/nodePackages-mainProgram

nodePackages: cleanup overrides and add meta.mainProgram to many packages
main
Rick van Schijndel 2 years ago committed by GitHub
commit af49adccd7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 185
      doc/languages-frameworks/javascript.section.md
  2. 555
      pkgs/development/node-packages/default.nix
  3. 74
      pkgs/development/node-packages/main-programs.nix
  4. 533
      pkgs/development/node-packages/overrides.nix

@ -8,19 +8,16 @@ The various tools available will be listed in the [tools-overview](#javascript-t
## Getting unstuck / finding code examples
If you find you are lacking inspiration for packing javascript applications, the links below might prove useful.
Searching online for prior art can be helpful if you are running into solved problems.
If you find you are lacking inspiration for packing javascript applications, the links below might prove useful. Searching online for prior art can be helpful if you are running into solved problems.
### Github
- Searching Nix files for `mkYarnPackage`: <https://github.com/search?q=mkYarnPackage+language%3ANix&type=code>
- Searching just `flake.nix` files for `mkYarnPackage`: <https://github.com/search?q=mkYarnPackage+filename%3Aflake.nix&type=code>
### Gitlab
- Searching Nix files for `mkYarnPackage`: <https://gitlab.com/search?scope=blobs&search=mkYarnPackage+extension%3Anix>
- Searching just `flake.nix` files for `mkYarnPackage`: <https://gitlab.com/search?scope=blobs&search=mkYarnPackage+filename%3Aflake.nix>
## Tools overview {#javascript-tools-overview}
@ -35,109 +32,107 @@ It is often not documented which node version is used upstream, but if it is, tr
This can be a problem if upstream is using the latest and greatest and you are trying to use an earlier version of node. Some cryptic errors regarding V8 may appear.
An exception to this:
### Try to respect the package manager originally used by upstream (and use the upstream lock file) {#javascript-upstream-package-manager}
A lock file (package-lock.json, yarn.lock...) is supposed to make reproducible installations of node_modules for each tool.
Guidelines of package managers, recommend to commit those lock files to the repos. If a particular lock file is present, it is a strong indication of which package manager is used upstream.
It's better to try to use a nix tool that understand the lock file. Using a different tool might give you hard to understand error because different packages have been installed. An example of problems that could arise can be found [here](https://github.com/NixOS/nixpkgs/pull/126629). Upstream uses npm, but this is an attempt to package it with yarn2nix (that uses yarn.lock)
It's better to try to use a Nix tool that understand the lock file. Using a different tool might give you hard to understand error because different packages have been installed. An example of problems that could arise can be found [here](https://github.com/NixOS/nixpkgs/pull/126629). Upstream use NPM, but this is an attempt to package it with `yarn2nix` (that uses yarn.lock).
Using a different tool forces to commit a lock file to the repository. Those files are fairly large, so when packaging for nixpkgs, this approach does not scale well.
Exceptions to this rule are:
- when you encounter one of the bugs from a nix tool. In each of the tool specific instructions, known problems will be detailed. If you have a problem with a particular tool, then it's best to try another tool, even if this means you will have to recreate a lock file and commit it to nixpkgs. In general yarn2nix has less known problems and so a simple search in nixpkgs will reveal many yarn.lock files committed
- Some lock files contain particular version of a package that has been pulled off npm for some reason. In that case, you can recreate upstream lock (by removing the original and `npm install`, `yarn`, ...) and commit this to nixpkgs.
- The only tool that supports workspaces (a feature of npm that helps manage sub-directories with different package.json from a single top level package.json) is yarn2nix. If upstream has workspaces you should try yarn2nix.
- When you encounter one of the bugs from a Nix tool. In each of the tool specific instructions, known problems will be detailed. If you have a problem with a particular tool, then it's best to try another tool, even if this means you will have to recreate a lock file and commit it to nixpkgs. In general `yarn2nix` has less known problems and so a simple search in nixpkgs will reveal many yarn.lock files committed.
- Some lock files contain particular version of a package that has been pulled off NPM for some reason. In that case, you can recreate upstream lock (by removing the original and `npm install`, `yarn`, ...) and commit this to nixpkgs.
- The only tool that supports workspaces (a feature of NPM that helps manage sub-directories with different package.json from a single top level package.json) is `yarn2nix`. If upstream has workspaces you should try `yarn2nix`.
### Try to use upstream package.json {#javascript-upstream-package-json}
Exceptions to this rule are
Exceptions to this rule are:
- Sometimes the upstream repo assumes some dependencies be installed globally. In that case you can add them manually to the upstream package.json (`yarn add xxx` or `npm install xxx`, ...). Dependencies that are installed locally can be executed with `npx` for cli tools. (e.g. `npx postcss ...`, this is how you can call those dependencies in the phases).
- Sometimes there is a version conflict between some dependency requirements. In that case you can fix a version (by removing the `^`).
- Sometimes the script defined in the package.json does not work as is. Some scripts for example use cli tools that might not be available, or cd in directory with a different package.json (for workspaces notably). In that case, it's perfectly fine to look at what the particular script is doing and break this down in the phases. In the build script you can see `build:*` calling in turns several other build scripts like `build:ui` or `build:server`. If one of those fails, you can try to separate those into:
- Sometimes the upstream repo assumes some dependencies be installed globally. In that case you can add them manually to the upstream package.json (`yarn add xxx` or `npm install xxx`, ...). Dependencies that are installed locally can be executed with `npx` for CLI tools. (e.g. `npx postcss ...`, this is how you can call those dependencies in the phases).
- Sometimes there is a version conflict between some dependency requirements. In that case you can fix a version by removing the `^`.
- Sometimes the script defined in the package.json does not work as is. Some scripts for example use CLI tools that might not be available, or cd in directory with a different package.json (for workspaces notably). In that case, it's perfectly fine to look at what the particular script is doing and break this down in the phases. In the build script you can see `build:*` calling in turns several other build scripts like `build:ui` or `build:server`. If one of those fails, you can try to separate those into,
```Shell
yarn build:ui
yarn build:server
# OR
npm run build:ui
npm run build:server
```
```sh
yarn build:ui
yarn build:server
# OR
npm run build:ui
npm run build:server
```
when you need to override a package.json. It's nice to use the one from the upstream src and do some explicit override. Here is an example.
when you need to override a package.json. It's nice to use the one from the upstream source and do some explicit override. Here is an example:
```nix
patchedPackageJSON = final.runCommand "package.json" { } ''
${jq}/bin/jq '.version = "0.4.0" |
.devDependencies."@jsdoc/cli" = "^0.2.5"
${sonar-src}/package.json > $out
'';
```
```nix
patchedPackageJSON = final.runCommand "package.json" { } ''
${jq}/bin/jq '.version = "0.4.0" |
.devDependencies."@jsdoc/cli" = "^0.2.5"
${sonar-src}/package.json > $out
'';
```
you will still need to commit the modified version of the lock files, but at least the overrides are explicit for everyone to see.
You will still need to commit the modified version of the lock files, but at least the overrides are explicit for everyone to see.
### Using node_modules directly {#javascript-using-node_modules}
each tool has an abstraction to just build the node_modules (dependencies) directory. you can always use the stdenv.mkDerivation with the node_modules to build the package (symlink the node_modules directory and then use the package build command). the node_modules abstraction can be also used to build some web framework frontends. For an example of this see how [plausible](https://github.com/NixOS/nixpkgs/blob/master/pkgs/servers/web-apps/plausible/default.nix) is built. mkYarnModules to make the derivation containing node_modules. Then when building the frontend you can just symlink the node_modules directory
Each tool has an abstraction to just build the node_modules (dependencies) directory. You can always use the `stdenv.mkDerivation` with the node_modules to build the package (symlink the node_modules directory and then use the package build command). The node_modules abstraction can be also used to build some web framework frontends. For an example of this see how [plausible](https://github.com/NixOS/nixpkgs/blob/master/pkgs/servers/web-apps/plausible/default.nix) is built. `mkYarnModules` to make the derivation containing node_modules. Then when building the frontend you can just symlink the node_modules directory.
## Javascript packages inside nixpkgs {#javascript-packages-nixpkgs}
The `pkgs/development/node-packages` folder contains a generated collection of
[NPM packages](https://npmjs.com/) that can be installed with the Nix package
manager.
The [pkgs/development/node-packages](https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/node-packages) folder contains a generated collection of [NPM packages](https://npmjs.com/) that can be installed with the Nix package manager.
As a rule of thumb, the package set should only provide _end user_ software
packages, such as command-line utilities. Libraries should only be added to the
package set if there is a non-NPM package that requires it.
As a rule of thumb, the package set should only provide _end user_ software packages, such as command-line utilities. Libraries should only be added to the package set if there is a non-NPM package that requires it.
When 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.
When 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.
The package set provides support for the official stable Node.js versions.
The latest stable LTS release in `nodePackages`, as well as the latest stable
Current release in `nodePackages_latest`.
The package set provides support for the official stable Node.js versions. The latest stable LTS release in `nodePackages`, as well as the latest stable current release in `nodePackages_latest`.
If your package uses native addons, you need to examine what kind of native
build system it uses. Here are some examples:
If your package uses native addons, you need to examine what kind of native build system it uses. Here are some examples:
- `node-gyp`
- `node-gyp-builder`
- `node-pre-gyp`
After you have identified the correct system, you need to override your package
expression while adding in build system as a build input. For example, `dat`
requires `node-gyp-build`, so [we override](https://github.com/NixOS/nixpkgs/blob/32f5e5da4a1b3f0595527f5195ac3a91451e9b56/pkgs/development/node-packages/default.nix#L37-L40) its expression in [`default.nix`](https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/node-packages/default.nix):
After you have identified the correct system, you need to override your package expression while adding in build system as a build input. For 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):
```nix
dat = super.dat.override {
buildInputs = [ self.node-gyp-build pkgs.libtool pkgs.autoconf pkgs.automake ];
meta.broken = since "12";
};
dat = prev.dat.override (oldAttrs: {
buildInputs = [ final.node-gyp-build pkgs.libtool pkgs.autoconf pkgs.automake ];
meta = oldAttrs.meta // { broken = since "12"; };
});
```
### Adding and Updating Javascript packages in nixpkgs
To add a package from NPM to nixpkgs:
1. Modify `pkgs/development/node-packages/node-packages.json` to add, update
or remove package entries to have it included in `nodePackages` and
`nodePackages_latest`.
2. Run the script: `./pkgs/development/node-packages/generate.sh`.
1. 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`.
2. Run the script:
```sh
./pkgs/development/node-packages/generate.sh
```
3. Build your new package to test your changes:
`cd /path/to/nixpkgs && nix-build -A nodePackages.<new-or-updated-package>`.
To build against the latest stable Current Node.js version (e.g. 14.x):
`nix-build -A nodePackages_latest.<new-or-updated-package>`
4. Add and commit all modified and generated files.
For more information about the generation process, consult the
[README.md](https://github.com/svanderburg/node2nix) file of the `node2nix`
tool.
```sh
nix-build -A nodePackages.<new-or-updated-package>
```
To build against the latest stable Current Node.js version (e.g. 18.x):
```sh
nix-build -A nodePackages_latest.<new-or-updated-package>
```
If the package doesn't build, you may need to add an override as explained above.
4. 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`.
5. Add and commit all modified and generated files.
For more information about the generation process, consult the [README.md](https://github.com/svanderburg/node2nix) file of the `node2nix` tool.
To update NPM packages in nixpkgs, run the same `generate.sh` script:
@ -148,10 +143,11 @@ To update NPM packages in nixpkgs, run the same `generate.sh` script:
#### Git protocol error
Some packages may have Git dependencies from GitHub specified with `git://`.
GitHub has
[disabled unecrypted 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:
`The unauthenticated git protocol on port 9418 is no longer supported`.
GitHub has [disabled unecrypted 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:
```
The unauthenticated git protocol on port 9418 is no longer supported
```
Use the following Git configuration to resolve the issue:
@ -165,34 +161,33 @@ git config --global url."https://github.com/".insteadOf git://github.com/
#### Preparation {#javascript-node2nix-preparation}
you will need to generate a nix expression for the dependencies
You will need to generate a Nix expression for the dependencies. Don't forget the `-l package-lock.json` if there is a lock file. Most probably you will need the `--development` to include the `devDependencies`
- don't forget the `-l package-lock.json` if there is a lock file
- Most probably you will need the `--development` to include the `devDependencies`
so the command will most likely be
`node2nix --development -l package-lock.json`
So the command will most likely be:
```sh
node2nix --development -l package-lock.json
```
[link to the doc in the repo](https://github.com/svanderburg/node2nix)
See `node2nix` [docs](https://github.com/svanderburg/node2nix) for more info.
#### Pitfalls {#javascript-node2nix-pitfalls}
- if upstream package.json does not have a "version" attribute, node2nix will crash. You will need to add it like shown in [the package.json section](#javascript-upstream-package-json)
- node2nix has some [bugs](https://github.com/svanderburg/node2nix/issues/238). related to working with lock files from npm distributed with nodejs-16_x
- node2nix does not like missing packages from npm. If you see something like `Cannot resolve version: vue-loader-v16@undefined` then you might want to try another tool. The package might have been pulled off of npm.
- If upstream package.json does not have a "version" attribute, `node2nix` will crash. You will need to add it like shown in [the package.json section](#javascript-upstream-package-json).
- `node2nix` has some [bugs](https://github.com/svanderburg/node2nix/issues/238) related to working with lock files from NPM distributed with `nodejs-16_x`.
- `node2nix` does not like missing packages from NPM. If you see something like `Cannot resolve version: vue-loader-v16@undefined` then you might want to try another tool. The package might have been pulled off of NPM.
### yarn2nix {#javascript-yarn2nix}
#### Preparation {#javascript-yarn2nix-preparation}
you will need at least a yarn.lock and yarn.nix file
You will need at least a yarn.lock and yarn.nix file.
- generate a yarn.lock in upstream if it is not already there
- `yarn2nix > yarn.nix` will generate the dependencies in a nix format
- Generate a yarn.lock in upstream if it is not already there.
- `yarn2nix > yarn.nix` will generate the dependencies in a Nix format.
#### mkYarnPackage {#javascript-yarn2nix-mkYarnPackage}
this will by default try to generate a binary. For package only generating static assets (Svelte, Vue, React...), you will need to explicitly override the build step with your instructions. It's important to use the `--offline` flag. For example if you script is `"build": "something"` in package.json use
This will by default try to generate a binary. For package only generating static assets (Svelte, Vue, React...), you will need to explicitly override the build step with your instructions. It's important to use the `--offline` flag. For example if you script is `"build": "something"` in package.json use:
```nix
buildPhase = ''
@ -200,14 +195,13 @@ buildPhase = ''
'';
```
The dist phase is also trying to build a binary, the only way to override it is with
The dist phase is also trying to build a binary, the only way to override it is with:
```nix
distPhase = "true";
```
the configure phase can sometimes fail because it tries to be too clever.
One common override is
The configure phase can sometimes fail because it tries to be too clever. One common override is:
```nix
configurePhase = "ln -s $node_modules node_modules";
@ -215,13 +209,17 @@ configurePhase = "ln -s $node_modules node_modules";
#### mkYarnModules {#javascript-yarn2nix-mkYarnModules}
this will generate a derivation including the node_modules. If you have to build a derivation for an integrated web framework (rails, phoenix..), this is probably the easiest way. [Plausible](https://github.com/NixOS/nixpkgs/blob/master/pkgs/servers/web-apps/plausible/default.nix#L39) offers a good example of how to do this.
This will generate a derivation including the node_modules. If you have to build a derivation for an integrated web framework (rails, phoenix..), this is probably the easiest way. [Plausible](https://github.com/NixOS/nixpkgs/blob/master/pkgs/servers/web-apps/plausible/default.nix#L39) offers a good example of how to do this.
#### Overriding dependency behavior
In the `mkYarnPackage` record the property `pkgConfig` can be used to override packages when you encounter problems building.
For instance, say your package is throwing errors when trying to invoke node-sass: `ENOENT: no such file or directory, scandir '/build/source/node_modules/node-sass/vendor'`
For instance, say your package is throwing errors when trying to invoke node-sass:
```
ENOENT: no such file or directory, scandir '/build/source/node_modules/node-sass/vendor'
```
To fix this we will specify different versions of build inputs to use, as well as some post install steps to get the software built the way we want:
@ -241,9 +239,8 @@ mkYarnPackage rec {
#### Pitfalls {#javascript-yarn2nix-pitfalls}
- if version is missing from upstream package.json, yarn will silently install nothing. In that case, you will need to override package.json as shown in the [package.json section](#javascript-upstream-package-json)
- having trouble with node-gyp? Try adding these lines to the `yarnPreBuild` steps:
- If version is missing from upstream package.json, yarn will silently install nothing. In that case, you will need to override package.json as shown in the [package.json section](#javascript-upstream-package-json)
- Having trouble with `node-gyp`? Try adding these lines to the `yarnPreBuild` steps:
```nix
yarnPreBuild = ''
@ -259,20 +256,20 @@ mkYarnPackage rec {
## Outside of nixpkgs {#javascript-outside-nixpkgs}
There are some other options available that can't be used inside nixpkgs. Those other options are written in nix. Importing them in nixpkgs will require moving the source code into nixpkgs. Using [Import From Derivation](https://nixos.wiki/wiki/Import_From_Derivation) is not allowed in hydra at present. If you are packaging something outside nixpkgs, those can be considered
There are some other options available that can't be used inside nixpkgs. Those other options are written in Nix. Importing them in nixpkgs will require moving the source code into nixpkgs. Using [Import From Derivation](https://nixos.wiki/wiki/Import_From_Derivation) is not allowed in Hydra at present. If you are packaging something outside nixpkgs, those can be considered
### npmlock2nix {#javascript-npmlock2nix}
[npmlock2nix](https://github.com/nix-community/npmlock2nix) aims at building node_modules without code generation. It hasn't reached v1 yet, the api might be subject to change.
[npmlock2nix](https://github.com/nix-community/npmlock2nix) aims at building node_modules without code generation. It hasn't reached v1 yet, the API might be subject to change.
#### Pitfalls {#javascript-npmlock2nix-pitfalls}
- there are some [problems with npm v7](https://github.com/tweag/npmlock2nix/issues/45).
There are some [problems with npm v7](https://github.com/tweag/npmlock2nix/issues/45).
### nix-npm-buildpackage {#javascript-nix-npm-buildpackage}
[nix-npm-buildpackage](https://github.com/serokell/nix-npm-buildpackage) aims at building node_modules without code generation. It hasn't reached v1 yet, the api might change. It supports both package-lock.json and yarn.lock.
[nix-npm-buildpackage](https://github.com/serokell/nix-npm-buildpackage) aims at building node_modules without code generation. It hasn't reached v1 yet, the API might change. It supports both package-lock.json and yarn.lock.
#### Pitfalls {#javascript-nix-npm-buildpackage-pitfalls}
- there are some [problems with npm v7](https://github.com/serokell/nix-npm-buildpackage/issues/33).
There are some [problems with npm v7](https://github.com/serokell/nix-npm-buildpackage/issues/33).

@ -1,544 +1,23 @@
{ pkgs, nodejs, stdenv, applyPatches, fetchFromGitHub, fetchpatch, fetchurl, nixosTests }:
{ pkgs, lib, nodejs, stdenv}:
let
inherit (pkgs) lib;
since = version: pkgs.lib.versionAtLeast nodejs.version version;
before = version: pkgs.lib.versionOlder nodejs.version version;
super = import ./composition.nix {
inherit (lib) composeManyExtensions extends makeExtensible mapAttrs;
nodePackages = final: import ./composition.nix {
inherit pkgs nodejs;
inherit (stdenv.hostPlatform) system;
};
self = super // {
"@angular/cli" = super."@angular/cli".override {
prePatch = ''
export NG_CLI_ANALYTICS=false
'';
};
autoprefixer = super.autoprefixer.override {
nativeBuildInputs = [ pkgs.makeWrapper ];
postInstall = ''
wrapProgram "$out/bin/autoprefixer" \
--prefix NODE_PATH : ${self.postcss}/lib/node_modules
'';
passthru.tests = {
simple-execution = pkgs.callPackage ./package-tests/autoprefixer.nix { inherit (self) autoprefixer; };
};
};
aws-azure-login = super.aws-azure-login.override {
meta.platforms = pkgs.lib.platforms.linux;
nativeBuildInputs = [ pkgs.makeWrapper ];
prePatch = ''
export PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=1
'';
postInstall = ''
wrapProgram $out/bin/aws-azure-login \
--set PUPPETEER_EXECUTABLE_PATH ${pkgs.chromium}/bin/chromium
'';
};
bower2nix = super.bower2nix.override {
buildInputs = [ pkgs.makeWrapper ];
postInstall = ''
for prog in bower2nix fetch-bower; do
wrapProgram "$out/bin/$prog" --prefix PATH : ${pkgs.lib.makeBinPath [ pkgs.git pkgs.nix ]}
done
'';
};
carbon-now-cli = super.carbon-now-cli.override {
nativeBuildInputs = [ pkgs.makeWrapper ];
prePatch = ''
export PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=1
'';
postInstall = ''
wrapProgram $out/bin/carbon-now \
--set PUPPETEER_EXECUTABLE_PATH ${pkgs.chromium.outPath}/bin/chromium
'';
};
deltachat-desktop = super."deltachat-desktop-../../applications/networking/instant-messengers/deltachat-desktop".override {
meta.broken = true; # use the top-level package instead
};
fast-cli = super.fast-cli.override {
nativeBuildInputs = [ pkgs.makeWrapper ];
prePatch = ''
export PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=1
'';
postInstall = ''
wrapProgram $out/bin/fast \
--set PUPPETEER_EXECUTABLE_PATH ${pkgs.chromium.outPath}/bin/chromium
'';
};
hyperspace-cli = super."@hyperspace/cli".override {
nativeBuildInputs = with pkgs; [
makeWrapper
libtool
autoconf
automake
];
buildInputs = with pkgs; [
nodePackages.node-gyp-build
nodejs
];
postInstall = ''
wrapProgram "$out/bin/hyp" --prefix PATH : ${
pkgs.lib.makeBinPath [ pkgs.nodejs ]
}
'';
};
mdctl-cli = super."@medable/mdctl-cli".override {
nativeBuildInputs = with pkgs; with darwin.apple_sdk.frameworks; [
glib
libsecret
pkg-config
] ++ lib.optionals stdenv.isDarwin [
AppKit
Security
];
buildInputs = with pkgs; [
nodePackages.node-gyp-build
nodePackages.node-pre-gyp
nodejs
];
};
coc-imselect = super.coc-imselect.override {
meta.broken = since "10";
};
dat = super.dat.override {
buildInputs = [ self.node-gyp-build pkgs.libtool pkgs.autoconf pkgs.automake ];
meta.broken = since "12";
};
# NOTE: this is a stub package to fetch npm dependencies for
# ../../applications/video/epgstation
epgstation = super."epgstation-../../applications/video/epgstation".override (drv: {
buildInputs = [ self.node-pre-gyp self.node-gyp-build ];
meta = drv.meta // {
platforms = pkgs.lib.platforms.none;
};
});
# NOTE: this is a stub package to fetch npm dependencies for
# ../../applications/video/epgstation/client
epgstation-client = super."epgstation-client-../../applications/video/epgstation/client".override (drv: {
meta = drv.meta // {
platforms = pkgs.lib.platforms.none;
};
});
bitwarden-cli = super."@bitwarden/cli".override (drv: {
name = "bitwarden-cli-${drv.version}";
meta.mainProgram = "bw";
});
flood = super.flood.override {
buildInputs = [ self.node-pre-gyp ];
meta.mainProgram = "flood";
};
expo-cli = super."expo-cli".override (attrs: {
# The traveling-fastlane-darwin optional dependency aborts build on Linux.
dependencies = builtins.filter (d: d.packageName != "@expo/traveling-fastlane-${if stdenv.isLinux then "darwin" else "linux"}") attrs.dependencies;
});
"@electron-forge/cli" = super."@electron-forge/cli".override {
buildInputs = [ self.node-pre-gyp self.rimraf ];
};
git-ssb = super.git-ssb.override {
buildInputs = [ self.node-gyp-build ];
meta.broken = since "10";
};
hsd = super.hsd.override {
buildInputs = [ self.node-gyp-build pkgs.unbound ];
};
ijavascript = super.ijavascript.override (oldAttrs: {
preRebuild = ''
export NPM_CONFIG_ZMQ_EXTERNAL=true
'';
buildInputs = oldAttrs.buildInputs ++ [ self.node-gyp-build pkgs.zeromq ];
});
insect = super.insect.override (drv: {
nativeBuildInputs = drv.nativeBuildInputs or [] ++ [ pkgs.psc-package self.pulp ];
});
intelephense = super.intelephense.override {
meta.license = pkgs.lib.licenses.unfree;
};
jsonplaceholder = super.jsonplaceholder.override (drv: {
buildInputs = [ nodejs ];
postInstall = ''
exe=$out/bin/jsonplaceholder
mkdir -p $out/bin
cat >$exe <<EOF
#!${pkgs.runtimeShell}
exec -a jsonplaceholder ${nodejs}/bin/node $out/lib/node_modules/jsonplaceholder/index.js
EOF
chmod a+x $exe
'';
});
makam = super.makam.override {
buildInputs = [ pkgs.nodejs pkgs.makeWrapper ];
postFixup = ''
wrapProgram "$out/bin/makam" --prefix PATH : ${pkgs.lib.makeBinPath [ pkgs.nodejs ]}
${
if stdenv.isLinux
then "patchelf --set-interpreter ${stdenv.glibc}/lib/ld-linux-x86-64.so.2 \"$out/lib/node_modules/makam/makam-bin-linux64\""
else ""
}
'';
};
manta = super.manta.override {
nativeBuildInputs = with pkgs; [ nodejs-14_x installShellFiles ];
postInstall = ''
# create completions, following upstream procedure https://github.com/joyent/node-manta/blob/v5.2.3/Makefile#L85-L91
completion_cmds=$(find ./bin -type f -printf "%f\n")
node ./lib/create_client.js
for cmd in $completion_cmds; do
installShellCompletion --cmd $cmd --bash <(./bin/$cmd --completion)
done
'';
};
markdownlint-cli = super.markdownlint-cli.override {
meta.mainProgram = "markdownlint";
};
node-gyp = super.node-gyp.override {
nativeBuildInputs = [ pkgs.makeWrapper ];
# Teach node-gyp to use nodejs headers locally rather that download them form https://nodejs.org.
# This is important when build nodejs packages in sandbox.
postInstall = ''
wrapProgram "$out/bin/node-gyp" \
--set npm_config_nodedir ${nodejs}
'';
};
near-cli = super.near-cli.override {
nativeBuildInputs = with pkgs; [
libusb1
nodePackages.prebuild-install
nodePackages.node-gyp-build
pkg-config
];
};
node-inspector = super.node-inspector.override {
buildInputs = [ self.node-pre-gyp ];
meta.broken = since "10";
};
node2nix = super.node2nix.override {
buildInputs = [ pkgs.makeWrapper ];
# We need to use master because of a fix that replaces git:// url to https://.
src = fetchFromGitHub {
owner = "svanderburg";
repo = "node2nix";
rev = "68f5735f9a56737e3fedceb182705985e3ab8799";
sha256 = "sha256-NK6gDTkGx0GG7yPTwgtFC4ttQZPfcLaLp8W8OOMO6bg=";
};
postInstall = ''
wrapProgram "$out/bin/node2nix" --prefix PATH : ${pkgs.lib.makeBinPath [ pkgs.nix ]}
'';
};
node-red = super.node-red.override {
buildInputs = [ self.node-pre-gyp ];
};
mermaid-cli = super."@mermaid-js/mermaid-cli".override (
if stdenv.isDarwin
then {}
else {
nativeBuildInputs = [ pkgs.makeWrapper ];
prePatch = ''
export PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=1
'';
postInstall = ''
wrapProgram $out/bin/mmdc \
--set PUPPETEER_EXECUTABLE_PATH ${pkgs.chromium.outPath}/bin/chromium
'';
});
pnpm = super.pnpm.override {
nativeBuildInputs = [ pkgs.makeWrapper ];
preRebuild = ''
sed 's/"link:/"file:/g' --in-place package.json
'';
postInstall = let
pnpmLibPath = pkgs.lib.makeBinPath [
nodejs.passthru.python
nodejs
];
in ''
for prog in $out/bin/*; do
wrapProgram "$prog" --prefix PATH : ${pnpmLibPath}
done
'';
};
parcel = super.parcel.override {
buildInputs = [ self.node-gyp-build ];
preRebuild = ''
sed -i -e "s|#!/usr/bin/env node|#! ${pkgs.nodejs}/bin/node|" node_modules/node-gyp-build/bin.js
'';
};
postcss-cli = super.postcss-cli.override {
nativeBuildInputs = [ pkgs.makeWrapper ];
postInstall = ''
wrapProgram "$out/bin/postcss" \
--prefix NODE_PATH : ${self.postcss}/lib/node_modules \
--prefix NODE_PATH : ${self.autoprefixer}/lib/node_modules
ln -s '${self.postcss}/lib/node_modules/postcss' "$out/lib/node_modules/postcss"
'';
passthru.tests = {
simple-execution = pkgs.callPackage ./package-tests/postcss-cli.nix {
inherit (self) postcss-cli;
};
};
meta = {
mainProgram = "postcss";
maintainers = with lib.maintainers; [ Luflosi ];
};
};
# To update prisma, please first update prisma-engines to the latest
# version. Then change the correct hash to this package. The PR should hold
# two commits: one for the engines and the other one for the node package.
prisma = super.prisma.override rec {
nativeBuildInputs = [ pkgs.makeWrapper ];
inherit (pkgs.prisma-engines) version;
src = fetchurl {
url = "https://registry.npmjs.org/prisma/-/prisma-${version}.tgz";
sha512 = "sha512-l9MOgNCn/paDE+i1K2fp9NZ+Du4trzPTJsGkaQHVBufTGqzoYHuNk8JfzXuIn0Gte6/ZjyKj652Jq/Lc1tp2yw==";
};
postInstall = with pkgs; ''
wrapProgram "$out/bin/prisma" \
--set PRISMA_MIGRATION_ENGINE_BINARY ${prisma-engines}/bin/migration-engine \
--set PRISMA_QUERY_ENGINE_BINARY ${prisma-engines}/bin/query-engine \
--set PRISMA_QUERY_ENGINE_LIBRARY ${lib.getLib prisma-engines}/lib/libquery_engine.node \
--set PRISMA_INTROSPECTION_ENGINE_BINARY ${prisma-engines}/bin/introspection-engine \
--set PRISMA_FMT_BINARY ${prisma-engines}/bin/prisma-fmt
'';
passthru.tests = {
simple-execution = pkgs.callPackage ./package-tests/prisma.nix {
inherit (self) prisma;
};
};
};
pulp = super.pulp.override {
# tries to install purescript
npmFlags = "--ignore-scripts";
nativeBuildInputs = [ pkgs.makeWrapper ];
postInstall = ''
wrapProgram "$out/bin/pulp" --suffix PATH : ${pkgs.lib.makeBinPath [
pkgs.purescript
]}
'';
};
reveal-md = super.reveal-md.override (
lib.optionalAttrs (!stdenv.isDarwin) {
nativeBuildInputs = [ pkgs.makeWrapper ];
prePatch = ''
export PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=1
'';
postInstall = ''
wrapProgram $out/bin/reveal-md \
--set PUPPETEER_EXECUTABLE_PATH ${pkgs.chromium.outPath}/bin/chromium
'';
}
);
ssb-server = super.ssb-server.override {
buildInputs = [ pkgs.automake pkgs.autoconf self.node-gyp-build ];
meta.broken = since "10";
};
stf = super.stf.override {
meta.broken = since "10";
};
tailwindcss = super.tailwindcss.overrideAttrs (oldAttrs: {
plugins = [ ];
nativeBuildInputs = [ pkgs.makeWrapper ];
postInstall = ''
nodePath=""
for p in "$out" "${self.postcss}" $plugins; do
nodePath="$nodePath''${nodePath:+:}$p/lib/node_modules"
done
wrapProgram "$out/bin/tailwind" \
--prefix NODE_PATH : "$nodePath"
wrapProgram "$out/bin/tailwindcss" \
--prefix NODE_PATH : "$nodePath"
unset nodePath
'';
passthru.tests = {
simple-execution = pkgs.callPackage ./package-tests/tailwindcss.nix { inherit (self) tailwindcss; };
};
});
tedicross = super."tedicross-git+https://github.com/TediCross/TediCross.git#v0.8.7".override {
nativeBuildInputs = [ pkgs.makeWrapper ];
postInstall = ''
makeWrapper '${nodejs}/bin/node' "$out/bin/tedicross" \
--add-flags "$out/lib/node_modules/tedicross/main.js"
'';
};
thelounge-plugin-closepms = super.thelounge-plugin-closepms.override {
nativeBuildInputs = [ self.node-pre-gyp ];
};
thelounge-theme-flat-blue = super.thelounge-theme-flat-blue.override {
nativeBuildInputs = [ self.node-pre-gyp ];
};
thelounge-theme-flat-dark = super.thelounge-theme-flat-dark.override {
nativeBuildInputs = [ self.node-pre-gyp ];
};
tsun = super.tsun.overrideAttrs (oldAttrs: {
buildInputs = oldAttrs.buildInputs ++ [ pkgs.makeWrapper ];
postInstall = ''
wrapProgram "$out/bin/tsun" \
--prefix NODE_PATH : ${self.typescript}/lib/node_modules
'';
});
ts-node = super.ts-node.overrideAttrs (oldAttrs: {
buildInputs = oldAttrs.buildInputs ++ [ pkgs.makeWrapper ];
postInstall = ''
wrapProgram "$out/bin/ts-node" \
--prefix NODE_PATH : ${self.typescript}/lib/node_modules
'';
});
typescript = super.typescript.overrideAttrs (oldAttrs: {
meta = oldAttrs.meta // { mainProgram = "tsc"; };
});
typescript-language-server = super.typescript-language-server.override {
nativeBuildInputs = [ pkgs.makeWrapper ];
postInstall = ''
wrapProgram "$out/bin/typescript-language-server" \
--suffix PATH : ${pkgs.lib.makeBinPath [ self.typescript ]}
'';
};
teck-programmer = super.teck-programmer.override {
nativeBuildInputs = [ self.node-gyp-build ];
buildInputs = [ pkgs.libusb1 ];
};
uppy-companion = super."@uppy/companion".override {
name = "uppy-companion";
};
vega-cli = super.vega-cli.override {
nativeBuildInputs = [ pkgs.pkg-config ];
buildInputs = with pkgs; [
super.node-pre-gyp
pixman
cairo
pango
libjpeg
];
};
vega-lite = super.vega-lite.override {
postInstall = ''
cd node_modules
for dep in ${self.vega-cli}/lib/node_modules/vega-cli/node_modules/*; do
if [[ ! -d $dep ]]; then
ln -s "${self.vega-cli}/lib/node_modules/vega-cli/node_modules/$dep"
fi
done
'';
passthru.tests = {
simple-execution = pkgs.callPackage ./package-tests/vega-lite.nix {
inherit (self) vega-lite;
};
};
};
webtorrent-cli = super.webtorrent-cli.override {
buildInputs = [ self.node-gyp-build ];
};
joplin = super.joplin.override {
nativeBuildInputs = [ pkgs.pkg-config ];
buildInputs = with pkgs; [
# required by sharp
# https://sharp.pixelplumbing.com/install
vips
libsecret
self.node-gyp-build
self.node-pre-gyp
] ++ lib.optionals stdenv.isDarwin [
darwin.apple_sdk.frameworks.AppKit
darwin.apple_sdk.frameworks.Security
];
};
thelounge = super.thelounge.override {
buildInputs = [ self.node-pre-gyp ];
postInstall = ''
echo /var/lib/thelounge > $out/lib/node_modules/thelounge/.thelounge_home
patch -d $out/lib/node_modules/thelounge -p1 < ${./thelounge-packages-path.patch}
'';
passthru.tests = { inherit (nixosTests) thelounge; };
meta = super.thelounge.meta // { maintainers = with lib.maintainers; [ winter ]; };
};
triton = super.triton.override {
nativeBuildInputs = [ pkgs.installShellFiles ];
postInstall = ''
installShellCompletion --cmd triton --bash <($out/bin/triton completion)
'';
};
yaml-language-server = super.yaml-language-server.override {
nativeBuildInputs = [ pkgs.makeWrapper ];
postInstall = ''
wrapProgram "$out/bin/yaml-language-server" \
--prefix NODE_PATH : ${self.prettier}/lib/node_modules
'';
};
wavedrom-cli = super.wavedrom-cli.override {
nativeBuildInputs = [ pkgs.pkg-config self.node-pre-gyp ];
# These dependencies are required by
# https://github.com/Automattic/node-canvas.
buildInputs = with pkgs; [
pixman
cairo
pango
];
};
};
in self
mainProgramOverrides = final: prev:
mapAttrs (pkgName: mainProgram:
prev.${pkgName}.override (oldAttrs: {
meta = oldAttrs.meta // { inherit mainProgram; };
})
) (import ./main-programs.nix);
extensions = composeManyExtensions [
mainProgramOverrides
(import ./overrides.nix { inherit pkgs nodejs; })
];
in
makeExtensible (extends extensions nodePackages)

@ -0,0 +1,74 @@
# Use this file to add `meta.mainProgram` to packages in `nodePackages`, that don't provide an
# executable that matches that packages name, so that they'll work with `nix run`.
{
# Packages that provide multiple executables where one is clearly the `mainProgram`.
typescript = "tsc";
# Packages that provide a single executable whose name differs from the package's `name`.
"@angular/cli" = "ng";
"@antora/cli" = "antora";
"@astrojs/language-server" = "astro-ls";
"@bitwarden/cli" = "bw";
"@commitlint/cli" = "commitlint";
"@gitbeaker/cli" = "gitbeaker";
"@google/clasp" = "clasp";
"@hyperspace/cli" = "hyp";
"@medable/mdctl-cli" = "mdctl";
"@mermaid-js/mermaid-cli" = "mmdc";
"@nerdwallet/shepherd" = "shepherd";
"@nestjs/cli" = "nest";
"@prisma/language-server" = "prisma-language-server";
"@tailwindcss/language-server" = "tailwindcss-language-server";
"@uppy/companion" = "companion";
"@vue/cli" = "vue";
"@webassemblyjs/repl" = "wasm";
"@webassemblyjs/wasm-strip" = "wasm-strip";
"@webassemblyjs/wasm-text-gen" = "wasmgen";
"@webassemblyjs/wast-refmt" = "wast-refmt";
balanceofsatoshis = "bos";
carbon-now-cli = "carbon-now";
cdk8s-cli = "cdk8s";
cdktf-cli = "cdktf";
clean-css-cli = "cleancss";
clipboard-cli = "clipboard";
clubhouse-cli = "club";
conventional-changelog-cli = "conventional-changelog";
cpy-cli = "cpy";
dockerfile-language-server-nodejs = "docker-langserver";
fast-cli = "fast";
fauna-shell = "fauna";
firebase-tools = "firebase";
fkill-cli = "fkill";
fleek-cli = "fleek";
git-run = "gr";
gitmoji-cli = "gitmoji";
graphql-cli = "graphql";
grunt-cli = "grunt";
gulp-cli = "gulp";
kaput-cli = "kaput";
leetcode-cli = "leetcode";
less = "lessc";
lua-fmt = "luafmt";
markdownlint-cli = "markdownlint";
near-cli = "near";
neovim = "neovim-node-host";
parcel-bundler = "parcel";
parsoid = "parse.js";
poor-mans-t-sql-formatter-cli = "sqlformat";
postcss-cli = "postcss";
purescript-psa = "psa";
react-native-cli = "react-native";
react-tools = "jsx";
remod-cli = "remod";
s3http = "s3http.js";
svelte-language-server = "svelteserver";
teck-programmer = "teck-firmware-upgrade";
uglify-js = "uglifyjs";
undollar = "$";
vsc-leetcode-cli = "leetcode";
vscode-css-languageserver-bin = "css-languageserver";
vscode-html-languageserver-bin = "html-languageserver";
vscode-json-languageserver-bin = "json-languageserver";
vue-language-server = "vls";
webtorrent-cli = "webtorrent";
}

@ -0,0 +1,533 @@
# Do not use overrides in this file to add `meta.mainProgram` to packges. Use `./main-programs.nix`
# instead.
{ pkgs, nodejs }:
let
inherit (pkgs)
stdenv
lib
callPackage
fetchFromGitHub
fetchurl
nixosTests;
since = version: lib.versionAtLeast nodejs.version version;
before = version: lib.versionOlder nodejs.version version;
in
final: prev: {
"@angular/cli" = prev."@angular/cli".override {
prePatch = ''
export NG_CLI_ANALYTICS=false
'';
};
"@electron-forge/cli" = prev."@electron-forge/cli".override {
buildInputs = [ final.node-gyp-build ];
};
"@hyperspace/cli" = prev."@hyperspace/cli".override {
nativeBuildInputs = [ pkgs.makeWrapper ];
buildInputs = [ final.node-gyp-build ];
postInstall = ''wrapProgram "$out/bin/hyp" --prefix PATH : ${ lib.makeBinPath [ nodejs ] }'';
};
hyperspace-cli = final."@hyperspace/cli";
"@medable/mdctl-cli" = prev."@medable/mdctl-cli".override {
nativeBuildInputs = with pkgs; with darwin.apple_sdk.frameworks; [
glib
libsecret
pkg-config
] ++ lib.optionals stdenv.isDarwin [
AppKit
Security
];
buildInputs = [
final.node-gyp-build
final.node-pre-gyp
nodejs
];
};
mdctl-cli = final."@medable/mdctl-cli";
autoprefixer = prev.autoprefixer.override {
nativeBuildInputs = [ pkgs.makeWrapper ];
postInstall = ''
wrapProgram "$out/bin/autoprefixer" \
--prefix NODE_PATH : ${final.postcss}/lib/node_modules
'';
passthru.tests = {
simple-execution = callPackage ./package-tests/autoprefixer.nix { inherit (final) autoprefixer; };
};
};
aws-azure-login = prev.aws-azure-login.override (oldAttrs: {
nativeBuildInputs = [ pkgs.makeWrapper ];
prePatch = ''
export PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=1
'';
postInstall = ''
wrapProgram $out/bin/aws-azure-login \
--set PUPPETEER_EXECUTABLE_PATH ${pkgs.chromium}/bin/chromium
'';
meta = oldAttrs.meta // { platforms = lib.platforms.linux; };
});
bitwarden-cli = prev."@bitwarden/cli".override {
name = "bitwarden-cli";
};
bower2nix = prev.bower2nix.override {
nativeBuildInputs = [ pkgs.makeWrapper ];
postInstall = ''
for prog in bower2nix fetch-bower; do
wrapProgram "$out/bin/$prog" --prefix PATH : ${lib.makeBinPath [ pkgs.git pkgs.nix ]}
done
'';
};
carbon-now-cli = prev.carbon-now-cli.override {
nativeBuildInputs = [ pkgs.makeWrapper ];
prePatch = ''
export PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=1
'';
postInstall = ''
wrapProgram $out/bin/carbon-now \
--set PUPPETEER_EXECUTABLE_PATH ${pkgs.chromium.outPath}/bin/chromium
'';
};
coc-imselect = prev.coc-imselect.override (oldAttrs: {
meta = oldAttrs.meta // { broken = since "10"; };
});
dat = prev.dat.override (oldAttrs: {
buildInputs = [ final.node-gyp-build pkgs.libtool pkgs.autoconf pkgs.automake ];
meta = oldAttrs.meta // { broken = since "12"; };
});
deltachat-desktop = prev."deltachat-desktop-../../applications/networking/instant-messengers/deltachat-desktop".override (oldAttrs: {
meta = oldAttrs.meta // { broken = true; }; # use the top-level package instead
});
# NOTE: this is a stub package to fetch npm dependencies for
# ../../applications/video/epgstation
epgstation = prev."epgstation-../../applications/video/epgstation".override (oldAttrs: {
buildInputs = [ final.node-pre-gyp final.node-gyp-build ];
meta = oldAttrs.meta // { platforms = lib.platforms.none; };
});
# NOTE: this is a stub package to fetch npm dependencies for
# ../../applications/video/epgstation/client
epgstation-client = prev."epgstation-client-../../applications/video/epgstation/client".override (oldAttrs: {
meta = oldAttrs.meta // { platforms = lib.platforms.none; };
});
expo-cli = prev."expo-cli".override (oldAttrs: {
# The traveling-fastlane-darwin optional dependency aborts build on Linux.
dependencies = builtins.filter (d: d.packageName != "@expo/traveling-fastlane-${if stdenv.isLinux then "darwin" else "linux"}") oldAttrs.dependencies;
});
fast-cli = prev.fast-cli.override {
nativeBuildInputs = [ pkgs.makeWrapper ];
prePatch = ''
export PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=1
'';
postInstall = ''
wrapProgram $out/bin/fast \
--set PUPPETEER_EXECUTABLE_PATH ${pkgs.chromium.outPath}/bin/chromium
'';
};
flood = prev.flood.override {
buildInputs = [ final.node-pre-gyp ];
};
git-ssb = prev.git-ssb.override (oldAttrs: {
buildInputs = [ final.node-gyp-build ];
meta = oldAttrs.meta // { broken = since "10"; };
});
hsd = prev.hsd.override {
buildInputs = [ final.node-gyp-build pkgs.unbound ];
};
ijavascript = prev.ijavascript.override (oldAttrs: {
preRebuild = ''
export NPM_CONFIG_ZMQ_EXTERNAL=true
'';
buildInputs = oldAttrs.buildInputs ++ [ final.node-gyp-build pkgs.zeromq ];
});
insect = prev.insect.override (oldAttrs: {
nativeBuildInputs = oldAttrs.nativeBuildInputs or [] ++ [ pkgs.psc-package final.pulp ];
});
intelephense = prev.intelephense.override (oldAttrs: {
meta = oldAttrs.meta // { license = lib.licenses.unfree; };
});
joplin = prev.joplin.override {
nativeBuildInputs = [ pkgs.pkg-config ];
buildInputs = with pkgs; [
# required by sharp
# https://sharp.pixelplumbing.com/install
vips
libsecret
final.node-gyp-build
final.node-pre-gyp
] ++ lib.optionals stdenv.isDarwin [
darwin.apple_sdk.frameworks.AppKit
darwin.apple_sdk.frameworks.Security
];
};
jsonplaceholder = prev.jsonplaceholder.override {
buildInputs = [ nodejs ];
postInstall = ''
exe=$out/bin/jsonplaceholder
mkdir -p $out/bin
cat >$exe <<EOF
#!${pkgs.runtimeShell}
exec -a jsonplaceholder ${nodejs}/bin/node $out/lib/node_modules/jsonplaceholder/index.js
EOF
chmod a+x $exe
'';
};
makam = prev.makam.override {
nativeBuildInputs = [ pkgs.makeWrapper ];
postFixup = ''
wrapProgram "$out/bin/makam" --prefix PATH : ${lib.makeBinPath [ nodejs ]}
${
if stdenv.isLinux
then "patchelf --set-interpreter ${stdenv.glibc}/lib/ld-linux-x86-64.so.2 \"$out/lib/node_modules/makam/makam-bin-linux64\""
else ""
}
'';
};
manta = prev.manta.override {
nativeBuildInputs = with pkgs; [ nodejs-14_x installShellFiles ];
postInstall = ''
# create completions, following upstream procedure https://github.com/joyent/node-manta/blob/v5.2.3/Makefile#L85-L91
completion_cmds=$(find ./bin -type f -printf "%f\n")
node ./lib/create_client.js
for cmd in $completion_cmds; do
installShellCompletion --cmd $cmd --bash <(./bin/$cmd --completion)
done
'';
};
mermaid-cli = prev."@mermaid-js/mermaid-cli".override (
if stdenv.isDarwin
then {}
else {
nativeBuildInputs = [ pkgs.makeWrapper ];
prePatch = ''
export PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=1
'';
postInstall = ''
wrapProgram $out/bin/mmdc \
--set PUPPETEER_EXECUTABLE_PATH ${pkgs.chromium.outPath}/bin/chromium
'';
});
near-cli = prev.near-cli.override {
nativeBuildInputs = with pkgs; [
libusb1
final.prebuild-install
final.node-gyp-build
pkg-config
];
};
node-gyp = prev.node-gyp.override {
nativeBuildInputs = [ pkgs.makeWrapper ];
# Teach node-gyp to use nodejs headers locally rather that download them form https://nodejs.org.
# This is important when build nodejs packages in sandbox.
postInstall = ''
wrapProgram "$out/bin/node-gyp" \
--set npm_config_nodedir ${nodejs}
'';
};
node-inspector = prev.node-inspector.override (oldAttrs: {
buildInputs = [ final.node-pre-gyp ];
meta = oldAttrs.meta // { broken = since "10"; };
});
node-red = prev.node-red.override {
buildInputs = [ final.node-pre-gyp ];
};
node2nix = prev.node2nix.override {
nativeBuildInputs = [ pkgs.makeWrapper ];
# We need to use master because of a fix that replaces git:// url to https://.
src = fetchFromGitHub {
owner = "svanderburg";
repo = "node2nix";
rev = "68f5735f9a56737e3fedceb182705985e3ab8799";
sha256 = "sha256-NK6gDTkGx0GG7yPTwgtFC4ttQZPfcLaLp8W8OOMO6bg=";
};
postInstall = ''
wrapProgram "$out/bin/node2nix" --prefix PATH : ${lib.makeBinPath [ pkgs.nix ]}
'';
};
parcel = prev.parcel.override {
buildInputs = [ final.node-gyp-build ];
preRebuild = ''
sed -i -e "s|#!/usr/bin/env node|#! ${nodejs}/bin/node|" node_modules/node-gyp-build/bin.js
'';
};
pnpm = prev.pnpm.override {
nativeBuildInputs = [ pkgs.makeWrapper ];
preRebuild = ''
sed 's/"link:/"file:/g' --in-place package.json
'';
postInstall = let
pnpmLibPath = lib.makeBinPath [
nodejs.passthru.python
nodejs
];
in ''
for prog in $out/bin/*; do
wrapProgram "$prog" --prefix PATH : ${pnpmLibPath}
done
'';
};
postcss-cli = prev.postcss-cli.override (oldAttrs: {
nativeBuildInputs = [ pkgs.makeWrapper ];
postInstall = ''
wrapProgram "$out/bin/postcss" \
--prefix NODE_PATH : ${final.postcss}/lib/node_modules \
--prefix NODE_PATH : ${final.autoprefixer}/lib/node_modules
ln -s '${final.postcss}/lib/node_modules/postcss' "$out/lib/node_modules/postcss"
'';
passthru.tests = {
simple-execution = callPackage ./package-tests/postcss-cli.nix {
inherit (final) postcss-cli;
};
};
meta = oldAttrs.meta // { maintainers = with lib.maintainers; [ Luflosi ]; };
});
# To update prisma, please first update prisma-engines to the latest
# version. Then change the correct hash to this package. The PR should hold
# two commits: one for the engines and the other one for the node package.
prisma = prev.prisma.override rec {
nativeBuildInputs = [ pkgs.makeWrapper ];
inherit (pkgs.prisma-engines) version;
src = fetchurl {
url = "https://registry.npmjs.org/prisma/-/prisma-${version}.tgz";
sha512 = "sha512-l9MOgNCn/paDE+i1K2fp9NZ+Du4trzPTJsGkaQHVBufTGqzoYHuNk8JfzXuIn0Gte6/ZjyKj652Jq/Lc1tp2yw==";
};
postInstall = with pkgs; ''
wrapProgram "$out/bin/prisma" \
--set PRISMA_MIGRATION_ENGINE_BINARY ${prisma-engines}/bin/migration-engine \
--set PRISMA_QUERY_ENGINE_BINARY ${prisma-engines}/bin/query-engine \
--set PRISMA_QUERY_ENGINE_LIBRARY ${lib.getLib prisma-engines}/lib/libquery_engine.node \
--set PRISMA_INTROSPECTION_ENGINE_BINARY ${prisma-engines}/bin/introspection-engine \
--set PRISMA_FMT_BINARY ${prisma-engines}/bin/prisma-fmt
'';
passthru.tests = {
simple-execution = pkgs.callPackage ./package-tests/prisma.nix {
inherit (final) prisma;
};
};
};
pulp = prev.pulp.override {
# tries to install purescript
npmFlags = "--ignore-scripts";
nativeBuildInputs = [ pkgs.makeWrapper ];
postInstall = ''
wrapProgram "$out/bin/pulp" --suffix PATH : ${lib.makeBinPath [
pkgs.purescript
]}
'';
};
reveal-md = prev.reveal-md.override (
lib.optionalAttrs (!stdenv.isDarwin) {
nativeBuildInputs = [ pkgs.makeWrapper ];
prePatch = ''
export PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=1
'';
postInstall = ''
wrapProgram $out/bin/reveal-md \
--set PUPPETEER_EXECUTABLE_PATH ${pkgs.chromium.outPath}/bin/chromium
'';
}
);
ssb-server = prev.ssb-server.override (oldAttrs: {
buildInputs = [ pkgs.automake pkgs.autoconf final.node-gyp-build ];
meta = oldAttrs.meta // { broken = since "10"; };
});
stf = prev.stf.override (oldAttrs: {
meta = oldAttrs.meta // { broken = since "10"; };
});
tailwindcss = prev.tailwindcss.override {
plugins = [ ];
nativeBuildInputs = [ pkgs.makeWrapper ];
postInstall = ''
nodePath=""
for p in "$out" "${final.postcss}" $plugins; do
nodePath="$nodePath''${nodePath:+:}$p/lib/node_modules"
done
wrapProgram "$out/bin/tailwind" \
--prefix NODE_PATH : "$nodePath"
wrapProgram "$out/bin/tailwindcss" \
--prefix NODE_PATH : "$nodePath"
unset nodePath
'';
passthru.tests = {
simple-execution = callPackage ./package-tests/tailwindcss.nix {
inherit (final) tailwindcss;
};
};
};
teck-programmer = prev.teck-programmer.override {
nativeBuildInputs = [ final.node-gyp-build ];
buildInputs = [ pkgs.libusb1 ];
};
tedicross = prev."tedicross-git+https://github.com/TediCross/TediCross.git#v0.8.7".override {
nativeBuildInputs = [ pkgs.makeWrapper ];
postInstall = ''
makeWrapper '${nodejs}/bin/node' "$out/bin/tedicross" \
--add-flags "$out/lib/node_modules/tedicross/main.js"
'';
};
thelounge = prev.thelounge.override (oldAttrs: {
buildInputs = [ final.node-pre-gyp ];
postInstall = ''
echo /var/lib/thelounge > $out/lib/node_modules/thelounge/.thelounge_home
patch -d $out/lib/node_modules/thelounge -p1 < ${./thelounge-packages-path.patch}
'';
passthru.tests = { inherit (nixosTests) thelounge; };
meta = oldAttrs.meta // { maintainers = with lib.maintainers; [ winter ]; };
});
thelounge-plugin-closepms = prev.thelounge-plugin-closepms.override {
nativeBuildInputs = [ final.node-pre-gyp ];
};
thelounge-plugin-giphy = prev.thelounge-plugin-giphy.override {
nativeBuildInputs = [ final.node-pre-gyp ];
};
thelounge-theme-flat-blue = prev.thelounge-theme-flat-blue.override {
nativeBuildInputs = [ final.node-pre-gyp ];
};
thelounge-theme-flat-dark = prev.thelounge-theme-flat-dark.override {
nativeBuildInputs = [ final.node-pre-gyp ];
};
triton = prev.triton.override {
nativeBuildInputs = [ pkgs.installShellFiles ];
postInstall = ''
installShellCompletion --cmd triton --bash <($out/bin/triton completion)
'';
};
ts-node = prev.ts-node.override {
nativeBuildInputs = [ pkgs.makeWrapper ];
postInstall = ''
wrapProgram "$out/bin/ts-node" \
--prefix NODE_PATH : ${final.typescript}/lib/node_modules
'';
};
tsun = prev.tsun.override {
nativeBuildInputs = [ pkgs.makeWrapper ];
postInstall = ''
wrapProgram "$out/bin/tsun" \
--prefix NODE_PATH : ${final.typescript}/lib/node_modules
'';
};
typescript-language-server = prev.typescript-language-server.override {
nativeBuildInputs = [ pkgs.makeWrapper ];
postInstall = ''
wrapProgram "$out/bin/typescript-language-server" \
--suffix PATH : ${lib.makeBinPath [ final.typescript ]}
'';
};
uppy-companion = prev."@uppy/companion".override {
name = "uppy-companion";
};
vega-cli = prev.vega-cli.override {
nativeBuildInputs = [ pkgs.pkg-config ];
buildInputs = with pkgs; [
final.node-pre-gyp
pixman
cairo
pango
libjpeg
] ++ lib.optionals stdenv.isDarwin [
darwin.apple_sdk.frameworks.CoreText
];
};
vega-lite = prev.vega-lite.override {
postInstall = ''
cd node_modules
for dep in ${final.vega-cli}/lib/node_modules/vega-cli/node_modules/*; do
if [[ ! -d $dep ]]; then
ln -s "${final.vega-cli}/lib/node_modules/vega-cli/node_modules/$dep"
fi
done
'';
passthru.tests = {
simple-execution = callPackage ./package-tests/vega-lite.nix {
inherit (final) vega-lite;
};
};
};
wavedrom-cli = prev.wavedrom-cli.override {
nativeBuildInputs = [ pkgs.pkg-config final.node-pre-gyp ];
# These dependencies are required by
# https://github.com/Automattic/node-canvas.
buildInputs = with pkgs; [
pixman
cairo
pango
] ++ lib.optionals stdenv.isDarwin [
darwin.apple_sdk.frameworks.CoreText
];
};
webtorrent-cli = prev.webtorrent-cli.override {
buildInputs = [ final.node-gyp-build ];
};
yaml-language-server = prev.yaml-language-server.override {
nativeBuildInputs = [ pkgs.makeWrapper ];
postInstall = ''
wrapProgram "$out/bin/yaml-language-server" \
--prefix NODE_PATH : ${final.prettier}/lib/node_modules
'';
};
}
Loading…
Cancel
Save