2021-08-22 07:53:02 +00:00
|
|
|
{ stdenv, lib, fetchurl, makeWrapper, jre, gnugrep, coreutils, writeScript
|
|
|
|
, common-updater-scripts, git, gnused, nix, nixfmt, majorVersion }:
|
2020-11-06 00:33:48 +00:00
|
|
|
|
|
|
|
let
|
|
|
|
repo = "git@github.com:scala/scala.git";
|
|
|
|
|
2020-12-09 12:39:15 +00:00
|
|
|
versionMap = {
|
|
|
|
"2.10" = {
|
|
|
|
version = "2.10.7";
|
|
|
|
sha256 = "koMRmRb2u3cU4HaihAzPItWIGbNVIo7RWRrm92kp8RE=";
|
|
|
|
pname = "scala_2_10";
|
|
|
|
};
|
2020-11-06 00:33:48 +00:00
|
|
|
|
2020-12-09 12:39:15 +00:00
|
|
|
"2.11" = {
|
|
|
|
version = "2.11.12";
|
|
|
|
sha256 = "sR19M2mcpPYLw7K2hY/ZU+PeK4UiyUP0zaS2dDFhlqg=";
|
|
|
|
pname = "scala_2_11";
|
|
|
|
};
|
2020-11-06 00:33:48 +00:00
|
|
|
|
2020-12-09 12:39:15 +00:00
|
|
|
"2.12" = {
|
2023-07-15 17:15:38 +00:00
|
|
|
version = "2.12.18";
|
|
|
|
sha256 = "naIJCET+YPrbXln39F9aU3DBdnjcn7PYMmhDxETOA5g=";
|
2020-12-09 12:39:15 +00:00
|
|
|
pname = "scala_2_12";
|
|
|
|
};
|
2020-11-06 00:33:48 +00:00
|
|
|
|
2020-12-09 12:39:15 +00:00
|
|
|
"2.13" = {
|
2023-10-09 19:29:22 +00:00
|
|
|
version = "2.13.12";
|
|
|
|
sha256 = "r+fm+1njyIRX6Z9wGHMOUvuifI0V49cVT3KWggbKhxk=";
|
2020-12-09 12:39:15 +00:00
|
|
|
pname = "scala_2_13";
|
|
|
|
};
|
|
|
|
};
|
2020-11-06 00:33:48 +00:00
|
|
|
|
2020-12-09 12:39:15 +00:00
|
|
|
in with versionMap.${majorVersion};
|
2020-11-06 00:33:48 +00:00
|
|
|
|
2020-12-09 12:39:15 +00:00
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
inherit version;
|
2020-11-06 00:33:48 +00:00
|
|
|
|
2020-12-09 12:39:15 +00:00
|
|
|
name = "scala-${version}";
|
2020-11-06 00:33:48 +00:00
|
|
|
|
2020-12-09 12:39:15 +00:00
|
|
|
src = fetchurl {
|
|
|
|
inherit sha256;
|
|
|
|
url = "https://www.scala-lang.org/files/archive/scala-${version}.tgz";
|
|
|
|
};
|
2020-11-06 00:33:48 +00:00
|
|
|
|
2020-12-09 12:39:15 +00:00
|
|
|
propagatedBuildInputs = [ jre ];
|
2020-11-06 00:33:48 +00:00
|
|
|
|
2021-03-09 03:18:52 +00:00
|
|
|
nativeBuildInputs = [ makeWrapper ];
|
2020-11-06 00:33:48 +00:00
|
|
|
|
2020-12-09 12:39:15 +00:00
|
|
|
installPhase = ''
|
2021-02-24 18:30:23 +00:00
|
|
|
runHook preInstall
|
|
|
|
mkdir -p $out
|
|
|
|
rm bin/*.bat
|
|
|
|
mv * $out
|
|
|
|
# put docs in correct subdirectory
|
|
|
|
mkdir -p $out/share/doc
|
|
|
|
mv $out/doc $out/share/doc/${name}
|
|
|
|
mv $out/man $out/share/man
|
2020-12-09 12:39:15 +00:00
|
|
|
for p in $(ls $out/bin/) ; do
|
|
|
|
wrapProgram $out/bin/$p \
|
|
|
|
--prefix PATH ":" ${coreutils}/bin \
|
|
|
|
--prefix PATH ":" ${gnugrep}/bin \
|
|
|
|
--prefix PATH ":" ${jre}/bin \
|
|
|
|
--set JAVA_HOME ${jre}
|
2021-02-24 18:30:23 +00:00
|
|
|
done
|
|
|
|
runHook postInstall
|
2020-12-09 12:39:15 +00:00
|
|
|
'';
|
2020-11-06 00:33:48 +00:00
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
doInstallCheck = true;
|
|
|
|
installCheckPhase = ''
|
|
|
|
$out/bin/scalac -version 2>&1 | grep '^Scala compiler version ${version}'
|
|
|
|
|
|
|
|
echo 'println("foo"*3)' | $out/bin/scala 2>/dev/null | grep "foofoofoo"
|
|
|
|
'';
|
|
|
|
|
2020-12-09 12:39:15 +00:00
|
|
|
passthru = {
|
|
|
|
updateScript = writeScript "update.sh" ''
|
|
|
|
#!${stdenv.shell}
|
|
|
|
set -o errexit
|
|
|
|
PATH=${
|
2021-02-05 17:12:51 +00:00
|
|
|
lib.makeBinPath [
|
2020-12-09 12:39:15 +00:00
|
|
|
common-updater-scripts
|
|
|
|
coreutils
|
|
|
|
git
|
|
|
|
gnused
|
|
|
|
nix
|
|
|
|
nixfmt
|
|
|
|
]
|
|
|
|
}
|
2023-03-04 12:14:45 +00:00
|
|
|
versionSelect='v${lib.versions.major version}.${lib.versions.minor version}.*'
|
2020-12-09 12:39:15 +00:00
|
|
|
oldVersion="$(nix-instantiate --eval -E "with import ./. {}; lib.getVersion ${pname}" | tr -d '"')"
|
|
|
|
latestTag="$(git -c 'versionsort.suffix=-' ls-remote --exit-code --refs --sort='version:refname' --tags ${repo} "$versionSelect" | tail --lines=1 | cut --delimiter='/' --fields=3 | sed 's|^v||g')"
|
|
|
|
if [ "$oldVersion" != "$latestTag" ]; then
|
|
|
|
nixpkgs="$(git rev-parse --show-toplevel)"
|
|
|
|
default_nix="$nixpkgs/pkgs/development/compilers/scala/2.x.nix"
|
|
|
|
update-source-version ${pname} "$latestTag" --version-key=version --print-changes
|
|
|
|
nixfmt "$default_nix"
|
|
|
|
else
|
|
|
|
echo "${pname} is already up-to-date"
|
|
|
|
fi
|
|
|
|
'';
|
2020-11-06 00:33:48 +00:00
|
|
|
};
|
|
|
|
|
2023-02-02 18:25:31 +00:00
|
|
|
meta = with lib; {
|
2020-12-09 12:39:15 +00:00
|
|
|
description = "A general purpose programming language";
|
|
|
|
longDescription = ''
|
|
|
|
Scala is a general purpose programming language designed to express
|
|
|
|
common programming patterns in a concise, elegant, and type-safe way.
|
|
|
|
It smoothly integrates features of object-oriented and functional
|
|
|
|
languages, enabling Java and other programmers to be more productive.
|
|
|
|
Code sizes are typically reduced by a factor of two to three when
|
|
|
|
compared to an equivalent Java application.
|
|
|
|
'';
|
|
|
|
homepage = "https://www.scala-lang.org/";
|
|
|
|
license = licenses.bsd3;
|
|
|
|
platforms = platforms.all;
|
|
|
|
branch = versions.majorMinor version;
|
2023-10-09 19:29:22 +00:00
|
|
|
maintainers = with maintainers; [ nequissimus kashw2 ];
|
2020-11-06 00:33:48 +00:00
|
|
|
};
|
|
|
|
}
|