@@ -1,10 +1,11 @@
1{ lib, stdenv, fetchFromGitHub,
1{ lib, stdenv, fetchFromGitHub,
2− fetchHex, erlang, makeWrapper }:
2+ fetchHex, erlang, makeWrapper,
3+ writeScript, common-updater-scripts, coreutils, git, gnused, nix, rebar3-nix }:
5 version = "3.15.1";
6 version = "3.15.1";
6 owner = "erlang";
7 owner = "erlang";
7− deps = import ./rebar-deps.nix { inherit fetchHex; };
8+ deps = import ./rebar-deps.nix { inherit fetchFromGitHub fetchHex; };
8 rebar3 = stdenv.mkDerivation rec {
9 rebar3 = stdenv.mkDerivation rec {
9 pname = "rebar3";
10 pname = "rebar3";
10 inherit version erlang;
11 inherit version erlang;
@@ -63,6 +64,31 @@ let
63 license = lib.licenses.asl20;
64 license = lib.licenses.asl20;
67+ passthru.updateScript = writeScript "update.sh" ''
72+ common-updater-scripts
77+ (rebar3WithPlugins { globalPlugins = [rebar3-nix]; })
80+ latest=$(list-git-tags https://github.com/${owner}/${pname}.git | sed -n '/[\d\.]\+/p' | sort -V | tail -1)
81+ if [ "$latest" != "${version}" ]; then
82+ nixpkgs="$(git rev-parse --show-toplevel)"
83+ nix_path="$nixpkgs/pkgs/development/tools/build-managers/rebar3"
84+ update-source-version rebar3 "$latest" --version-key=version --print-changes --file="$nix_path/default.nix"
86+ cp -R $(nix-build $nixpkgs --no-out-link -A rebar3.src)/* "$tmpdir"
87+ (cd "$tmpdir" && rebar3 nix lock -o "$nix_path/rebar-deps.nix")
89+ echo "rebar3 is already up-to-date"
67 rebar3WithPlugins = { plugins ? [ ], globalPlugins ? [ ] }:
93 rebar3WithPlugins = { plugins ? [ ], globalPlugins ? [ ] }: