diff --git a/pkgs/applications/science/math/sage/default.nix b/pkgs/applications/science/math/sage/default.nix index 70e24e2608d..84b511de8fc 100644 --- a/pkgs/applications/science/math/sage/default.nix +++ b/pkgs/applications/science/math/sage/default.nix @@ -48,6 +48,12 @@ let logo64 = "${sage-src}/src/doc/common/themes/sage/static/sageicon.png"; }; + jupyter-kernel-specs = pkgs.jupyter-kernel.create { + definitions = pkgs.jupyter-kernel.default // { + sagemath = jupyter-kernel-definition; + }; + }; + three = callPackage ./threejs-sage.nix { }; # A bash script setting various environment variables to tell sage where @@ -73,7 +79,7 @@ let # The documentation for sage, building it takes a lot of ram. sagedoc = callPackage ./sagedoc.nix { inherit sage-with-env; - inherit python3 maxima; + inherit python3 maxima jupyter-kernel-specs; }; # sagelib with added wrappers and a dependency on sage-tests to make sure thet tests were run. @@ -167,6 +173,6 @@ let in # A wrapper around sage that makes sure sage finds its docs (if they were build). callPackage ./sage.nix { - inherit sage-tests sage-with-env sagedoc jupyter-kernel-definition; + inherit sage-tests sage-with-env sagedoc jupyter-kernel-specs; inherit withDoc requireSageTests; } diff --git a/pkgs/applications/science/math/sage/python-modules/sage-docbuild.nix b/pkgs/applications/science/math/sage/python-modules/sage-docbuild.nix index 1766cec3e35..b0f40bf0658 100644 --- a/pkgs/applications/science/math/sage/python-modules/sage-docbuild.nix +++ b/pkgs/applications/science/math/sage/python-modules/sage-docbuild.nix @@ -2,6 +2,7 @@ , buildPythonPackage , sage-src , sphinx +, jupyter-sphinx }: buildPythonPackage rec { @@ -11,6 +12,7 @@ buildPythonPackage rec { propagatedBuildInputs = [ sphinx + jupyter-sphinx ]; preBuild = '' diff --git a/pkgs/applications/science/math/sage/sage.nix b/pkgs/applications/science/math/sage/sage.nix index 96122fba5ab..78fd8d598d0 100644 --- a/pkgs/applications/science/math/sage/sage.nix +++ b/pkgs/applications/science/math/sage/sage.nix @@ -2,8 +2,7 @@ , makeWrapper , sage-tests , sage-with-env -, jupyter-kernel-definition -, jupyter-kernel +, jupyter-kernel-specs , sagedoc , withDoc , requireSageTests @@ -12,14 +11,6 @@ # A wrapper that makes sure sage finds its docs (if they were build) and the # jupyter kernel spec. -let - # generate kernel spec + default kernels - kernel-specs = jupyter-kernel.create { - definitions = jupyter-kernel.default // { - sagemath = jupyter-kernel-definition; - }; - }; -in stdenv.mkDerivation rec { version = src.version; pname = "sage"; @@ -43,7 +34,7 @@ stdenv.mkDerivation rec { --set SAGE_DOC_SRC_OVERRIDE "${src}/src/doc" ${ lib.optionalString withDoc "--set SAGE_DOC_OVERRIDE ${sagedoc}/share/doc/sage" } \ - --prefix JUPYTER_PATH : "${kernel-specs}" + --prefix JUPYTER_PATH : "${jupyter-kernel-specs}" ''; doInstallCheck = withDoc; @@ -58,7 +49,7 @@ stdenv.mkDerivation rec { quicktest = sage-tests.override { longTests = false; timeLimit = 600; }; # as many tests as possible in ~10m doc = sagedoc; lib = sage-with-env.env.lib; - kernelspec = jupyter-kernel-definition; + kernelspec = jupyter-kernel-specs.definition.sagemath; }; meta = with lib; { diff --git a/pkgs/applications/science/math/sage/sagedoc.nix b/pkgs/applications/science/math/sage/sagedoc.nix index 489fc2edfe5..55674719064 100644 --- a/pkgs/applications/science/math/sage/sagedoc.nix +++ b/pkgs/applications/science/math/sage/sagedoc.nix @@ -1,6 +1,7 @@ { stdenv , sage-with-env , python3 +, jupyter-kernel-specs , maxima , tachyon , jmol @@ -59,10 +60,15 @@ stdenv.mkDerivation rec { OUTPUT="$OUTPUT_DIR/options.txt" ${sage-with-env}/bin/sage -advanced > "$OUTPUT" - ${sage-with-env}/bin/sage --docbuild \ + # jupyter-sphinx calls the sagemath jupyter kernel during docbuild + export JUPYTER_PATH=${jupyter-kernel-specs} + + # sage --docbuild unsets JUPYTER_PATH, so we call sage_docbuild directly + # https://trac.sagemath.org/ticket/33650#comment:32 + ${sage-with-env}/bin/sage --python3 -m sage_docbuild \ --mathjax \ --no-pdf-links \ - all html + all html < /dev/null ''; installPhase = ''