Skip to content

Commit

Permalink
Try using nix-provided nodehun
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasjm committed Nov 18, 2023
1 parent b73387a commit 4301c58
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 50 deletions.
2 changes: 1 addition & 1 deletion codedown.nix
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ rec {

nixpkgsStableSearcher = common.searcher pkgsStable;

spellchecker = callPackage ./language_servers/markdown-spellcheck-lsp {};
spellchecker = pkgsUnstable.callPackage ./language_servers/markdown-spellcheck-lsp {};

shells = {
zsh = callPackage ./shells/zsh {};
Expand Down
58 changes: 9 additions & 49 deletions language_servers/markdown-spellcheck-lsp/default.nix
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
{ lib
, callPackage
{ callPackage
, fetchFromGitHub
, lib
, makeWrapper
, runCommand
, stdenv

, hunspell
, hunspellDicts
, hunspellWithDicts
, makeWrapper

, node2nix
, nodePackages
, nodehun
, nodejs-18_x
, nodejs-slim-18_x

, python3
, stdenv
, runCommand
, unixtools
}:

Expand All @@ -22,57 +26,13 @@ let

nodejs = nodejs-slim-18_x;

nodehunWithNix = stdenv.mkDerivation {
name = "nodehun-with-nix";
src = fetchFromGitHub {
owner = "Wulf";
repo = "nodehun";
rev = "03c9dcf1fcd965031a68553ccaf6487d1fe87f79";
sha256 = "13baqdxq8m1rvcqpdx5kwwk32xppwv9k29d2w55ash48akk3v1ij";
};

dontConfigure = true;
dontFixup = true;

doCheck = false;

buildInputs = [node2nix];

buildPhase = "node2nix -18 -l package-lock.json";

installPhase = "cp -r ./. $out";
};

nodeHeaders = runCommand "node-${nodejs.version}-headers.tar.gz" { buildInputs = []; } ''
dir="node-v${nodejs.version}"
mkdir "$dir"
cp -r ${nodejs}/include "$dir"
tar -czvf $out "$dir"
'';

nodehun = (callPackage nodehunWithNix { nodejs = nodejs-18_x; }).package.override {
preRebuild = ''
npm run build -- --tarball ${nodeHeaders}
'';

buildInputs = [python3 nodePackages.node-gyp stdenv];

disallowedReferences = [ nodejs ];

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
'';
};

indexJs = stdenv.mkDerivation {
name = "markdown-spellcheck-lsp-index.js";

Expand Down

0 comments on commit 4301c58

Please sign in to comment.