diff options
-rw-r--r-- | lib/maintainers.nix | 1 | ||||
-rw-r--r-- | pkgs/applications/science/math/sage/default.nix | 173 | ||||
-rw-r--r-- | pkgs/applications/science/math/sage/env.patch | 22 | ||||
-rwxr-xr-x | pkgs/applications/science/math/sage/fetch-mirrors.sh | 11 | ||||
-rw-r--r-- | pkgs/applications/science/math/sage/spkg-giac.patch | 11 | ||||
-rw-r--r-- | pkgs/applications/science/math/sage/spkg-git.patch | 14 | ||||
-rw-r--r-- | pkgs/applications/science/math/sage/spkg-python.patch | 11 | ||||
-rw-r--r-- | pkgs/applications/science/math/sage/spkg-python2.patch | 12 | ||||
-rw-r--r-- | pkgs/applications/science/math/sage/spkg-python3.patch | 12 | ||||
-rw-r--r-- | pkgs/applications/science/math/sage/spkg-singular.patch | 36 |
10 files changed, 244 insertions, 59 deletions
diff --git a/lib/maintainers.nix b/lib/maintainers.nix index e2d3c73301b44..a1a6d36b69839 100644 --- a/lib/maintainers.nix +++ b/lib/maintainers.nix @@ -627,6 +627,7 @@ ThomasMader = "Thomas Mader <thomas.mader@gmail.com>"; thoughtpolice = "Austin Seipp <aseipp@pobox.com>"; timbertson = "Tim Cuthbertson <tim@gfxmonk.net>"; + timokau = "Timo Kaufmann <timokau@zoho.com>"; titanous = "Jonathan Rudenberg <jonathan@titanous.com>"; tnias = "Philipp Bartsch <phil@grmr.de>"; tohl = "Tomas Hlavaty <tom@logand.com>"; diff --git a/pkgs/applications/science/math/sage/default.nix b/pkgs/applications/science/math/sage/default.nix index bf3c7fcea9899..c1b5484da0f6b 100644 --- a/pkgs/applications/science/math/sage/default.nix +++ b/pkgs/applications/science/math/sage/default.nix @@ -1,42 +1,183 @@ -{ stdenv, fetchurl, m4, perl, gfortran, texlive, ffmpeg, tk, gnused_422 -, imagemagick, liblapack, python, openssl, libpng +# TODO +# - consider writing a script to convert spkgs to nix packages, similar to vim +# or cabal2nix. This would allow a more efficient and "cleaner" build, greater +# flexibility and the possibility to select which dependencies to add and which +# to remove. It would also allow to use system packages for some dependencies +# and recompile others (optimized for the system) without recompiling everything. +# - add optdeps: +# - imagemagick +# - texlive full for documentation +# - ... +# - further seperate build outputs. Also maybe run `make doc`. +# Configure flags like --bindir and --libdir oculd also be used for that, see +# ./configure --help`. + +# Other resources: +# - https://wiki.debian.org/DebianScience/Sage +# - https://github.com/cschwan/sage-on-gentoo +# - https://git.archlinux.org/svntogit/community.git/tree/trunk?h=packages/sagemath + +{ stdenv +, fetchurl +, perl +, gfortran +, python +, autoreconfHook +, gettext , which +, texlive +, hevea }: stdenv.mkDerivation rec { - name = "sage-6.8"; + version = "8.0"; + name = "sage-${version}"; src = fetchurl { - url = "http://old.files.sagemath.org/src-old/${name}.tar.gz"; - sha256 = "102mrzzi215g1xn5zgcv501x9sghwg758jagx2jixvg1rj2jijj9"; - + # Note that the source is *not* fetched from github, since that doesn't + # the upstream folder with all the source tarballs of the spkgs. + # If those are not present they are fetched at build time, which breaks + # when building in a sandbox (and probably only works if you install the + # latest sage version). + urls = [ + "http://mirrors.mit.edu/sage/src/sage-${version}.tar.gz" + "ftp://ftp.fu-berlin.de/unix/misc/sage/src/sage-${version}.tar.gz" + "http://sagemath.polytechnic.edu.na/src/sage-${version}.tar.gz" + "ftp://ftp.sun.ac.za/pub/mirrors/www.sagemath.org/src/sage-${version}.tar.gz" + "http://sagemath.mirror.ac.za/src/sage-${version}.tar.gz" + "http://ftp.leg.uct.ac.za/pub/packages/sage/src/sage-${version}.tar.gz" + "http://mirror.ufs.ac.za/sagemath/src/sage-${version}.tar.gz" + "http://mirrors-usa.go-parts.com/sage/sagemath/src/sage-${version}.tar.gz" + "http://www.cecm.sfu.ca/sage/src/sage-${version}.tar.gz" + "http://files.sagemath.org/src/sage-${version}.tar.gz" + "http://mirrors.xmission.com/sage/src/sage-${version}.tar.gz" + "http://sagemath.c3sl.ufpr.br/src/sage-${version}.tar.gz" + "http://linorg.usp.br/sage/src/sage-${version}.tar.gz" + "http://mirror.hust.edu.cn/sagemath/src/sage-${version}.tar.gz" + "http://ftp.iitm.ac.in/sage/src/sage-${version}.tar.gz" + "http://ftp.kaist.ac.kr/sage/src/sage-${version}.tar.gz" + "http://ftp.riken.jp/sagemath/src/sage-${version}.tar.gz" + "http://mirrors.tuna.tsinghua.edu.cn/sagemath/src/sage-${version}.tar.gz" + "http://mirrors.ustc.edu.cn/sagemath/src/sage-${version}.tar.gz" + "http://ftp.tsukuba.wide.ad.jp/software/sage/src/sage-${version}.tar.gz" + "http://ftp.yz.yamagata-u.ac.jp/pub/math/sage/src/sage-${version}.tar.gz" + "http://mirror.yandex.ru/mirrors/sage.math.washington.edu/src/sage-${version}.tar.gz" + "http://mirror.aarnet.edu.au/pub/sage/src/sage-${version}.tar.gz" + "http://sage.mirror.garr.it/mirrors/sage/src/sage-${version}.tar.gz" + "http://www.mirrorservice.org/sites/www.sagemath.org/src/sage-${version}.tar.gz" + "http://mirror.switch.ch/mirror/sagemath/src/sage-${version}.tar.gz" + "https://mirrors.up.pt/pub/sage/src/sage-${version}.tar.gz" + "http://www-ftp.lip6.fr/pub/math/sagemath/src/sage-${version}.tar.gz" + "http://ftp.ntua.gr/pub/sagemath/src/sage-${version}.tar.gz" + ]; + sha256 = "1a9rhb8jby6fdqa2s7n2fl9jwqqlsl7qz7dbpbwvg6jwlrvni7fg"; }; - buildInputs = [ m4 perl gfortran texlive.combined.scheme-basic ffmpeg gnused_422 tk imagemagick liblapack - python openssl libpng which ]; + postPatch = '' + substituteAllInPlace src/bin/sage-env + ''; - patches = [ ./spkg-singular.patch ./spkg-python.patch ./spkg-git.patch ]; + installPhase = '' + # Sage installs during first `make`, `make install` is no-op and just takes time. + ''; + + outputs = [ "out" "doc" ]; + + buildInputs = [ + perl # needed for the build + python # needed for the build + gfortran # needed to build giac + autoreconfHook # needed to configure sage with prefix + gettext # needed to build the singular spkg + hevea # needed to build the docs of the giac spkg + which # needed in configure of mpir + # needed to build the docs of the giac spkg + (texlive.combine { inherit (texlive) + scheme-basic + collection-pstricks # needed by giac + times # font needed by giac + stmaryrd # needed by giac + babel-greek # optional for giac, otherwise throws a bunch of latex command not founds + ; + }) + ]; + + patches = [ + # fix usages of /bin/rm + ./spkg-singular.patch + # help python find the crypt library + ./spkg-python2.patch + ./spkg-python3.patch + # fix usages of /usr/bin/perl + ./spkg-git.patch + # fix usages of /bin/cp and add necessary argument to function call + ./spkg-giac.patch + # environment + ./env.patch + ]; enableParallelBuilding = true; - hardeningDisable = [ "format" ]; + hardeningDisable = [ + "format" # needed to build palp, for lines like `printf(ctime(&_NFL->TIME))` + # TODO could be patched with `sed s|printf(ctime(\(.*\)))|%s... or fixed upstream + ]; preConfigure = '' export SAGE_NUM_THREADS=$NIX_BUILD_CORES export SAGE_ATLAS_ARCH=fast - mkdir -p $out/sageHome - export HOME=$out/sageHome - export CPPFLAGS="-P" + + export HOME=$out/sage-home + mkdir -p $out/sage-home + + mkdir -p "$out" + + # we need to keep the source around + dir="$PWD" + cd .. + mv "$dir" "$out/sage-root" + + cd "$out/sage-root" # build in target dir, since `make` is also `make install` + ''; + + # for reference: http://doc.sagemath.org/html/en/installation/source.html + preBuild = '' + # TODO do this conditionally + export SAGE_SPKG_INSTALL_DOCS='no' + patchShebangs build + ''; + + postBuild = '' + 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 -r "$out/sage-root/logs" + # Fix dependency cycle between out and doc + rm -f "$out/sage-root/config.status" + rm -f "$out/sage-root/build/make/Makefile-auto" + rm -f "$out/sage-home/.sage/gap/libgap-workspace-"* ''; - preBuild = "patchShebangs build"; + # TODO there are some doctest failures, which seem harmless. + # We should figure out a way to fix the failures or ignore only those tests. + doCheck = false; - installPhase = ''DESTDIR=$out make install''; + checkTarget = "ptestalllong"; # all long tests in parallell + preCheck = '' + export SAGE_TIMEOUT=0 # no timeout + export SAGE_TIMEOUT_LONG=0 # no timeout + ''; meta = { homepage = http://www.sagemath.org; description = "A free open source mathematics software system"; + # taken from the homepage + longDescription = '' + SageMath is a free open-source mathematics software system licensed under the GPL. It builds on top of many existing open-source packages: NumPy, SciPy, matplotlib, Sympy, Maxima, GAP, FLINT, R and many more. Access their combined power through a common, Python-based language or directly via interfaces or wrappers. + Mission: Creating a viable free open source alternative to Magma, Maple, Mathematica and Matlab. + ''; license = stdenv.lib.licenses.gpl2Plus; - broken = true; + platforms = stdenv.lib.platforms.all; + maintainers = with stdenv.lib.maintainers; [ timokau ]; }; } diff --git a/pkgs/applications/science/math/sage/env.patch b/pkgs/applications/science/math/sage/env.patch new file mode 100644 index 0000000000000..a7f8538eac3d4 --- /dev/null +++ b/pkgs/applications/science/math/sage/env.patch @@ -0,0 +1,22 @@ +diff --git a/src/bin/sage-env b/src/bin/sage-env +index ead308f861..ed8db9f9b7 100644 +--- a/src/bin/sage-env ++++ b/src/bin/sage-env +@@ -111,6 +111,8 @@ resolvelinks() { + } + + ++SAGE_ROOT="@out@/sage-root" ++ + # New value for SAGE_ROOT: either SAGE_ROOT (if given) + # or a guessed value based on pwd. + if [ -n "$SAGE_ROOT" ]; then +@@ -185,6 +187,8 @@ fi + export SAGE_ENV_SOURCED=$SAGE_ENV_VERSION + + export SAGE_ROOT="$NEW_SAGE_ROOT" ++export SAGE_LOCAL='@out@/' ++export PYTHONPATH="@out@/lib/python2.7/site-packages:$PYTHONPATH" + + + # sage-env must know where the Sage's script files are. diff --git a/pkgs/applications/science/math/sage/fetch-mirrors.sh b/pkgs/applications/science/math/sage/fetch-mirrors.sh new file mode 100755 index 0000000000000..a1103e86beb9c --- /dev/null +++ b/pkgs/applications/science/math/sage/fetch-mirrors.sh @@ -0,0 +1,11 @@ +#! /usr/bin/env nix-shell +#! nix-shell -i bash -p curl go-pup + +# Fetches a list of all available source mirrors from the sage homepage. +# Note that the list is sorted by country, but fetchurl doesn't offer an option +# to customize mirror preference. + +curl -s http://www.sagemath.org/download-source.html \ + | pup 'table#mirror' \ + | pup 'a attr{href}' \ + | sed -e 's/index\.html/sage-${version}.tar.gz/' diff --git a/pkgs/applications/science/math/sage/spkg-giac.patch b/pkgs/applications/science/math/sage/spkg-giac.patch new file mode 100644 index 0000000000000..15b91433d2544 --- /dev/null +++ b/pkgs/applications/science/math/sage/spkg-giac.patch @@ -0,0 +1,11 @@ +--- old/build/pkgs/giac/spkg-install 2017-07-21 14:10:00.000000000 -0500 ++++ new/build/pkgs/giac/spkg-install 2017-10-15 15:55:55.321237645 -0500 +@@ -4,6 +4,8 @@ + ## Giac + ########################################### + ++find . -type f -exec sed -e 's@/bin/cp@cp@g' -i '{}' ';' && echo "Patching input parser" && find . -iname 'input_parser.cc' ++sed -e 's@yylex (&yylval)@yylex (\&yyval, scanner)@gp' -i 'src/src/input_parser.cc' + + if [ "$SAGE_LOCAL" = "" ]; then + echo "SAGE_LOCAL undefined ... exiting"; diff --git a/pkgs/applications/science/math/sage/spkg-git.patch b/pkgs/applications/science/math/sage/spkg-git.patch index a3e768a7c2401..ff9a7b2e491a2 100644 --- a/pkgs/applications/science/math/sage/spkg-git.patch +++ b/pkgs/applications/science/math/sage/spkg-git.patch @@ -1,10 +1,12 @@ ---- old/build/pkgs/git/spkg-install 2015-07-26 15:34:43.000000000 +0200 -+++ new/build/pkgs/git/spkg-install 2015-09-17 08:28:03.586657451 +0200 -@@ -45,6 +45,8 @@ - fi - done +diff --git a/build/pkgs/git/spkg-install b/build/pkgs/git/spkg-install +index 8469cb58c2..d0dc9a1db9 100755 +--- a/build/pkgs/git/spkg-install ++++ b/build/pkgs/git/spkg-install +@@ -35,6 +35,8 @@ fi -+find . -exec sed -e 's@/usr/bin/perl@perl@g' -i '{}' ';' + cd src + ++find . -type f -exec sed -e 's@/usr/bin/perl@perl@g' -i '{}' ';' + # We don't want to think about Fink or Macports export NO_FINK=1 diff --git a/pkgs/applications/science/math/sage/spkg-python.patch b/pkgs/applications/science/math/sage/spkg-python.patch deleted file mode 100644 index 4db9427e3e02f..0000000000000 --- a/pkgs/applications/science/math/sage/spkg-python.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- old/build/pkgs/python2/spkg-install 2015-07-26 15:34:43.000000000 +0200 -+++ new/build/pkgs/python2/spkg-install 2015-09-16 20:48:51.904555797 +0200 -@@ -32,7 +32,7 @@ - done - - # We are setting LDFLAGS so that we pick up Sage's readline --LDFLAGS="-L$SAGE_LOCAL/lib $LDFLAGS" -+LDFLAGS="-L$SAGE_LOCAL/lib -lcrypt $LDFLAGS" - export LDFLAGS - - if [ "$SAGE_DEBUG" = "yes" ]; then diff --git a/pkgs/applications/science/math/sage/spkg-python2.patch b/pkgs/applications/science/math/sage/spkg-python2.patch new file mode 100644 index 0000000000000..5d92d3f8beafc --- /dev/null +++ b/pkgs/applications/science/math/sage/spkg-python2.patch @@ -0,0 +1,12 @@ +--- old/build/pkgs/python2/spkg-install 2017-07-21 14:10:00.000000000 -0500 ++++ new/build/pkgs/python2/spkg-install 2017-10-15 11:26:54.823134067 -0500 +@@ -22,6 +22,9 @@ + + cd src + ++LDFLAGS="-lcrypt $LDFLAGS" ++export LDFLAGS ++ + if [ "$SAGE_DEBUG" = "yes" ]; then + echo "Building Python with pydebug" + PYTHON_CONFIGURE="$PYTHON_CONFIGURE --with-pydebug" diff --git a/pkgs/applications/science/math/sage/spkg-python3.patch b/pkgs/applications/science/math/sage/spkg-python3.patch new file mode 100644 index 0000000000000..51827fd11be05 --- /dev/null +++ b/pkgs/applications/science/math/sage/spkg-python3.patch @@ -0,0 +1,12 @@ +--- old/build/pkgs/python3/spkg-install 2017-07-21 14:10:00.000000000 -0500 ++++ new/build/pkgs/python3/spkg-install 2017-10-15 13:11:17.769261404 -0500 +@@ -22,6 +22,9 @@ + + cd src + ++LDFLAGS="-lcrypt $LDFLAGS" ++export LDFLAGS ++ + if [ "$SAGE_DEBUG" = "yes" ]; then + echo "Building Python with pydebug" + PYTHON_CONFIGURE="$PYTHON_CONFIGURE --with-pydebug" diff --git a/pkgs/applications/science/math/sage/spkg-singular.patch b/pkgs/applications/science/math/sage/spkg-singular.patch index a4c29825a4c4a..d561768600b4b 100644 --- a/pkgs/applications/science/math/sage/spkg-singular.patch +++ b/pkgs/applications/science/math/sage/spkg-singular.patch @@ -1,28 +1,12 @@ ---- old/build/pkgs/singular/spkg-install 2015-07-26 15:34:43.000000000 +0200 -+++ new/build/pkgs/singular/spkg-install 2015-09-15 20:42:51.716505855 +0200 -@@ -115,6 +115,11 @@ - done - } +--- old/build/pkgs/singular/spkg-install 2017-10-15 10:35:41.826540964 -0500 ++++ new/build/pkgs/singular/spkg-install 2017-10-15 10:36:40.613743443 -0500 +@@ -4,6 +4,9 @@ + ## Singular + ########################################### -+nix_nuke_bin_rm() -+{ -+ find . -exec sed -e 's@/bin/rm@rm@g' -i '{}' ';' -+} ++find . -type f -exec sed -e 's@/bin/rm@rm@g' -i '{}' ';' ++#echo '#!/usr/bin/env bash\nIgnoring missing $1' > src/build-aux/missing + - remove_old_version() - { - rm -f "$SAGE_LOCAL"/bin/Singular* -@@ -306,11 +311,11 @@ - - - # Actually run all the functions defined above --for i in choose_patches apply_patches remove_old_version config \ -+for i in choose_patches apply_patches nix_nuke_bin_rm remove_old_version config \ - build_singular build_libsingular build_factory build_libfac \ - create_singular_script install_docs ; do - echo "### Singular spkg-install: $i ###" -- cd "$SRC" && $i -+ cd "$SRC" && pwd && $i - if [ $? -ne 0 ]; then - echo >&2 "Error building Singular (error in $i)." - exit 1 + if [ -z "$SAGE_LOCAL" ]; then + echo >&2 "Error: SAGE_LOCAL undefined -- exiting..." + echo >&2 "Maybe run 'sage -sh'?" |