summary refs log tree commit diff
path: root/pkgs/applications/science/math/sage/sage-wrapper.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/applications/science/math/sage/sage-wrapper.nix')
-rw-r--r--pkgs/applications/science/math/sage/sage-wrapper.nix41
1 files changed, 41 insertions, 0 deletions
diff --git a/pkgs/applications/science/math/sage/sage-wrapper.nix b/pkgs/applications/science/math/sage/sage-wrapper.nix
new file mode 100644
index 000000000000..06b667f426fa
--- /dev/null
+++ b/pkgs/applications/science/math/sage/sage-wrapper.nix
@@ -0,0 +1,41 @@
+{ stdenv
+, makeWrapper
+, sage
+, sage-src
+, sagedoc
+, withDoc
+}:
+
+stdenv.mkDerivation rec {
+  version = sage.version;
+  name = "sage-wrapper-${version}";
+
+  buildInputs = [
+    makeWrapper
+  ];
+
+  unpackPhase = "#do nothing";
+  configurePhase = "#do nothing";
+  buildPhase = "#do nothing";
+
+  installPhase = ''
+    mkdir -p "$out/bin"
+    makeWrapper "${sage}/bin/sage" "$out/bin/sage" \
+      --set SAGE_DOC_SRC_OVERRIDE "${sage-src}/src/doc" ${
+      stdenv.lib.optionalString withDoc "--set SAGE_DOC_OVERRIDE ${sagedoc}/share/doc/sage"
+    }
+  '';
+
+  doInstallCheck = withDoc;
+  installCheckPhase = ''
+    export HOME="$TMPDIR/sage-home"
+    mkdir -p "$HOME"
+    "$out/bin/sage" -c 'browse_sage_doc._open("reference", testing=True)'
+  '';
+
+  meta = with stdenv.lib; {
+    description = "Open Source Mathematics Software, free alternative to Magma, Maple, Mathematica, and Matlab";
+    license = licenses.gpl2;
+    maintainers = with maintainers; [ timokau ];
+  };
+}