summary refs log tree commit diff
path: root/pkgs/applications/science/math/sage/sage-wrapper.nix
blob: 06b667f426fa98242e2e1008448d6220b02757e5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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 ];
  };
}