@@ -1,10 +1,11 @@
1−{ fetchFromGitHub, fetchHex, rebar3Relx, buildRebar3, rebar3-proper, stdenv, lib }:
1+{ fetchFromGitHub, fetchgit, fetchHex, rebar3Relx, buildRebar3, rebar3-proper
2+, stdenv, writeScript, lib }:
23let
34 version = "0.18.0";
45 owner = "erlang-ls";
56 repo = "erlang_ls";
67 deps = import ./rebar-deps.nix {
7− inherit fetchHex fetchFromGitHub;
8+ inherit fetchHex fetchFromGitHub fetchgit;
89 builder = buildRebar3;
910 overrides = (self: super: {
1011 proper = super.proper.overrideAttrs (_: {
@@ -45,4 +46,22 @@ rebar3Relx {
4546 platforms = platforms.unix;
4647 license = licenses.asl20;
4748 };
49+ passthru.updateScript = writeScript "update.sh" ''
50+ #!/usr/bin/env nix-shell
51+ #! nix-shell -i bash -p common-updater-scripts coreutils git gnused gnutar gzip "rebar3WithPlugins { globalPlugins = [ beamPackages.rebar3-nix ]; }"
52+
53+ set -ox errexit
54+ latest=$(list-git-tags https://github.com/${owner}/${repo}.git | sed -n '/[\d\.]\+/p' | sort -V | tail -1)
55+ if [[ "$latest" != "${version}" ]]; then
56+ nixpkgs="$(git rev-parse --show-toplevel)"
57+ nix_path="$nixpkgs/pkgs/development/beam-modules/erlang-ls"
58+ update-source-version erlang-ls "$latest" --version-key=version --print-changes --file="$nix_path/default.nix"
59+ tmpdir=$(mktemp -d)
60+ cp -R $(nix-build $nixpkgs --no-out-link -A erlang-ls.src)/* "$tmpdir"
61+ DEBUG=1
62+ (cd "$tmpdir" && HOME=. rebar3 as test nix lock -o "$nix_path/rebar-deps.nix")
63+ else
64+ echo "erlang-ls is already up-to-date"
65+ fi
66+ '';
4867}