1{
2 lib,
3 stdenv,
4 fetchurl,
5 libGL,
6 xorg,
7 jre,
8 makeDesktopItem,
9 makeWrapper,
10 unzip,
11 language ? "en_US",
12}:
13let
14 pname = "geogebra";
15 version = "5-0-785-0";
16
17 srcIcon = fetchurl {
18 url = "https://web.archive.org/web/20200227000442if_/https://static.geogebra.org/images/geogebra-logo.svg";
19 hash = "sha256-Vd7Wteya04JJT4WNirXe8O1sfVKUgc0hKGOy7d47Xgc=";
20 };
21
22 desktopItem = makeDesktopItem {
23 name = "geogebra";
24 exec = "geogebra";
25 icon = "geogebra";
26 desktopName = "Geogebra";
27 genericName = "Geogebra";
28 comment = meta.description;
29 categories = [
30 "Education"
31 "Science"
32 "Math"
33 ];
34 mimeTypes = [
35 "application/vnd.geogebra.file"
36 "application/vnd.geogebra.tool"
37 ];
38 };
39
40 meta = with lib; {
41 description = "Dynamic mathematics software with graphics, algebra and spreadsheets";
42 longDescription = ''
43 Dynamic mathematics software for all levels of education that brings
44 together geometry, algebra, spreadsheets, graphing, statistics and
45 calculus in one easy-to-use package.
46 '';
47 homepage = "https://www.geogebra.org/";
48 maintainers = with maintainers; [
49 sikmir
50 soupglasses
51 ];
52 license = with licenses; [
53 gpl3
54 cc-by-nc-sa-30
55 geogebra
56 ];
57 sourceProvenance = with sourceTypes; [
58 binaryBytecode
59 binaryNativeCode # some jars include native binaries
60 ];
61 platforms = with platforms; linux ++ darwin;
62 hydraPlatforms = [ ];
63 };
64
65 linuxPkg = stdenv.mkDerivation {
66 inherit
67 pname
68 version
69 meta
70 srcIcon
71 desktopItem
72 ;
73
74 preferLocalBuild = true;
75
76 src = fetchurl {
77 urls = [
78 "https://download.geogebra.org/installers/5.0/GeoGebra-Linux-Portable-${version}.tar.bz2"
79 "https://web.archive.org/web/20230627211902/https://download.geogebra.org/installers/5.0/GeoGebra-Linux-Portable-${version}.tar.bz2"
80 ];
81 hash = "sha256-cL4ERKZpE9Y6IdOjvYiX3nIIW3E2qoqkpMyTszvFseM=";
82 };
83
84 nativeBuildInputs = [ makeWrapper ];
85
86 installPhase = ''
87 install -D geogebra/* -t "$out/libexec/geogebra/"
88
89 # The bundled jogl (required for 3D graphics) links to libXxf86vm, and loads libGL at runtime
90 # OpenGL versions newer than 3.0 cause "javax.media.opengl.GLException: Not a GL2 implementation"
91 makeWrapper "$out/libexec/geogebra/geogebra" "$out/bin/geogebra" \
92 --prefix LD_LIBRARY_PATH : "${
93 lib.makeLibraryPath [
94 libGL
95 xorg.libXxf86vm
96 ]
97 }" \
98 --set MESA_GL_VERSION_OVERRIDE 3.0 \
99 --set JAVACMD "${jre}/bin/java" \
100 --set GG_PATH "$out/libexec/geogebra" \
101 --add-flags "--language=${language}"
102
103 install -Dm644 "${desktopItem}/share/applications/"* \
104 -t $out/share/applications/
105
106 install -Dm644 "${srcIcon}" \
107 "$out/share/icons/hicolor/scalable/apps/geogebra.svg"
108 '';
109 };
110
111 darwinPkg = stdenv.mkDerivation {
112 inherit pname version meta;
113
114 preferLocalBuild = true;
115
116 src = fetchurl {
117 urls = [
118 "https://download.geogebra.org/installers/5.0/GeoGebra-MacOS-Installer-withJava-${version}-x64.zip"
119 "https://web.archive.org/web/20230627211427/https://download.geogebra.org/installers/5.0/GeoGebra-MacOS-Installer-withJava-${version}-x64.zip"
120 ];
121 hash = "sha256-KHjNH8c3/aMJ5CcwCwW9z0QRxJwqYU5I610zpMMruBQ=";
122 };
123
124 dontUnpack = true;
125
126 nativeBuildInputs = [ unzip ];
127
128 installPhase = ''
129 install -dm755 $out/Applications
130 unzip $src -d $out/Applications
131 '';
132 };
133in
134if stdenv.hostPlatform.isDarwin then darwinPkg else linuxPkg