2021-08-15 20:48:27 +00:00
|
|
|
{ fetchFromGitHub, fetchgit, fetchHex, rebar3Relx, buildRebar3, rebar3-proper
|
|
|
|
, stdenv, writeScript, lib }:
|
2021-05-11 21:33:58 +00:00
|
|
|
let
|
2021-10-05 01:07:11 +00:00
|
|
|
version = "0.20.0";
|
2021-05-11 21:33:58 +00:00
|
|
|
owner = "erlang-ls";
|
|
|
|
repo = "erlang_ls";
|
2021-05-17 15:53:54 +00:00
|
|
|
deps = import ./rebar-deps.nix {
|
2021-08-15 20:48:27 +00:00
|
|
|
inherit fetchHex fetchFromGitHub fetchgit;
|
2021-05-17 15:53:54 +00:00
|
|
|
builder = buildRebar3;
|
2021-05-31 17:25:05 +00:00
|
|
|
overrides = (self: super: {
|
|
|
|
proper = super.proper.overrideAttrs (_: {
|
|
|
|
configurePhase = "true";
|
|
|
|
});
|
|
|
|
});
|
2021-05-17 15:53:54 +00:00
|
|
|
};
|
2021-07-08 11:13:42 +00:00
|
|
|
in
|
|
|
|
rebar3Relx {
|
|
|
|
pname = "erlang-ls";
|
2021-05-11 21:33:58 +00:00
|
|
|
inherit version;
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
inherit owner repo;
|
2021-10-05 01:07:11 +00:00
|
|
|
sha256 = "sha256-XBCauvPalIPjVOYlMfWC+5mKku28b/qqKhp9NgSkoyA=";
|
2021-05-11 21:33:58 +00:00
|
|
|
rev = version;
|
|
|
|
};
|
2021-05-17 15:53:54 +00:00
|
|
|
releaseType = "escript";
|
|
|
|
beamDeps = builtins.attrValues deps;
|
2021-05-31 17:25:05 +00:00
|
|
|
buildPlugins = [ rebar3-proper ];
|
2021-05-17 15:53:54 +00:00
|
|
|
buildPhase = "HOME=. make";
|
2021-05-31 17:25:05 +00:00
|
|
|
# based on https://github.com/erlang-ls/erlang_ls/blob/main/.github/workflows/build.yml
|
|
|
|
# these tests are excessively long and we should probably skip them
|
|
|
|
checkPhase = ''
|
|
|
|
HOME=. epmd -daemon
|
|
|
|
HOME=. rebar3 ct
|
|
|
|
HOME=. rebar3 proper --constraint_tries 100
|
|
|
|
'';
|
2021-07-31 15:36:06 +00:00
|
|
|
# tests seem to be a bit flaky on darwin, skip them for now
|
|
|
|
doCheck = !stdenv.isDarwin;
|
2021-05-11 21:33:58 +00:00
|
|
|
installPhase = ''
|
|
|
|
mkdir -p $out/bin
|
|
|
|
cp _build/default/bin/erlang_ls $out/bin/
|
|
|
|
cp _build/dap/bin/els_dap $out/bin/
|
|
|
|
'';
|
|
|
|
meta = with lib; {
|
|
|
|
homepage = "https://github.com/erlang-ls/erlang_ls";
|
|
|
|
description = "The Erlang Language Server";
|
|
|
|
platforms = platforms.unix;
|
|
|
|
license = licenses.asl20;
|
|
|
|
};
|
2021-08-15 20:48:27 +00:00
|
|
|
passthru.updateScript = writeScript "update.sh" ''
|
|
|
|
#!/usr/bin/env nix-shell
|
|
|
|
#! nix-shell -i bash -p common-updater-scripts coreutils git gnused gnutar gzip "rebar3WithPlugins { globalPlugins = [ beamPackages.rebar3-nix ]; }"
|
|
|
|
|
|
|
|
set -ox errexit
|
|
|
|
latest=$(list-git-tags https://github.com/${owner}/${repo}.git | sed -n '/[\d\.]\+/p' | sort -V | tail -1)
|
|
|
|
if [[ "$latest" != "${version}" ]]; then
|
|
|
|
nixpkgs="$(git rev-parse --show-toplevel)"
|
|
|
|
nix_path="$nixpkgs/pkgs/development/beam-modules/erlang-ls"
|
|
|
|
update-source-version erlang-ls "$latest" --version-key=version --print-changes --file="$nix_path/default.nix"
|
|
|
|
tmpdir=$(mktemp -d)
|
|
|
|
cp -R $(nix-build $nixpkgs --no-out-link -A erlang-ls.src)/* "$tmpdir"
|
|
|
|
DEBUG=1
|
|
|
|
(cd "$tmpdir" && HOME=. rebar3 as test nix lock -o "$nix_path/rebar-deps.nix")
|
|
|
|
else
|
|
|
|
echo "erlang-ls is already up-to-date"
|
|
|
|
fi
|
|
|
|
'';
|
2021-05-11 21:33:58 +00:00
|
|
|
}
|