diff --git a/pkgs/development/tools/nodehun/default.nix b/pkgs/development/tools/nodehun/default.nix new file mode 100644 index 000000000000..cef41d918791 --- /dev/null +++ b/pkgs/development/tools/nodehun/default.nix @@ -0,0 +1,64 @@ +{ buildNpmPackage +, darwin +, fetchFromGitHub +, lib +, nodePackages +, nodejs +, python3 +, stdenv +}: + +buildNpmPackage { + pname = "nodehun"; + version = "3.0.2"; + + src = fetchFromGitHub { + owner = "Wulf"; + repo = "nodehun"; + rev = "03c9dcf1fcd965031a68553ccaf6487d1fe87f79"; + hash = "sha256-MoY95lSIQK1K4aIlMdPm93YxJuez9HYx2zlUhHvDao0="; + }; + + patches = [ + # fsevents is needed on Darwin, but its dependency "nan" in the upstream package-lock.json + # is too old for the Node 18.x in Nixpkgs. + # This patch is generated by checking out the upstream source and running + # npm update nan --lockfile-version 1 + ./update-nan.patch + ]; + + npmDepsHash = "sha256-mV6rWNf2p2w4H0ESUT0/Ybtx9YEdvO5l2gCvlWFXK+U="; + + buildInputs = lib.optionals stdenv.isDarwin [ darwin.apple_sdk.frameworks.CoreServices ]; + nativeBuildInputs = [ nodePackages.node-gyp python3 ] + ++ lib.optionals stdenv.isDarwin [ darwin.cctools ]; + + postInstall = '' + # Only keep the necessary parts of build/Release to reduce closure size + cd $out/lib/node_modules/nodehun + mv build build_old + mkdir build + cp -r build_old/Release build/ + rm -rf build_old + rm -rf build/Release/.deps + # Remove a development script to eliminate runtime dependency on node + rm node_modules/node-addon-api/tools/conversion.js + ''; + + doInstallCheck = true; + nativeCheckInputs = [ nodejs ]; + postInstallCheck = '' + # Smoke check: require() works + export NODE_PATH=$out/lib/node_modules + echo 'require("nodehun")' | node - + ''; + + disallowedReferences = [ nodejs ]; + + meta = with lib; { + description = "The Hunspell binding for NodeJS that exposes as much of Hunspell as possible and also adds new features"; + homepage = "https://github.com/Wulf/nodehun"; + license = licenses.mit; + maintainers = [ maintainers.thomasjm ]; + }; +} diff --git a/pkgs/development/tools/nodehun/update-nan.patch b/pkgs/development/tools/nodehun/update-nan.patch new file mode 100644 index 000000000000..e01f1e15c0e6 --- /dev/null +++ b/pkgs/development/tools/nodehun/update-nan.patch @@ -0,0 +1,150 @@ +diff --git a/package-lock.json b/package-lock.json +index 3c577dd..64be338 100644 +--- a/package-lock.json ++++ b/package-lock.json +@@ -932,10 +932,6 @@ + "concat-map": "0.0.1" + } + }, +- "chownr": { +- "version": "1.1.1", +- "bundled": true +- }, + "code-point-at": { + "version": "1.1.0", + "bundled": true, +@@ -987,13 +983,6 @@ + "dev": true, + "optional": true + }, +- "fs-minipass": { +- "version": "1.2.5", +- "bundled": true, +- "requires": { +- "minipass": "^2.2.1" +- } +- }, + "fs.realpath": { + "version": "1.0.0", + "bundled": true, +@@ -1100,22 +1089,6 @@ + "dev": true, + "optional": true + }, +- "minipass": { +- "version": "2.3.5", +- "bundled": true, +- "optional": true, +- "requires": { +- "safe-buffer": "^5.1.2", +- "yallist": "^3.0.0" +- } +- }, +- "minizlib": { +- "version": "1.2.1", +- "bundled": true, +- "requires": { +- "minipass": "^2.2.1" +- } +- }, + "mkdirp": { + "version": "0.5.1", + "bundled": true, +@@ -1300,6 +1273,7 @@ + "safe-buffer": { + "version": "5.1.2", + "bundled": true, ++ "dev": true, + "optional": true + }, + "safer-buffer": { +@@ -1332,24 +1306,24 @@ + "dev": true, + "optional": true + }, +- "string-width": { +- "version": "1.0.2", ++ "string_decoder": { ++ "version": "1.1.1", + "bundled": true, + "dev": true, + "optional": true, + "requires": { +- "code-point-at": "^1.0.0", +- "is-fullwidth-code-point": "^1.0.0", +- "strip-ansi": "^3.0.0" ++ "safe-buffer": "~5.1.0" + } + }, +- "string_decoder": { +- "version": "1.1.1", ++ "string-width": { ++ "version": "1.0.2", + "bundled": true, + "dev": true, + "optional": true, + "requires": { +- "safe-buffer": "~5.1.0" ++ "code-point-at": "^1.0.0", ++ "is-fullwidth-code-point": "^1.0.0", ++ "strip-ansi": "^3.0.0" + } + }, + "strip-ansi": { +@@ -1387,11 +1361,6 @@ + "bundled": true, + "dev": true, + "optional": true +- }, +- "yallist": { +- "version": "3.0.3", +- "bundled": true, +- "optional": true + } + } + }, +@@ -2096,9 +2065,9 @@ + "dev": true + }, + "nan": { +- "version": "2.14.0", +- "resolved": "https://registry.npmjs.org/nan/-/nan-2.14.0.tgz", +- "integrity": "sha512-INOFj37C7k3AfaNTtX8RhsTw7qRy7eLET14cROi9+5HAVbbHuIWUHEauBv5qT4Av2tWasiTY1Jw6puUNqRJXQg==", ++ "version": "2.17.0", ++ "resolved": "https://registry.npmjs.org/nan/-/nan-2.17.0.tgz", ++ "integrity": "sha512-2ZTgtl0nJsO0KQCjEpxcIr5D+Yv90plTitZt9JBfQvVJDS5seMl3FOvsh3+9CoYWXf/1l5OaZzzF6nDm4cagaQ==", + "dev": true, + "optional": true + }, +@@ -2768,6 +2737,15 @@ + } + } + }, ++ "string_decoder": { ++ "version": "1.1.1", ++ "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", ++ "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", ++ "dev": true, ++ "requires": { ++ "safe-buffer": "~5.1.0" ++ } ++ }, + "string-width": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", +@@ -2798,15 +2776,6 @@ + "function-bind": "^1.1.1" + } + }, +- "string_decoder": { +- "version": "1.1.1", +- "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", +- "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", +- "dev": true, +- "requires": { +- "safe-buffer": "~5.1.0" +- } +- }, + "strip-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 862c6bca7e3e..2754f5e87c1d 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -25331,6 +25331,8 @@ with pkgs; ### DEVELOPMENT / LIBRARIES / JAVASCRIPT + nodehun = callPackage ../development/tools/nodehun { }; + yuicompressor = callPackage ../development/tools/yuicompressor { }; ### DEVELOPMENT / BOWER MODULES (JAVASCRIPT)