From 6834d33b00bc68e5e37a589b802bdb028c271a65 Mon Sep 17 00:00:00 2001 From: Tim Steinbach Date: Thu, 5 Nov 2020 08:32:28 -0500 Subject: scala: Refactor, add tests Abstract over Scala derivation, add tests for individual versions --- nixos/tests/all-tests.nix | 1 + nixos/tests/scala.nix | 33 +++++++++++++ pkgs/development/compilers/scala/2.10.nix | 43 ----------------- pkgs/development/compilers/scala/2.11.nix | 48 ------------------- pkgs/development/compilers/scala/2.12.nix | 47 ------------------ pkgs/development/compilers/scala/2.13.nix | 47 ------------------ pkgs/development/compilers/scala/2.x.nix | 80 +++++++++++++++++++++++++++++++ pkgs/top-level/all-packages.nix | 10 ++-- 8 files changed, 120 insertions(+), 189 deletions(-) create mode 100644 nixos/tests/scala.nix delete mode 100644 pkgs/development/compilers/scala/2.10.nix delete mode 100644 pkgs/development/compilers/scala/2.11.nix delete mode 100644 pkgs/development/compilers/scala/2.12.nix delete mode 100644 pkgs/development/compilers/scala/2.13.nix create mode 100644 pkgs/development/compilers/scala/2.x.nix diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 0e80f27cee8..e2a5263a95d 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -314,6 +314,7 @@ in samba = handleTest ./samba.nix {}; sanoid = handleTest ./sanoid.nix {}; sbt = handleTest ./sbt.nix {}; + scala = handleTest ./scala.nix {}; sddm = handleTest ./sddm.nix {}; service-runner = handleTest ./service-runner.nix {}; shadowsocks = handleTest ./shadowsocks {}; diff --git a/nixos/tests/scala.nix b/nixos/tests/scala.nix new file mode 100644 index 00000000000..f99d9e563ff --- /dev/null +++ b/nixos/tests/scala.nix @@ -0,0 +1,33 @@ +{ system ? builtins.currentSystem, + config ? {}, + pkgs ? import ../.. { inherit system config; } +}: + +with pkgs.lib; + +let + common = name: package: (import ./make-test-python.nix ({ + inherit name; + meta = with pkgs.stdenv.lib.maintainers; { + maintainers = [ nequissimus ]; + }; + + nodes = { + scala = { ... }: { + environment.systemPackages = [ package ]; + }; + }; + + testScript = '' + start_all() + + scala.succeed("scalac -version 2>&1 | grep '^Scala compiler version ${package.version}'") + ''; + }) { inherit system; }); + +in with pkgs; { + scala_2_10 = common "scala_2_10" scala_2_10; + scala_2_11 = common "scala_2_11" scala_2_11; + scala_2_12 = common "scala_2_12" scala_2_12; + scala_2_13 = common "scala_2_13" scala_2_13; +} diff --git a/pkgs/development/compilers/scala/2.10.nix b/pkgs/development/compilers/scala/2.10.nix deleted file mode 100644 index d41442afaf1..00000000000 --- a/pkgs/development/compilers/scala/2.10.nix +++ /dev/null @@ -1,43 +0,0 @@ -{ stdenv, fetchurl, makeWrapper, jre, gnugrep, coreutils }: - -stdenv.mkDerivation rec { - name = "scala-2.10.7"; - - src = fetchurl { - url = "https://www.scala-lang.org/files/archive/${name}.tgz"; - sha256 = "04gi55lzgrhsb78qw8jmnccqim92rw6898knw0a7gfzn2sci30wj"; - }; - - propagatedBuildInputs = [ jre ] ; - buildInputs = [ makeWrapper ] ; - - installPhase = '' - mkdir -p $out - rm bin/*.bat - mv * $out - - 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} - done - ''; - - meta = { - 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 = stdenv.lib.licenses.bsd3; - platforms = stdenv.lib.platforms.all; - branch = "2.10"; - }; -} diff --git a/pkgs/development/compilers/scala/2.11.nix b/pkgs/development/compilers/scala/2.11.nix deleted file mode 100644 index d8fcd3f9a88..00000000000 --- a/pkgs/development/compilers/scala/2.11.nix +++ /dev/null @@ -1,48 +0,0 @@ -{ stdenv, fetchurl, makeWrapper, jre, gnugrep, coreutils }: - -stdenv.mkDerivation rec { - name = "scala-2.11.12"; - - src = fetchurl { - url = "https://www.scala-lang.org/files/archive/${name}.tgz"; - sha256 = "1a4nc4qp9dm4rps47j92hlmxxqskv67qbdmjqc5zd94wd4rps7di"; - }; - - propagatedBuildInputs = [ jre ] ; - buildInputs = [ makeWrapper ] ; - - installPhase = '' - 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 - - 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} - done - ''; - - meta = { - description = "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 = stdenv.lib.licenses.bsd3; - platforms = stdenv.lib.platforms.all; - branch = "2.11"; - }; -} diff --git a/pkgs/development/compilers/scala/2.12.nix b/pkgs/development/compilers/scala/2.12.nix deleted file mode 100644 index 1a7c5677de5..00000000000 --- a/pkgs/development/compilers/scala/2.12.nix +++ /dev/null @@ -1,47 +0,0 @@ -{ stdenv, fetchurl, makeWrapper, jre, gnugrep, coreutils }: - -stdenv.mkDerivation rec { - name = "scala-2.12.12"; - - src = fetchurl { - url = "https://www.scala-lang.org/files/archive/${name}.tgz"; - sha256 = "0avyaa7y8w7494339krcpqhc2p8y5pjk4pz7mqmzdzwy7hgws81m"; - }; - - propagatedBuildInputs = [ jre ] ; - buildInputs = [ makeWrapper ] ; - - installPhase = '' - mkdir -p $out - rm "bin/"*.bat - mv * $out - - # put docs in correct subdirectory - mkdir -p $out/share/doc - mv $out/doc $out/share/doc/scala - mv $out/{LICENSE,NOTICE} $out/share/doc/scala - - 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} - done - ''; - - meta = { - description = "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 = stdenv.lib.licenses.bsd3; - platforms = stdenv.lib.platforms.all; - }; -} diff --git a/pkgs/development/compilers/scala/2.13.nix b/pkgs/development/compilers/scala/2.13.nix deleted file mode 100644 index 75996c382a8..00000000000 --- a/pkgs/development/compilers/scala/2.13.nix +++ /dev/null @@ -1,47 +0,0 @@ -{ stdenv, fetchurl, makeWrapper, jre, gnugrep, coreutils }: - -stdenv.mkDerivation rec { - name = "scala-2.13.3"; - - src = fetchurl { - url = "https://www.scala-lang.org/files/archive/${name}.tgz"; - sha256 = "0zv9w9f6g2cfydsvp8mqcfgv2v3487xp4ca1qndg6v7jrhdp7wy9"; - }; - - propagatedBuildInputs = [ jre ] ; - buildInputs = [ makeWrapper ] ; - - installPhase = '' - mkdir -p $out - rm "bin/"*.bat - mv * $out - - # put docs in correct subdirectory - mkdir -p $out/share/doc - mv $out/doc $out/share/doc/scala - mv $out/{LICENSE,NOTICE} $out/share/doc/scala - - 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} - done - ''; - - meta = { - description = "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 = stdenv.lib.licenses.bsd3; - platforms = stdenv.lib.platforms.all; - }; -} diff --git a/pkgs/development/compilers/scala/2.x.nix b/pkgs/development/compilers/scala/2.x.nix new file mode 100644 index 00000000000..6b24fafc0c5 --- /dev/null +++ b/pkgs/development/compilers/scala/2.x.nix @@ -0,0 +1,80 @@ +{ stdenv, fetchurl, makeWrapper, jre, gnugrep, coreutils, nixosTests }: +let + common = { version, sha256, test }: + stdenv.mkDerivation rec { + inherit version; + + name = "scala-${version}"; + + src = fetchurl { + inherit sha256; + url = "https://www.scala-lang.org/files/archive/scala-${version}.tgz"; + }; + + propagatedBuildInputs = [ jre ]; + buildInputs = [ makeWrapper ]; + + installPhase = '' + 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 + + 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} + done + ''; + + passthru = { + tests = [ test ]; + }; + + meta = { + 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 = stdenv.lib.licenses.bsd3; + platforms = stdenv.lib.platforms.all; + branch = stdenv.lib.majorMinor version; + }; + }; +in { + scala_2_10 = common { + version = "2.10.7"; + sha256 = "04gi55lzgrhsb78qw8jmnccqim92rw6898knw0a7gfzn2sci30wj"; + test = { inherit (nixosTests) scala_2_10; }; + }; + + scala_2_11 = common { + version = "2.11.12"; + sha256 = "1a4nc4qp9dm4rps47j92hlmxxqskv67qbdmjqc5zd94wd4rps7di"; + test = { inherit (nixosTests) scala_2_11; }; + }; + + scala_2_12 = common { + version = "2.12.12"; + sha256 = "0avyaa7y8w7494339krcpqhc2p8y5pjk4pz7mqmzdzwy7hgws81m"; + test = { inherit (nixosTests) scala_2_12; }; + }; + + scala_2_13 = common { + version = "2.13.3"; + sha256 = "0zv9w9f6g2cfydsvp8mqcfgv2v3487xp4ca1qndg6v7jrhdp7wy9"; + test = { inherit (nixosTests) scala_2_13; }; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 26833e4870b..3d15b75f2ed 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -9931,10 +9931,12 @@ in sbcl_2_0_9 = callPackage ../development/compilers/sbcl/2.0.9.nix {}; sbcl = callPackage ../development/compilers/sbcl {}; - scala_2_10 = callPackage ../development/compilers/scala/2.10.nix { }; - scala_2_11 = callPackage ../development/compilers/scala/2.11.nix { }; - scala_2_12 = callPackage ../development/compilers/scala/2.12.nix { jre = jre8; }; - scala_2_13 = callPackage ../development/compilers/scala/2.13.nix { jre = jre8; }; + inherit (callPackage ../development/compilers/scala/2.x.nix { jre = jre8; }) + scala_2_10 + scala_2_11 + scala_2_12 + scala_2_13; + scala = scala_2_13; metal = callPackage ../development/libraries/metal { }; -- cgit 1.4.1