Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at devShellTools-shell 101 lines 2.6 kB view raw
1{ 2 lib, 3 stdenv, 4 fetchurl, 5 openjdk11, 6 unzip, 7 makeWrapper, 8 makeDesktopItem, 9 copyDesktopItems, 10 xdg-utils, 11 imagemagick, 12 maxMemoryAllocationPool ? "1000M", 13}: 14 15stdenv.mkDerivation rec { 16 pname = "weka"; 17 version = "3.9.6"; 18 19 src = fetchurl { 20 url = "mirror://sourceforge/weka/${lib.replaceStrings [ "." ] [ "-" ] "${pname}-${version}"}.zip"; 21 sha256 = "sha256-8fVN4MXYqXNEmyVtXh1IrauHTBZWgWG8AvsGI5Y9Aj0="; 22 }; 23 24 nativeBuildInputs = [ 25 makeWrapper 26 unzip 27 imagemagick 28 ] 29 ++ lib.optionals stdenv.hostPlatform.isLinux [ copyDesktopItems ]; 30 31 # The -Xmx1000M comes suggested from their download page: 32 # https://www.cs.waikato.ac.nz/ml/weka/downloading.html 33 installPhase = '' 34 runHook preInstall 35 36 mkdir -pv $out/share/weka 37 mkdir -p $out/share/icons/hicolor 38 cp -Rv * $out/share/weka 39 40 makeWrapper ${openjdk11}/bin/java $out/bin/weka \ 41 --add-flags "-Xmx${maxMemoryAllocationPool} -jar $out/share/weka/weka.jar" 42 43 makeWrapper ${openjdk11}/bin/java $out/bin/weka-java \ 44 --add-flags "-Xmx${maxMemoryAllocationPool} -cp $out/share/weka/weka.jar" 45 46 ${lib.optionalString stdenv.hostPlatform.isLinux " 47 makeWrapper ${xdg-utils}/bin/xdg-open $out/bin/weka-doc --add-flags $out/share/weka/documentation.html 48 "} 49 50 cat << EOF > $out/bin/weka-home 51 #!${stdenv.shell} 52 echo -n $out/share/weka 53 EOF 54 55 chmod ugo+x $out/bin/weka-home 56 57 for n in 16 24 32 48 64 96 128 256; do 58 size=$n"x"$n 59 mkdir -p $out/share/icons/hicolor/$size/apps 60 magick convert $out/share/weka/weka.gif -resize $size $out/share/icons/hicolor/$size/apps/weka.png 61 done; 62 63 runHook postInstall 64 ''; 65 66 desktopItems = [ 67 (makeDesktopItem { 68 name = "weka"; 69 exec = "weka"; 70 icon = "weka"; 71 desktopName = "WEKA"; 72 categories = [ 73 "Science" 74 "ArtificialIntelligence" 75 "ComputerScience" 76 ]; 77 }) 78 79 (makeDesktopItem { 80 name = "weka-doc"; 81 exec = "weka-doc"; 82 icon = "weka"; 83 desktopName = "View the WEKA documentation with a web browser"; 84 categories = [ 85 "Science" 86 "ArtificialIntelligence" 87 "ComputerScience" 88 ]; 89 }) 90 ]; 91 92 meta = with lib; { 93 homepage = "https://www.cs.waikato.ac.nz/ml/weka/"; 94 description = "Collection of machine learning algorithms for data mining tasks"; 95 mainProgram = "weka"; 96 sourceProvenance = with sourceTypes; [ binaryBytecode ]; 97 license = licenses.gpl2Plus; 98 maintainers = [ maintainers.mimame ]; 99 platforms = platforms.unix; 100 }; 101}