anchor.diff:      # 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
  
positive.code:     # Sage installs during first `make`, `make install` is no-op and just takes time.
    '';
  
    outputs = [ "out" "doc" ];
  
    buildInputs = [
      bash # needed for the build
  
negative.code:     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 = ''
      # 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
  