Merge pull request #329823 from ExpidusOS/fix/pkgsllvm/elfutils
[NixPkgs.git] / pkgs / by-name / ba / bash-language-server / package.nix
blobeb47dfdd9f6b6c87dcb867440368e2a1c8720f2a
1 { lib
2 , stdenv
3 , fetchFromGitHub
4 , pnpm_8
5 , nodejs
6 , npmHooks
7 , makeBinaryWrapper
8 , shellcheck
9 }:
11 stdenv.mkDerivation (finalAttrs: {
12   pname = "bash-language-server";
13   version = "5.4.0";
15   src = fetchFromGitHub {
16     owner = "bash-lsp";
17     repo = "bash-language-server";
18     rev = "server-${finalAttrs.version}";
19     hash = "sha256-yJ81oGd9aNsWQMLvDSgMVVH1//Mw/SVFYFIPsJTQYzE=";
20   };
22   pnpmDeps = pnpm_8.fetchDeps {
23     inherit (finalAttrs) pname version src;
24     hash = "sha256-W25xehcxncBs9QgQBt17F5YHK0b+GDEmt27XzTkyYWg=";
25   };
27   nativeBuildInputs = [
28     nodejs
29     pnpm_8.configHook
30     npmHooks.npmBuildHook
31     makeBinaryWrapper
32   ];
33   npmBuildScript = "compile";
34   # We are only interested in the bash-language-server executable, which is
35   # part of the `./server` directory. From some reason, the `./vscode-client`
36   # directory is not included in upstream's `pnpm-workspace.yaml`, so perhaps
37   # that's why our ${pnpmDeps} don't include the dependencies required for it.
38   preBuild = ''
39     rm -r vscode-client
40     substituteInPlace tsconfig.json \
41       --replace-fail '{ "path": "./vscode-client" },' ""
42   '';
44   installPhase = ''
45     runHook preInstall
47     pnpm --offline \
48       --frozen-lockfile --ignore-script \
49       --filter=bash-language-server \
50       deploy $out/lib/bash-language-server
51     # Cleanup directory a bit, to save space, and make fixup phase a bit faster
52     rm -r $out/lib/bash-language-server/src
53     find $out/lib/bash-language-server -name '*.ts' -delete
54     rm -r \
55       $out/lib/bash-language-server/node_modules/.bin \
56       $out/lib/bash-language-server/node_modules/*/bin
58     # Create the executable, based upon what happens in npmHooks.npmInstallHook
59     makeWrapper ${lib.getExe nodejs} $out/bin/bash-language-server \
60       --prefix PATH : ${lib.makeBinPath [ shellcheck ]} \
61       --inherit-argv0 \
62       --add-flags $out/lib/bash-language-server/out/cli.js
64     runHook postInstall
65   '';
67   meta = with lib; {
68     description = "A language server for Bash";
69     homepage = "https://github.com/bash-lsp/bash-language-server";
70     license = licenses.mit;
71     maintainers = with maintainers; [ doronbehar ];
72     mainProgram = "bash-language-server";
73     platforms = platforms.all;
74   };