summary refs log tree commit diff
diff options
context:
space:
mode:
authorMauricio Collares <mauricio@collares.org>2023-05-21 16:26:59 +0200
committerMauricio Collares <mauricio@collares.org>2023-05-21 22:37:53 +0200
commitc13e4258f6bc07334eb3f18383e028cf47ea8b87 (patch)
tree0833d8971d26a789a0b7f78a1e9782c0f9ccd1bc
parent0edaaae3ffd117b88879bf655260654947ee2dc4 (diff)
downloadnixpkgs-c13e4258f6bc07334eb3f18383e028cf47ea8b87.tar
nixpkgs-c13e4258f6bc07334eb3f18383e028cf47ea8b87.tar.gz
nixpkgs-c13e4258f6bc07334eb3f18383e028cf47ea8b87.tar.bz2
nixpkgs-c13e4258f6bc07334eb3f18383e028cf47ea8b87.tar.lz
nixpkgs-c13e4258f6bc07334eb3f18383e028cf47ea8b87.tar.xz
nixpkgs-c13e4258f6bc07334eb3f18383e028cf47ea8b87.tar.zst
nixpkgs-c13e4258f6bc07334eb3f18383e028cf47ea8b87.zip
sageWithDoc: run src/doc/bootstrap script before docbuild
-rw-r--r--pkgs/applications/science/math/sage/sage-src.nix11
-rw-r--r--pkgs/applications/science/math/sage/sagedoc.nix27
2 files changed, 21 insertions, 17 deletions
diff --git a/pkgs/applications/science/math/sage/sage-src.nix b/pkgs/applications/science/math/sage/sage-src.nix
index 7f168aa5ff9..4f533a822de 100644
--- a/pkgs/applications/science/math/sage/sage-src.nix
+++ b/pkgs/applications/science/math/sage/sage-src.nix
@@ -92,17 +92,6 @@ stdenv.mkDerivation rec {
     sed -i \
       "s|var(\"SAGE_ROOT\".*|var(\"SAGE_ROOT\", \"$out\")|" \
       src/sage/env.py
-
-    # docbuilding expects a spkg index generated by the doc/bootstrap script (which
-    # we don't run) to exist. the spkg list includes nix package names, but it's not
-    # worth the hassle of running the bootstrap script, so just create a dummy index.
-    touch src/doc/en/reference/spkg/index.rst
-
-    # the bootstrap script also generates installation instructions for
-    # arch, debian, fedora, cygwin and homebrew using data from build/pkgs.
-    # we don't run the bootstrap script, so disable including the generated
-    # files. docbuilding fails otherwise.
-    sed -i "/literalinclude/d" src/doc/en/installation/source.rst
   '';
 
   buildPhase = "# do nothing";
diff --git a/pkgs/applications/science/math/sage/sagedoc.nix b/pkgs/applications/science/math/sage/sagedoc.nix
index 650b6d3b141..228b5aa2c60 100644
--- a/pkgs/applications/science/math/sage/sagedoc.nix
+++ b/pkgs/applications/science/math/sage/sagedoc.nix
@@ -11,6 +11,11 @@ stdenv.mkDerivation rec {
 
   strictDeps = true;
 
+  nativeBuildInputs = [
+    # for patchShebangs below
+    python3
+  ];
+
   unpackPhase = ''
     export SAGE_DOC_OVERRIDE="$PWD/share/doc/sage"
     export SAGE_DOC_SRC_OVERRIDE="$PWD/docsrc"
@@ -24,15 +29,25 @@ stdenv.mkDerivation rec {
     export HOME="$TMPDIR/sage_home"
     mkdir -p "$HOME"
 
+    # run bootstrap script to generate Sage spkg docs, because unfortunately some unrelated doc
+    # pages link to them. it needs a few ugly (but self-contained) hacks for a standalone run.
+    cp -r "${src}/build" "$HOME"
+    chmod -R 755 "$HOME/build"
+    sed -i "/assert/d" "$HOME/build/sage_bootstrap/env.py"
+    sed -i "s|sage-bootstrap-python|python3|" "$HOME/build/bin/sage-package"
+    patchShebangs "$HOME/build/bin/sage-package"
+    pushd "$SAGE_DOC_SRC_OVERRIDE"
+    sed -i "s|OUTPUT_DIR=\"src/doc/|OUTPUT_DIR=\"$SAGE_DOC_SRC_OVERRIDE/|" bootstrap
+    PATH="$HOME/build/bin:$PATH" SAGE_ROOT="${src}" ./bootstrap
+    popd
+
+    # adapted from src/doc/Makefile (doc-src target), which tries to call Sage from PATH
+    mkdir -p $SAGE_DOC_SRC_OVERRIDE/en/reference/repl
+    ${sage-with-env}/bin/sage -advanced > $SAGE_DOC_SRC_OVERRIDE/en/reference/repl/options.txt
+
     # needed to link them in the sage docs using intersphinx
     export PPLPY_DOCS=${python3.pkgs.pplpy.doc}/share/doc/pplpy
 
-    # adapted from src/doc/bootstrap (which we don't run)
-    OUTPUT_DIR="$SAGE_DOC_SRC_OVERRIDE/en/reference/repl"
-    mkdir -p "$OUTPUT_DIR"
-    OUTPUT="$OUTPUT_DIR/options.txt"
-    ${sage-with-env}/bin/sage -advanced > "$OUTPUT"
-
     # jupyter-sphinx calls the sagemath jupyter kernel during docbuild
     export JUPYTER_PATH=${jupyter-kernel-specs}