10 # - "minimal" (~400M):
11 # Install the bare minimum of packages required by gap to start.
12 # This is likely to break a lot of stuff. Do not expect upstream support with
14 # - "standard" (~700M):
15 # Install the "standard packages" which gap autoloads by default. These
16 # packages are effectively considered a part of gap.
18 # Install all available packages. This takes a lot of space.
19 , packageSet ? "standard"
20 # Kept for backwards compatibility. Overrides packageSet to "full".
21 , keepAllPackages ? false
24 # packages absolutely required for gap to start
25 # `*` represents the version where applicable
32 # packages autoloaded by default if available, and their dependencies
33 autoloadedPackages = [
48 "autodoc" # dependency of atlasrep
49 "io" # used by atlasrep to fetch data from online sources
50 "radiroot" # dependency of polenta
51 "utils" # dependency of atlasrep
53 keepAll = keepAllPackages || (packageSet == "full");
54 packagesToKeep = requiredPackages ++ lib.optionals (packageSet == "standard") autoloadedPackages;
56 # Generate bash script that removes all packages from the `pkg` subdirectory
57 # that are not on the whitelist. The whitelist consists of strings expected by
59 removeNonWhitelistedPkgs = whitelist: ''
60 find pkg -type d -maxdepth 1 -mindepth 1 \
61 '' + (lib.concatStringsSep "\n" (map (str: "-not -name '${str}' \\") whitelist)) + ''
62 -exec echo "Removing package {}" \; \
66 stdenv.mkDerivation rec {
68 # https://www.gap-system.org/Releases/
72 url = "https://github.com/gap-system/gap/releases/download/v${version}/gap-${version}.tar.gz";
73 sha256 = "sha256-l5Tb26b7mY4KLQqoziH8iEitPT+cyZk7C44gvn4dvro=";
76 # remove all non-essential packages (which take up a lot of space)
77 preConfigure = lib.optionalString (!keepAll) (removeNonWhitelistedPkgs packagesToKeep) + ''
91 propagatedBuildInputs = [
92 pari # used at runtime by the alnuth package
95 # "teststandard" is a superset of the tests run by "check". it takes ~20min
96 # instead of ~1min. tests are run twice, once with all packages loaded and
98 # installCheckTarget = "teststandard";
100 doInstallCheck = true;
101 installCheckTarget = "check";
104 # gap tests check that the home directory exists
105 export HOME="$TMP/gap-home"
108 # make sure gap is in PATH
109 export PATH="$out/bin:$PATH"
111 # make sure we don't accidentally use the wrong gap binary
114 # like the defaults the Makefile, but use gap from PATH instead of the
116 installCheckFlagsArray+=(
117 "TESTGAPcore=gap --quitonbreak -b -q -r"
118 "TESTGAPauto=gap --quitonbreak -b -q -r -m 100m -o 1g -x 80"
119 "TESTGAP=gap --quitonbreak -b -q -r -m 100m -o 1g -x 80 -A"
125 # failures are ignored unless --strict is set
126 bash ../bin/BuildPackages.sh ${lib.optionalString (!keepAll) "--strict"}
131 # make install creates an empty pkg dir. since we run "make check" on
132 # installCheckPhase to make sure the installed GAP finds its libraries, we
133 # also install the tst dir. this is probably excessively cautious, see
134 # https://github.com/NixOS/nixpkgs/pull/192548#discussion_r992824942
135 rm -r "$out/share/gap/pkg"
136 cp -ar pkg tst "$out/share/gap"
140 # patchelf won't strip references to the build dir if it still exists
145 description = "Computational discrete algebra system";
146 # We are also grateful to ChrisJefferson for previous work on the package,
147 # and to ChrisJefferson and fingolfin for help with GAP-related questions
148 # from the upstream point of view.
149 maintainers = teams.sage.members;
150 platforms = platforms.all;
151 # keeping all packages increases the package size considerably, which is
152 # why a local build is preferable in that situation. The timeframe is
153 # reasonable and that way the binary cache doesn't get overloaded.
154 hydraPlatforms = lib.optionals (!keepAllPackages) meta.platforms;
155 license = licenses.gpl2;
156 homepage = "https://www.gap-system.org";