nixpkgs/pkgs/applications/science/math/gap/default.nix

186 lines
5.4 KiB
Nix
Raw Normal View History

2018-04-11 10:49:43 +01:00
{ stdenv
, lib
2018-04-11 10:49:43 +01:00
, fetchurl
, fetchpatch
, makeWrapper
, readline
2018-04-11 10:49:43 +01:00
, gmp
# one of
# - "minimal" (~400M):
# Install the bare minimum of packages required by gap to start.
# This is likely to break a lot of stuff. Do not expect upstream support with
# this configuration.
# - "standard" (~700M):
# Install the "standard packages" which gap autoloads by default. These
# packages are effectively considered a part of gap.
# - "full" (~1.7G):
# Install all available packages. This takes a lot of space.
, packageSet ? "standard"
# Kept for backwards compatibility. Overrides packageSet to "full".
, keepAllPackages ? false
2018-04-11 10:49:43 +01:00
}:
let
# packages absolutely required for gap to start
# `*` represents the version where applicable
requiredPackages = [
"GAPDoc-*"
"primgrp-*"
"SmallGrp-*"
"transgrp"
];
# packages autoloaded by default if available
autoloadedPackages = [
"atlasrep"
"autpgrp-*"
"alnuth-*"
"crisp-*"
"ctbllib"
"FactInt-*"
"fga"
"irredsol-*"
"laguna-*"
"polenta-*"
"polycyclic-*"
"resclasses-*"
"sophus-*"
"tomlib-*"
];
keepAll = keepAllPackages || (packageSet == "full");
packagesToKeep = requiredPackages ++ lib.optionals (packageSet == "standard") autoloadedPackages;
# Generate bash script that removes all packages from the `pkg` subdirectory
# that are not on the whitelist. The whitelist consists of strings expected by
# `find`'s `-name`.
removeNonWhitelistedPkgs = whitelist: ''
find pkg -type d -maxdepth 1 -mindepth 1 \
'' + (lib.concatStringsSep "\n" (map (str: "-not -name '${str}' \\") whitelist)) + ''
-exec echo "Removing package {}" \; \
-exec rm -r '{}' \;
'';
in
2015-07-21 12:19:38 +01:00
stdenv.mkDerivation rec {
2018-04-11 10:49:43 +01:00
pname = "gap";
# https://www.gap-system.org/Releases/
version = "4.10.2";
src = fetchurl {
url = "https://files.gap-system.org/gap-${lib.versions.major version}.${lib.versions.minor version}/tar.bz2/gap-${version}.tar.bz2";
sha256 = "0cp6ddk0469zzv1m1vair6gm27ic6c5m77ri8rn0znq3gaps6x94";
2015-07-21 12:19:38 +01:00
};
2018-04-11 10:49:43 +01:00
# remove all non-essential packages (which take up a lot of space)
preConfigure = lib.optionalString (!keepAll) (removeNonWhitelistedPkgs packagesToKeep) + ''
patchShebangs .
2018-04-11 10:49:43 +01:00
'';
buildInputs = [
readline
gmp
];
nativeBuildInputs = [
makeWrapper
];
2018-04-11 10:49:43 +01:00
patches = [
2019-04-06 17:01:02 +01:00
# https://github.com/gap-system/gap/pull/3294
(fetchpatch {
2019-04-06 17:01:02 +01:00
name = "add-make-install-targets.patch";
url = "https://github.com/gap-system/gap/commit/3361c172e6c5ff3bb3f01ba9d6f1dd4ad42cea80.patch";
sha256 = "1kwp9qnfvmlbpf1c3rs6j5m2jz22rj7a4hb5x1gj9vkpiyn5pdyj";
2018-04-11 10:49:43 +01:00
})
# Fix for locale specific tests causing issues. Already upstream.
# Backport of https://github.com/gap-system/gap/pull/4022
# WHEN REMOVING: also remove the`rm tst/testinstall/strings.tst` line in
# `postPatch` below. That line is necessary since the patch is not intended
# for gap 4.10.
(fetchpatch {
name = "remove-locale-specific-tests.patch";
url = "https://github.com/gap-system/gap/commit/c18b0c4215b5212a2cc4f305e2d5b94ba716bee8.patch";
excludes = ["tst/testinstall/stringobj.tst"];
sha256 = "1mz5b4mbw2jdd1ypp5s0dy6pp0jsvwsxr2dm4kbkls20r1r192sc";
})
2018-04-11 10:49:43 +01:00
];
postPatch = ''
# File not covered by the remove-locale-specific-tests.patch patch above.
rm tst/testinstall/strings.tst
'';
2018-04-11 10:49:43 +01:00
# "teststandard" is a superset of testinstall. It takes ~1h instead of ~1min.
# tests are run twice, once with all packages loaded and once without
# checkTarget = "teststandard";
doInstallCheck = true;
installCheckTarget = "check";
preInstallCheck = ''
2018-04-11 10:49:43 +01:00
# gap tests check that the home directory exists
export HOME="$TMP/gap-home"
mkdir -p "$HOME"
# make sure gap is in PATH
export PATH="$out/bin:$PATH"
# make sure we don't accidentally use the wrong gap binary
rm -r bin
# like the defaults the Makefile, but use gap from PATH instead of the
# one from builddir
installCheckFlagsArray+=(
"TESTGAP=gap --quitonbreak -b -m 100m -o 1g -q -x 80 -r -A"
"TESTGAPauto=gap --quitonbreak -b -m 100m -o 1g -q -x 80 -r"
)
2018-04-11 10:49:43 +01:00
'';
2016-06-02 22:53:39 +01:00
postBuild = ''
pushd pkg
bash ../bin/BuildPackages.sh
popd
'';
2018-04-11 10:49:43 +01:00
installTargets = [
"install-libgap"
"install-headers"
];
# full `make install` is not yet implemented, just for libgap and headers
postInstall = ''
# Install config.h, which is not currently handled by `make install-headers`
cp gen/config.h "$out/include/gap"
mkdir -p "$out/bin" "$out/share/gap/"
mkdir -p "$out/share/gap"
echo "Copying files to target directory"
cp -ar . "$out/share/gap/build-dir"
makeWrapper "$out/share/gap/build-dir/bin/gap.sh" "$out/bin/gap" \
--set GAP_DIR $out/share/gap/build-dir
'';
preFixup = ''
# patchelf won't strip references to the build dir if it still exists
rm -rf pkg
2015-07-21 12:19:38 +01:00
'';
2014-07-28 10:43:20 +01:00
meta = with lib; {
description = "Computational discrete algebra system";
2015-07-21 12:19:38 +01:00
maintainers = with maintainers;
[
raskin
2016-06-02 22:53:39 +01:00
chrisjefferson
timokau
];
2016-06-02 22:53:39 +01:00
platforms = platforms.all;
broken = stdenv.isDarwin;
2020-05-28 14:57:31 +01:00
# keeping all packages increases the package size considerably, which is
# why a local build is preferable in that situation. The timeframe is
# reasonable and that way the binary cache doesn't get overloaded.
hydraPlatforms = lib.optionals (!keepAllPackages) meta.platforms;
2015-07-21 12:19:38 +01:00
license = licenses.gpl2;
2020-05-28 14:58:41 +01:00
homepage = "https://www.gap-system.org";
};
2015-07-21 12:19:38 +01:00
}