nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenvNoCC,
4 fetchFromGitHub,
5 pnpm_10,
6 fetchPnpmDeps,
7 pnpmConfigHook,
8 nodejs,
9 makeBinaryWrapper,
10 shellcheck,
11 versionCheckHook,
12}:
13stdenvNoCC.mkDerivation (finalAttrs: {
14 pname = "bash-language-server";
15 version = "5.6.0";
16
17 src = fetchFromGitHub {
18 owner = "bash-lsp";
19 repo = "bash-language-server";
20 tag = "server-${finalAttrs.version}";
21 hash = "sha256-Pe32lQSlyWcyUbqwhfoulwNwhrnWdRcKFIl3Jj0Skac=";
22 };
23
24 pnpmWorkspaces = [ "bash-language-server" ];
25 pnpmDeps = fetchPnpmDeps {
26 inherit (finalAttrs)
27 pname
28 version
29 src
30 pnpmWorkspaces
31 ;
32 pnpm = pnpm_10;
33 fetcherVersion = 3;
34 hash = "sha256-6i+1V3ZkjiJ/IXDun3JfwmfDOiemxCmAXMzS/rGT6ZU=";
35 };
36
37 nativeBuildInputs = [
38 nodejs
39 pnpmConfigHook
40 pnpm_10
41 makeBinaryWrapper
42 versionCheckHook
43 ];
44 buildPhase = ''
45 runHook preBuild
46
47 pnpm compile server
48
49 runHook postBuild
50 '';
51
52 preInstall = ''
53 # remove unnecessary files
54 rm node_modules/.modules.yaml
55 CI=true pnpm --ignore-scripts --prod prune
56 rm -r node_modules/.pnpm/@mixmark-io*/node_modules/@mixmark-io/domino/{test,.yarn}
57 find -type f \( -name "*.ts" -o -name "*.map" \) -exec rm -rf {} +
58 # https://github.com/pnpm/pnpm/issues/3645
59 find node_modules server/node_modules -xtype l -delete
60
61 # remove non-deterministic files
62 rm node_modules/.modules.yaml
63 '';
64
65 installPhase = ''
66 runHook preInstall
67
68 mkdir -p $out/{bin,lib/bash-language-server}
69 cp -r {node_modules,server} $out/lib/bash-language-server/
70
71 # Create the executable, based upon what happens in npmHooks.npmInstallHook
72 makeWrapper ${lib.getExe nodejs} $out/bin/bash-language-server \
73 --suffix PATH : ${lib.makeBinPath [ shellcheck ]} \
74 --inherit-argv0 \
75 --add-flags $out/lib/bash-language-server/server/out/cli.js
76
77 runHook postInstall
78 '';
79
80 doInstallCheck = true;
81
82 meta = {
83 description = "Language server for Bash";
84 homepage = "https://github.com/bash-lsp/bash-language-server";
85 changelog = "https://github.com/bash-lsp/bash-language-server/releases/tag/${finalAttrs.src.tag}";
86 license = lib.licenses.mit;
87 maintainers = with lib.maintainers; [
88 doronbehar
89 gepbird
90 ];
91 mainProgram = "bash-language-server";
92 platforms = lib.platforms.all;
93 };
94})