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