nixpkgs/pkgs/applications/science/math/sage/sage.nix
Profpatsch 4a7f99d55d treewide: with stdenv.lib; in meta -> with lib;
Part of: https://github.com/NixOS/nixpkgs/issues/108938

meta = with stdenv.lib;

is a widely used pattern. We want to slowly remove
the `stdenv.lib` indirection and encourage people
to use `lib` directly. Thus let’s start with the meta
field.

This used a rewriting script to mostly automatically
replace all occurances of this pattern, and add the
`lib` argument to the package header if it doesn’t
exist yet.

The script in its current form is available at
https://cs.tvl.fyi/depot@2f807d7f141068d2d60676a89213eaa5353ca6e0/-/blob/users/Profpatsch/nixpkgs-rewriter/default.nix
2021-01-11 10:38:22 +01:00

69 lines
1.8 KiB
Nix

{ lib, stdenv
, makeWrapper
, sage-tests
, sage-with-env
, jupyter-kernel-definition
, jupyter-kernel
, sagedoc
, withDoc
}:
# A wrapper that makes sure sage finds its docs (if they were build) and the
# jupyter kernel spec.
let
# generate kernel spec + default kernels
kernel-specs = jupyter-kernel.create {
definitions = jupyter-kernel.default // {
sagemath = jupyter-kernel-definition;
};
};
in
stdenv.mkDerivation rec {
version = src.version;
pname = "sage";
src = sage-with-env.env.lib.src;
buildInputs = [
makeWrapper
# 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
];
dontUnpack = true;
configurePhase = "#do nothing";
buildPhase = "#do nothing";
installPhase = ''
mkdir -p "$out/bin"
makeWrapper "${sage-with-env}/bin/sage" "$out/bin/sage" \
--set SAGE_DOC_SRC_OVERRIDE "${src}/src/doc" ${
stdenv.lib.optionalString withDoc "--set SAGE_DOC_OVERRIDE ${sagedoc}/share/doc/sage"
} \
--prefix JUPYTER_PATH : "${kernel-specs}"
'';
doInstallCheck = withDoc;
installCheckPhase = ''
export HOME="$TMPDIR/sage-home"
mkdir -p "$HOME"
"$out/bin/sage" -c 'browse_sage_doc._open("reference", testing=True)'
'';
passthru = {
tests = sage-tests;
quicktest = sage-tests.override { longTests = false; timeLimit = 600; }; # as many tests as possible in ~10m
doc = sagedoc;
lib = sage-with-env.env.lib;
kernelspec = jupyter-kernel-definition;
};
meta = with lib; {
description = "Open Source Mathematics Software, free alternative to Magma, Maple, Mathematica, and Matlab";
license = licenses.gpl2;
maintainers = teams.sage.members;
};
}