evcc: 0.131.4 -> 0.131.5
[NixPkgs.git] / pkgs / by-name / no / nodehun / package.nix
blob5bc067085ed8f40c2a732c56cbc4d28f3fed8b49
1 { buildNpmPackage
2 , cctools
3 , darwin
4 , fetchFromGitHub
5 , lib
6 , node-gyp
7 , nodejs
8 , python3
9 , stdenv
12 buildNpmPackage {
13   pname = "nodehun";
14   version = "3.0.2";
16   src = fetchFromGitHub {
17     owner = "Wulf";
18     repo = "nodehun";
19     rev = "03c9dcf1fcd965031a68553ccaf6487d1fe87f79";
20     hash = "sha256-MoY95lSIQK1K4aIlMdPm93YxJuez9HYx2zlUhHvDao0=";
21   };
23   patches = [
24     # fsevents is needed on Darwin, but its dependency "nan" in the upstream package-lock.json
25     # is too old for the Node 18.x in Nixpkgs.
26     # This patch is generated by checking out the upstream source and running
27     # npm update nan --lockfile-version 1
28     ./update-nan.patch
29   ];
31   npmDepsHash = "sha256-mV6rWNf2p2w4H0ESUT0/Ybtx9YEdvO5l2gCvlWFXK+U=";
33   buildInputs = lib.optionals stdenv.hostPlatform.isDarwin [ darwin.apple_sdk.frameworks.CoreServices ];
34   nativeBuildInputs = [ node-gyp python3 ]
35     ++ lib.optionals stdenv.hostPlatform.isDarwin [ cctools ];
37   postInstall = ''
38     # Only keep the necessary parts of build/Release to reduce closure size
39     cd $out/lib/node_modules/nodehun
40     mv build build_old
41     mkdir build
42     cp -r build_old/Release build/
43     rm -rf build_old
44     rm -rf build/Release/.deps
45     # Remove a development script to eliminate runtime dependency on node
46     rm node_modules/node-addon-api/tools/conversion.js
47   '';
49   doInstallCheck = true;
50   nativeCheckInputs = [ nodejs ];
51   postInstallCheck = ''
52     # Smoke check: require() works
53     export NODE_PATH=$out/lib/node_modules
54     echo 'require("nodehun")' | node -
55   '';
57   disallowedReferences = [ nodejs ];
59   meta = with lib; {
60     description = "Hunspell binding for NodeJS that exposes as much of Hunspell as possible and also adds new features";
61     homepage = "https://github.com/Wulf/nodehun";
62     license = licenses.mit;
63     maintainers = [ maintainers.thomasjm ];
64   };