1{ lib, elixir, fetchFromGitHub, fetchMixDeps, mixRelease, nix-update-script }:
2# Based on the work of Hauleth
3# None of this would have happened without him
4
5let
6 pname = "elixir-ls";
7 version = "0.14.6";
8 src = fetchFromGitHub {
9 owner = "elixir-lsp";
10 repo = "elixir-ls";
11 rev = "v${version}";
12 hash = "sha256-O977DZLWPyLafIaOTPZKI4MOtK9E9TDProf2xyk05aI";
13 fetchSubmodules = true;
14 };
15in
16mixRelease {
17 inherit pname version src elixir;
18
19 stripDebug = true;
20
21 mixFodDeps = fetchMixDeps {
22 pname = "mix-deps-${pname}";
23 inherit src version elixir;
24 sha256 = "sha256-jF1Plkz1D85aWkiNgeBlJmHndhr7us+8+m/gMkXHvDw=";
25 };
26
27 # elixir-ls is an umbrella app
28 # override configurePhase to not skip umbrella children
29 configurePhase = ''
30 runHook preConfigure
31 mix deps.compile --no-deps-check
32 runHook postConfigure
33 '';
34
35 # elixir-ls require a special step for release
36 # compile and release need to be performed together because
37 # of the no-deps-check requirement
38 buildPhase = ''
39 runHook preBuild
40 mix do compile --no-deps-check, elixir_ls.release
41 runHook postBuild
42 '';
43
44 installPhase = ''
45 runHook preInstall
46 mkdir -p $out/bin
47 cp -Rv release $out/lib
48 # Prepare the wrapper script
49 substitute release/language_server.sh $out/bin/elixir-ls \
50 --replace 'exec "''${dir}/launch.sh"' "exec $out/lib/launch.sh"
51 chmod +x $out/bin/elixir-ls
52 # prepare the launcher
53 substituteInPlace $out/lib/launch.sh \
54 --replace "ERL_LIBS=\"\$SCRIPTPATH:\$ERL_LIBS\"" \
55 "ERL_LIBS=$out/lib:\$ERL_LIBS" \
56 --replace "exec elixir" "exec ${elixir}/bin/elixir"
57 runHook postInstall
58 '';
59
60 meta = with lib; {
61 homepage = "https://github.com/elixir-lsp/elixir-ls";
62 description = ''
63 A frontend-independent IDE "smartness" server for Elixir.
64 Implements the "Language Server Protocol" standard and provides debugger support via the "Debug Adapter Protocol"
65 '';
66 longDescription = ''
67 The Elixir Language Server provides a server that runs in the background, providing IDEs, editors, and other tools with information about Elixir Mix projects.
68 It adheres to the Language Server Protocol, a standard for frontend-independent IDE support.
69 Debugger integration is accomplished through the similar VS Code Debug Protocol.
70 '';
71 license = licenses.asl20;
72 platforms = platforms.unix;
73 maintainers = teams.beam.members;
74 };
75 passthru.updateScript = nix-update-script { };
76}