@@ -5,11 +5,60 @@
55, makeWrapper
66, m4
77, gmp
8−# don't remove any packages -- results in a ~1.3G size increase
9−# see https://github.com/NixOS/nixpkgs/pull/38754 for a discussion
10−, keepAllPackages ? true
8+# one of
9+# - "minimal" (~400M):
10+# Install the bare minimum of packages required by gap to start.
11+# This is likely to break a lot of stuff. Do not expect upstream support with
12+# this configuration.
13+# - "standard" (~700M):
14+# Install the "standard packages" which gap autoloads by default. These
15+# packages are effectively considered a part of gap.
16+# - "full" (~1.7G):
17+# Install all available packages. This takes a lot of space.
18+, packageSet ? "standard"
19+# Kept for backwards compatibility. Overrides packageSet to "full".
20+, keepAllPackages ? false
1121}:
12−
22+let
23+ # packages absolutely required for gap to start
24+ # `*` represents the version where applicable
25+ requiredPackages = [
26+ "GAPDoc-*"
27+ "primgrp-*"
28+ "SmallGrp-*"
29+ "transgrp"
30+ ];
31+ # packages autoloaded by default if available
32+ autoloadedPackages = [
33+ "atlasrep"
34+ "autpgrp-*"
35+ "alnuth-*"
36+ "crisp-*"
37+ "ctbllib"
38+ "FactInt-*"
39+ "fga"
40+ "irredsol-*"
41+ "laguna-*"
42+ "polenta-*"
43+ "polycyclic-*"
44+ "resclasses-*"
45+ "sophus-*"
46+ "tomlib-*"
47+ ];
48+ standardPackages = requiredPackages ++ autoloadedPackages;
49+ keepAll = keepAllPackages || (packageSet == "full");
50+ packagesToKeep = requiredPackages ++ lib.optionals (packageSet == "standard") autoloadedPackages;
51+
52+ # Generate bash script that removes all packages from the `pkg` subdirectory
53+ # that are not on the whitelist. The whitelist consists of strings expected by
54+ # `find`'s `-name`.
55+ removeNonWhitelistedPkgs = whitelist: ''
56+ find pkg -type d -maxdepth 1 -mindepth 1 \
57+ '' + (lib.concatStringsSep "\n" (map (str: "-not -name '${str}' \\") whitelist)) + ''
58+ -exec echo "Removing package {}" \; \
59+ -exec rm -r '{}' \;
60+ '';
61+in
1362stdenv.mkDerivation rec {
1463 pname = "gap";
1564 # https://www.gap-system.org/Releases/
@@ -21,14 +70,8 @@ stdenv.mkDerivation rec {
2170 };
2271
2372 # remove all non-essential packages (which take up a lot of space)
24− preConfigure = ''
73+ preConfigure = lib.optionalString (!keepAll) (removeNonWhitelistedPkgs packagesToKeep) + ''
2574 patchShebangs .
26− '' + lib.optionalString (!keepAllPackages) ''
27− find pkg -type d -maxdepth 1 -mindepth 1 \
28− -not -name 'GAPDoc-*' \
29− -not -name 'autpgrp*' \
30− -exec echo "Removing package {}" \; \
31− -exec rm -r {} \;
3275 '';
3376
3477 configureFlags = [ "--with-gmp=system" ];
@@ -107,7 +150,16 @@ stdenv.mkDerivation rec {
107150 popd
108151 '';
109152
110− installPhase = ''
153+ installTargets = [
154+ "install-libgap"
155+ "install-headers"
156+ ];
157+
158+ # full `make install` is not yet implemented, just for libgap and headers
159+ postInstall = ''
160+ # Install config.h, which is not currently handled by `make install-headers`
161+ cp gen/config.h "$out/include/gap"
162+
111163 mkdir -p "$out/bin" "$out/share/gap/"
112164
113165 mkdir -p "$out/share/gap"
@@ -129,6 +181,7 @@ stdenv.mkDerivation rec {
129181 [
130182 raskin
131183 chrisjefferson
184+ timokau
132185 ];
133186 platforms = platforms.all;
134187 # keeping all packages increases the package size considerably, wchich