about summary refs log tree commit diff
path: root/pkgs/applications/science/math
diff options
context:
space:
mode:
authorTimo Kaufmann <timokau@zoho.com>2018-02-11 21:04:52 +0100
committerTimo Kaufmann <timokau@zoho.com>2018-02-13 17:52:41 +0100
commit0713bde50fc117ed8ab1e6cece8ea702f0a0e73f (patch)
treee419d0f7308859bff39d47a8ca369164d54d277b /pkgs/applications/science/math
parenta5cabdb6b11dccdc62f2085868d2d2ec40338d0b (diff)
downloadnixlib-0713bde50fc117ed8ab1e6cece8ea702f0a0e73f.tar
nixlib-0713bde50fc117ed8ab1e6cece8ea702f0a0e73f.tar.gz
nixlib-0713bde50fc117ed8ab1e6cece8ea702f0a0e73f.tar.bz2
nixlib-0713bde50fc117ed8ab1e6cece8ea702f0a0e73f.tar.lz
nixlib-0713bde50fc117ed8ab1e6cece8ea702f0a0e73f.tar.xz
nixlib-0713bde50fc117ed8ab1e6cece8ea702f0a0e73f.tar.zst
nixlib-0713bde50fc117ed8ab1e6cece8ea702f0a0e73f.zip
sage: Don't build docs by default
This makes the HTML-docs an default-off option. Inline documentation
(`matrix-plot??`) is still available and HTML docs are available online.

Motivation: Get below the Hydra output size limit.
Diffstat (limited to 'pkgs/applications/science/math')
-rw-r--r--pkgs/applications/science/math/sage/default.nix31
1 files changed, 23 insertions, 8 deletions
diff --git a/pkgs/applications/science/math/sage/default.nix b/pkgs/applications/science/math/sage/default.nix
index 686e93b5d5e2..ee646fee2c25 100644
--- a/pkgs/applications/science/math/sage/default.nix
+++ b/pkgs/applications/science/math/sage/default.nix
@@ -29,6 +29,7 @@
 , texlive
 , texinfo
 , hevea
+, buildDocs ? false
 }:
 
 stdenv.mkDerivation rec {
@@ -87,7 +88,7 @@ stdenv.mkDerivation rec {
     # Sage installs during first `make`, `make install` is no-op and just takes time.
   '';
 
-  outputs = [ "out" "doc" ];
+  outputs = [ "out" ] ++ stdenv.lib.optionals (buildDocs) [ "doc" ];
 
   buildInputs = [
     bash # needed for the build
@@ -135,13 +136,16 @@ stdenv.mkDerivation rec {
     # TODO could be patched with `sed s|printf(ctime(\(.*\)))|%s... or fixed upstream
   ];
 
+  configureFlags = stdenv.lib.optionals(buildDocs) [ "--docdir=$(doc)" ];
   preConfigure = ''
-    export SAGE_NUM_THREADS=$NIX_BUILD_CORES
+    export SAGE_NUM_THREADS="$NIX_BUILD_CORES"
     export SAGE_ATLAS_ARCH=fast
 
-    export HOME=$out/sage-home
-    mkdir -p $out/sage-home
+    export HOME=/tmp/sage-home
+    export SAGE_ROOT="$PWD"
+    export SAGE_SRC="$PWD"
 
+    mkdir -p "$HOME"
     mkdir -p "$out"
 
     # we need to keep the source around
@@ -150,12 +154,18 @@ stdenv.mkDerivation rec {
     mv "$dir" "$out/sage-root"
 
     cd "$out/sage-root" # build in target dir, since `make` is also `make install`
+  ''
+  + stdenv.lib.optionalString (buildDocs) ''
+    mkdir -p "$doc"
+    export SAGE_DOC="$doc"
+    export SAGE_DOCBUILD_OPTS="--no-pdf-links -k"
+    export SAGE_SPKG_INSTALL_DOCS='no'
   '';
 
+  buildFlags = if (buildDocs) then "doc" else "build";
+
   # for reference: http://doc.sagemath.org/html/en/installation/source.html
   preBuild = ''
-    # TODO do this conditionally
-    export SAGE_SPKG_INSTALL_DOCS='no'
     # symlink python to make sure the shebangs are patched to the sage path
     # while still being able to use python before building it
     # (this is important because otherwise sage will try to install python
@@ -167,10 +177,15 @@ stdenv.mkDerivation rec {
   '';
 
   postBuild = ''
+    # Clean up
     rm -r "$out/sage-root/upstream" # don't keep the sources of all the spkgs
-    rm -r "$out/sage-root/src/build"
-    rm -rf "$out/sage-root/src/.git"
+    rm -rf "$out/sage-root/src/build"
+    rm -rf "$out/sage-root/src/autom4te.cache"
+    rm -rf "$out/sage-root/src/config"
+    rm -rf "$out/sage-root/src/m4"
+    rm -rf "$out/sage-root/.git"
     rm -r "$out/sage-root/logs"
+    rm -r "$out"/lib/python*/test
     # Fix dependency cycle between out and doc
     rm -f "$out/sage-root/config.log"
     rm -f "$out/sage-root/config.status"