about summary refs log tree commit diff
path: root/pkgs/applications/science/math/sage
diff options
context:
space:
mode:
authorGaraba Flórián <garaba.florian@protonmail.com>2021-04-17 10:23:29 -0300
committerMasanori Ogino <167209+omasanori@users.noreply.github.com>2021-04-22 14:06:56 +0900
commita0f410646c54c19f7bc239f25178cb1ffe7608d4 (patch)
treee160629c5756c5a44f89a09b0cf497c1773a05bb /pkgs/applications/science/math/sage
parent090165d7c17f814cfe458b22026fda026888f78b (diff)
sage: use threejs fork
Diffstat (limited to 'pkgs/applications/science/math/sage')
-rw-r--r--pkgs/applications/science/math/sage/default.nix6
-rw-r--r--pkgs/applications/science/math/sage/patches/dont-grep-threejs-version-from-minified-js.patch16
-rw-r--r--pkgs/applications/science/math/sage/sage-src.nix3
-rw-r--r--pkgs/applications/science/math/sage/threejs-sage.nix18
4 files changed, 22 insertions, 21 deletions
diff --git a/pkgs/applications/science/math/sage/default.nix b/pkgs/applications/science/math/sage/default.nix
index 8ef1f5189e5b9..4a18d1e88a603 100644
--- a/pkgs/applications/science/math/sage/default.nix
+++ b/pkgs/applications/science/math/sage/default.nix
@@ -38,14 +38,16 @@ let
     logo64 = "${sage-src}/doc/common/themes/sage/static/sageicon.png";
   };
 
+  three = callPackage ./threejs-sage.nix { };
+
   # A bash script setting various environment variables to tell sage where
   # the files its looking fore are located. Also see `sage-env`.
   env-locations = callPackage ./env-locations.nix {
     inherit pari_data;
     inherit singular maxima-ecl;
+    inherit three;
     ecl = maxima-ecl.ecl;
     cysignals = python3.pkgs.cysignals;
-    three = nodePackages.three;
     mathjax = nodePackages.mathjax;
   };
 
@@ -70,8 +72,8 @@ let
     inherit python3 pythonEnv;
     inherit sage-env;
     inherit pynac singular maxima-ecl;
+    inherit three;
     pkg-config = pkgs.pkg-config; # not to confuse with pythonPackages.pkg-config
-    three = nodePackages.three;
   };
 
   # Doesn't actually build anything, just runs sages testsuite. This is a
diff --git a/pkgs/applications/science/math/sage/patches/dont-grep-threejs-version-from-minified-js.patch b/pkgs/applications/science/math/sage/patches/dont-grep-threejs-version-from-minified-js.patch
deleted file mode 100644
index 88cb66506b1d7..0000000000000
--- a/pkgs/applications/science/math/sage/patches/dont-grep-threejs-version-from-minified-js.patch
+++ /dev/null
@@ -1,16 +0,0 @@
-diff --git a/src/sage/repl/rich_output/display_manager.py b/src/sage/repl/rich_output/display_manager.py
-index fb21f7a9c9..f39470777d 100644
---- a/src/sage/repl/rich_output/display_manager.py
-+++ b/src/sage/repl/rich_output/display_manager.py
-@@ -749,9 +749,9 @@ class DisplayManager(SageObject):
-             import sage.env
-             import re
-             import os
--            with open(os.path.join(sage.env.THREEJS_DIR, 'build', 'three.min.js')) as f:
-+            with open(os.path.join(sage.env.THREEJS_DIR, 'build', 'three.js')) as f:
-                 text = f.read().replace('\n','')
--            version = re.search(r'REVISION="(\d+)"', text).group(1)
-+            version = re.search(r"REVISION = '(\d+)'", text).group(1)
-             return """
- <script src="https://cdn.jsdelivr.net/gh/mrdoob/three.js@r{0}/build/three.min.js"></script>
- <script src="https://cdn.jsdelivr.net/gh/mrdoob/three.js@r{0}/examples/js/controls/OrbitControls.js"></script>
diff --git a/pkgs/applications/science/math/sage/sage-src.nix b/pkgs/applications/science/math/sage/sage-src.nix
index 1fb605b359987..8ac5143f44369 100644
--- a/pkgs/applications/science/math/sage/sage-src.nix
+++ b/pkgs/applications/science/math/sage/sage-src.nix
@@ -131,9 +131,6 @@ stdenv.mkDerivation rec {
     # fix test output with sympy 1.7 (https://trac.sagemath.org/ticket/30985)
     ./patches/sympy-1.7-update.patch
 
-    # workaround until we use sage's fork of threejs, which contains a "version" file
-    ./patches/dont-grep-threejs-version-from-minified-js.patch
-
     # updated eclib output has punctuation changes and tidier whitespace
     ./patches/eclib-20210223-test-formatting.patch
 
diff --git a/pkgs/applications/science/math/sage/threejs-sage.nix b/pkgs/applications/science/math/sage/threejs-sage.nix
new file mode 100644
index 0000000000000..0e4ad4dee955a
--- /dev/null
+++ b/pkgs/applications/science/math/sage/threejs-sage.nix
@@ -0,0 +1,18 @@
+{ stdenv, fetchFromGitHub }:
+
+stdenv.mkDerivation rec {
+  pname = "threejs-sage";
+  version = "r122";
+
+  src = fetchFromGitHub {
+    owner = "sagemath";
+    repo = "threejs-sage";
+    rev = version;
+    sha256 = "sha256-xPAPt36Fon3hYQq6SOmGkIyUzAII2LMl10nqYG4UPI0=";
+  };
+
+  installPhase = ''
+    mkdir -p $out/lib/node_modules/three
+    cp -r build version $out/lib/node_modules/three
+  '';
+}