nixpkgs/pkgs/by-name/ga/gap/package.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

159 lines
4.7 KiB
Nix
Raw Normal View History

2018-04-11 09:49:43 +00:00
{ stdenv
, lib
2018-04-11 09:49:43 +00:00
, fetchurl
, makeWrapper
, readline
2018-04-11 09:49:43 +00:00
, gmp
2022-09-23 02:32:58 +00:00
, pari
2021-04-03 18:29:01 +00:00
, zlib
# 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 09:49:43 +00:00
}:
let
# packages absolutely required for gap to start
# `*` represents the version where applicable
requiredPackages = [
2022-09-23 02:32:58 +00:00
"gapdoc"
"primgrp"
"smallgrp"
"transgrp"
];
2022-09-23 02:32:58 +00:00
# packages autoloaded by default if available, and their dependencies
autoloadedPackages = [
"atlasrep"
2022-09-23 02:32:58 +00:00
"autpgrp"
"alnuth"
"crisp"
"ctbllib"
"factint"
"fga"
2022-09-23 02:32:58 +00:00
"irredsol"
"laguna"
"polenta"
"polycyclic"
"resclasses"
"sophus"
"tomlib"
"autodoc" # dependency of atlasrep
"io" # used by atlasrep to fetch data from online sources
"radiroot" # dependency of polenta
"utils" # dependency of atlasrep
];
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 11:19:38 +00:00
stdenv.mkDerivation rec {
2018-04-11 09:49:43 +00:00
pname = "gap";
# https://www.gap-system.org/Releases/
2024-06-14 23:51:01 +00:00
version = "4.13.1";
src = fetchurl {
2021-05-05 12:02:19 +00:00
url = "https://github.com/gap-system/gap/releases/download/v${version}/gap-${version}.tar.gz";
2024-06-14 23:51:01 +00:00
sha256 = "sha256-l5Tb26b7mY4KLQqoziH8iEitPT+cyZk7C44gvn4dvro=";
2015-07-21 11:19:38 +00:00
};
2018-04-11 09:49:43 +00:00
# remove all non-essential packages (which take up a lot of space)
preConfigure = lib.optionalString (!keepAll) (removeNonWhitelistedPkgs packagesToKeep) + ''
patchShebangs .
2018-04-11 09:49:43 +00:00
'';
buildInputs = [
readline
gmp
2021-04-03 18:29:01 +00:00
zlib
];
nativeBuildInputs = [
makeWrapper
];
2018-04-11 09:49:43 +00:00
2022-09-23 02:32:58 +00:00
propagatedBuildInputs = [
pari # used at runtime by the alnuth package
];
# "teststandard" is a superset of the tests run by "check". it takes ~20min
# instead of ~1min. tests are run twice, once with all packages loaded and
# once without.
# installCheckTarget = "teststandard";
2018-04-11 09:49:43 +00:00
doInstallCheck = true;
installCheckTarget = "check";
preInstallCheck = ''
2018-04-11 09:49:43 +00: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+=(
2022-09-23 02:32:58 +00:00
"TESTGAPcore=gap --quitonbreak -b -q -r"
"TESTGAPauto=gap --quitonbreak -b -q -r -m 100m -o 1g -x 80"
"TESTGAP=gap --quitonbreak -b -q -r -m 100m -o 1g -x 80 -A"
)
2018-04-11 09:49:43 +00:00
'';
2016-06-02 21:53:39 +00:00
postBuild = ''
pushd pkg
2022-09-23 02:32:58 +00:00
# failures are ignored unless --strict is set
bash ../bin/BuildPackages.sh ${lib.optionalString (!keepAll) "--strict"}
2016-06-02 21:53:39 +00:00
popd
'';
2018-04-11 09:49:43 +00:00
postInstall = ''
2022-09-23 02:32:58 +00:00
# make install creates an empty pkg dir. since we run "make check" on
# installCheckPhase to make sure the installed GAP finds its libraries, we
# also install the tst dir. this is probably excessively cautious, see
# https://github.com/NixOS/nixpkgs/pull/192548#discussion_r992824942
rm -r "$out/share/gap/pkg"
cp -ar pkg tst "$out/share/gap"
'';
preFixup = ''
# patchelf won't strip references to the build dir if it still exists
rm -rf pkg
2015-07-21 11:19:38 +00:00
'';
2014-07-28 09:43:20 +00:00
meta = with lib; {
description = "Computational discrete algebra system";
2022-09-23 02:32:58 +00:00
# We are also grateful to ChrisJefferson for previous work on the package,
# and to ChrisJefferson and fingolfin for help with GAP-related questions
# from the upstream point of view.
maintainers = teams.sage.members;
2016-06-02 21:53:39 +00:00
platforms = platforms.all;
2020-05-28 13:57:31 +00: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 11:19:38 +00:00
license = licenses.gpl2;
2020-05-28 13:58:41 +00:00
homepage = "https://www.gap-system.org";
};
2015-07-21 11:19:38 +00:00
}