2020-11-06 00:33:48 +00:00
|
|
|
{ stdenv, fetchurl, jre, autoPatchelfHook, zlib, writeScript
|
|
|
|
, common-updater-scripts, git, nixfmt, nix, coreutils, gnused, nixosTests }:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "sbt";
|
2020-12-26 04:20:00 +00:00
|
|
|
version = "1.4.6";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchurl {
|
2020-10-11 12:50:04 +00:00
|
|
|
url =
|
|
|
|
"https://github.com/sbt/sbt/releases/download/v${version}/sbt-${version}.tgz";
|
2020-12-26 04:20:00 +00:00
|
|
|
sha256 = "sha256-hqbyjnmWYHQQEGarGqGSZ9DI1E6uIdqpPJxgVspvnaQ=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
patchPhase = ''
|
|
|
|
echo -java-home ${jre.home} >>conf/sbtopts
|
|
|
|
'';
|
|
|
|
|
2020-10-11 12:50:04 +00:00
|
|
|
nativeBuildInputs = stdenv.lib.optionals stdenv.isLinux [ autoPatchelfHook ];
|
2020-10-07 09:15:18 +00:00
|
|
|
|
2020-10-11 12:50:04 +00:00
|
|
|
buildInputs = stdenv.lib.optionals stdenv.isLinux [ zlib ];
|
2020-10-07 09:15:18 +00:00
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
installPhase = ''
|
|
|
|
mkdir -p $out/share/sbt $out/bin
|
|
|
|
cp -ra . $out/share/sbt
|
2020-10-07 09:15:18 +00:00
|
|
|
ln -sT ../share/sbt/bin/sbt $out/bin/sbt
|
2020-10-11 12:50:04 +00:00
|
|
|
ln -sT ../share/sbt/bin/sbtn-x86_64-${
|
|
|
|
if (stdenv.isDarwin) then "apple-darwin" else "pc-linux"
|
|
|
|
} $out/bin/sbtn
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
meta = with stdenv.lib; {
|
|
|
|
homepage = "https://www.scala-sbt.org/";
|
|
|
|
license = licenses.bsd3;
|
|
|
|
description = "A build tool for Scala, Java and more";
|
|
|
|
maintainers = with maintainers; [ nequissimus ];
|
|
|
|
platforms = platforms.unix;
|
|
|
|
};
|
2020-11-06 00:33:48 +00:00
|
|
|
|
|
|
|
passthru = {
|
|
|
|
tests = { inherit (nixosTests) sbt; };
|
|
|
|
|
|
|
|
updateScript = writeScript "update.sh" ''
|
|
|
|
#!${stdenv.shell}
|
|
|
|
set -o errexit
|
|
|
|
PATH=${
|
|
|
|
stdenv.lib.makeBinPath [
|
|
|
|
common-updater-scripts
|
|
|
|
git
|
|
|
|
nixfmt
|
|
|
|
nix
|
|
|
|
coreutils
|
|
|
|
gnused
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
oldVersion="$(nix-instantiate --eval -E "with import ./. {}; lib.getVersion sbt" | tr -d '"')"
|
|
|
|
latestTag="$(git -c 'versionsort.suffix=-' ls-remote --exit-code --refs --sort='version:refname' --tags git@github.com:sbt/sbt.git '*.*.*' | tail --lines=1 | cut --delimiter='/' --fields=3 | sed 's|^v||g')"
|
|
|
|
|
|
|
|
if [ ! "$oldVersion" = "$latestTag" ]; then
|
|
|
|
update-source-version sbt "$latestTag" --version-key=version --print-changes
|
|
|
|
nixpkgs="$(git rev-parse --show-toplevel)"
|
|
|
|
default_nix="$nixpkgs/pkgs/development/tools/build-managers/sbt/default.nix"
|
|
|
|
nixfmt "$default_nix"
|
|
|
|
else
|
|
|
|
echo "sbt is already up-to-date"
|
|
|
|
fi
|
|
|
|
'';
|
|
|
|
};
|
2020-04-24 23:36:52 +00:00
|
|
|
}
|