1{
2 buildNpmPackage,
3 cctools,
4 fetchFromGitHub,
5 lib,
6 node-gyp,
7 nodejs,
8 python3,
9 stdenv,
10}:
11
12buildNpmPackage {
13 pname = "nodehun";
14 version = "3.0.2";
15
16 src = fetchFromGitHub {
17 owner = "Wulf";
18 repo = "nodehun";
19 rev = "03c9dcf1fcd965031a68553ccaf6487d1fe87f79";
20 hash = "sha256-MoY95lSIQK1K4aIlMdPm93YxJuez9HYx2zlUhHvDao0=";
21 };
22
23 patches = [
24 # Remove the dependency on "nodemon", which is only needed for interactive
25 # development. This package depends on fsevents on macOS, which has
26 # repeatedly caused build problems. This patch is generated by checking out
27 # the upstream source and removing the "nodemon" line, and then running
28 #
29 # npm install --lockfile-version 1
30 ./remove-nodemon.patch
31 ];
32
33 npmDepsHash = "sha256-GyNUPgLJhdjzbIpld916/l8durIw0aQRHojjSmGgEJE=";
34 nativeBuildInputs = [
35 node-gyp
36 python3
37 ]
38 ++ lib.optionals stdenv.hostPlatform.isDarwin [ cctools ];
39
40 postInstall = ''
41 # Only keep the necessary parts of build/Release to reduce closure size
42 cd $out/lib/node_modules/nodehun
43 mv build build_old
44 mkdir build
45 cp -r build_old/Release build/
46 rm -rf build_old
47 rm -rf build/Release/.deps
48
49 # Remove a development script to eliminate runtime dependency on node
50 rm node_modules/node-addon-api/tools/conversion.js
51
52 # Remove dangling symlinks
53 rm -rf $out/lib/node_modules/nodehun/node_modules/.bin
54 '';
55
56 doInstallCheck = true;
57 nativeCheckInputs = [ nodejs ];
58 postInstallCheck = ''
59 # Smoke check: require() works
60 export NODE_PATH=$out/lib/node_modules
61 echo 'require("nodehun")' | node -
62 '';
63
64 disallowedReferences = [ nodejs ];
65
66 meta = with lib; {
67 description = "Hunspell binding for NodeJS that exposes as much of Hunspell as possible and also adds new features";
68 homepage = "https://github.com/Wulf/nodehun";
69 license = licenses.mit;
70 maintainers = [ maintainers.thomasjm ];
71 };
72}