2021-01-11 07:54:33 +00:00
|
|
|
{ lib, stdenv
|
2018-04-24 21:53:36 +00:00
|
|
|
, makeWrapper
|
2018-11-12 22:28:29 +00:00
|
|
|
, sage-tests
|
|
|
|
, sage-with-env
|
2022-05-23 15:55:11 +00:00
|
|
|
, jupyter-kernel-definition
|
2022-05-04 08:37:18 +00:00
|
|
|
, jupyter-kernel-specs
|
2018-11-12 22:28:29 +00:00
|
|
|
, sagedoc
|
|
|
|
, withDoc
|
2022-02-25 20:24:38 +00:00
|
|
|
, requireSageTests
|
2018-04-24 21:53:36 +00:00
|
|
|
}:
|
|
|
|
|
2018-11-25 14:54:31 +00:00
|
|
|
# A wrapper that makes sure sage finds its docs (if they were build) and the
|
|
|
|
# jupyter kernel spec.
|
2018-11-12 22:28:29 +00:00
|
|
|
|
2018-04-24 21:53:36 +00:00
|
|
|
stdenv.mkDerivation rec {
|
2018-11-12 22:28:29 +00:00
|
|
|
version = src.version;
|
2019-08-15 12:41:18 +00:00
|
|
|
pname = "sage";
|
2018-11-12 22:28:29 +00:00
|
|
|
src = sage-with-env.env.lib.src;
|
2018-04-24 21:53:36 +00:00
|
|
|
|
2022-08-15 03:40:21 +00:00
|
|
|
nativeBuildInputs = [ makeWrapper ];
|
|
|
|
buildInputs = lib.optionals requireSageTests [
|
2018-11-12 22:28:29 +00:00
|
|
|
# This is a hack to make sure sage-tests is evaluated. It doesn't acutally
|
|
|
|
# produce anything of value, it just decouples the tests from the build.
|
|
|
|
sage-tests
|
2018-04-24 21:53:36 +00:00
|
|
|
];
|
|
|
|
|
2019-06-19 15:45:34 +00:00
|
|
|
dontUnpack = true;
|
2018-04-24 21:53:36 +00:00
|
|
|
configurePhase = "#do nothing";
|
|
|
|
buildPhase = "#do nothing";
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
mkdir -p "$out/bin"
|
2018-11-12 22:28:29 +00:00
|
|
|
makeWrapper "${sage-with-env}/bin/sage" "$out/bin/sage" \
|
|
|
|
--set SAGE_DOC_SRC_OVERRIDE "${src}/src/doc" ${
|
2021-01-15 13:21:58 +00:00
|
|
|
lib.optionalString withDoc "--set SAGE_DOC_OVERRIDE ${sagedoc}/share/doc/sage"
|
2018-11-25 14:54:31 +00:00
|
|
|
} \
|
2022-05-04 08:37:18 +00:00
|
|
|
--prefix JUPYTER_PATH : "${jupyter-kernel-specs}"
|
2018-04-24 21:53:36 +00:00
|
|
|
'';
|
|
|
|
|
2018-11-12 22:28:29 +00:00
|
|
|
doInstallCheck = withDoc;
|
2018-04-24 21:53:36 +00:00
|
|
|
installCheckPhase = ''
|
|
|
|
export HOME="$TMPDIR/sage-home"
|
|
|
|
mkdir -p "$HOME"
|
2018-11-12 22:28:29 +00:00
|
|
|
"$out/bin/sage" -c 'browse_sage_doc._open("reference", testing=True)'
|
2018-04-24 21:53:36 +00:00
|
|
|
'';
|
2018-11-12 22:28:29 +00:00
|
|
|
|
|
|
|
passthru = {
|
|
|
|
tests = sage-tests;
|
2018-11-24 21:59:51 +00:00
|
|
|
quicktest = sage-tests.override { longTests = false; timeLimit = 600; }; # as many tests as possible in ~10m
|
2018-11-12 22:28:29 +00:00
|
|
|
doc = sagedoc;
|
|
|
|
lib = sage-with-env.env.lib;
|
2022-05-23 15:55:11 +00:00
|
|
|
kernelspec = jupyter-kernel-definition;
|
2018-11-12 22:28:29 +00:00
|
|
|
};
|
|
|
|
|
2021-01-11 07:54:33 +00:00
|
|
|
meta = with lib; {
|
2018-11-12 22:28:29 +00:00
|
|
|
description = "Open Source Mathematics Software, free alternative to Magma, Maple, Mathematica, and Matlab";
|
2021-09-14 01:56:34 +00:00
|
|
|
homepage = "https://www.sagemath.org";
|
|
|
|
license = licenses.gpl2Plus;
|
2020-11-17 19:41:33 +00:00
|
|
|
maintainers = teams.sage.members;
|
2018-11-12 22:28:29 +00:00
|
|
|
};
|
2018-04-24 21:53:36 +00:00
|
|
|
}
|