@@ -4,7 +4,32 @@
44, cmake, libyaml, Security
55, libjpeg, libX11, libXext, libXft, libXinerama
66, extraLibraries ? [ jdk unixODBC libXpm libSM libXt freetype fontconfig ]
7−, extraPacks ? []
7+# Packs must be installed from a local directory during the build, with dependencies
8+# resolved manually, e.g. to install the 'julian' pack, which depends on the 'delay', 'list_util' and 'typedef' packs:
9+# julian = pkgs.fetchzip {
10+# name = "swipl-pack-julian";
11+# url = "https://github.com/mndrix/julian/archive/v0.1.3.zip";
12+# sha256 = "1sgql7c21p3c5m14kwa0bcmlwn9fql612krn9h36gla1j9yjdfgy";
13+# };
14+# delay = pkgs.fetchzip {
15+# name = "swipl-pack-delay";
16+# url = "https://github.com/mndrix/delay/archive/v0.3.3.zip";
17+# sha256 = "0ira87afxnc2dnbbmgwmrr8qvary8lhzvhqwd52dccm6yqd3nybg";
18+# };
19+# list_util = pkgs.fetchzip {
20+# name = "swipl-pack-list_util";
21+# url = "https://github.com/mndrix/list_util/archive/v0.13.0.zip";
22+# sha256 = "0lx7vffflak0y8l8vg8k0g8qddwwn23ksbz02hi3f8rbarh1n89q";
23+# };
24+# typedef = builtins.fetchTarball {
25+# name = "swipl-pack-typedef";
26+# url = "https://raw.githubusercontent.com/samer--/prolog/master/typedef/release/typedef-0.1.9.tgz";
27+# sha256 = "056nqjn01g18fb1b2qivv9s7hb4azk24nx2d4kvkbmm1k91f44p3";
28+# };
29+# swiProlog = pkgs.swiProlog.override { extraPacks = map (dep-path: "'file://${dep-path}'") [
30+# julian delay list_util typedef
31+# ]; };
32+, extraPacks ? []
833, withGui ? false
934}:
1035
@@ -26,6 +51,11 @@ stdenv.mkDerivation {
2651 fetchSubmodules = true;
2752 };
2853
54+ # Add the packInstall path to the swipl pack search path
55+ postPatch = ''
56+ echo "user:file_search_path(pack, '$out/lib/swipl/pack')." >> /build/$sourceRoot/boot/init.pl
57+ '';
58+
2959 nativeBuildInputs = [ cmake pkg-config ];
3060
3161 buildInputs = [ gmp readline openssl
@@ -39,6 +69,10 @@ stdenv.mkDerivation {
3969
4070 cmakeFlags = [ "-DSWIPL_INSTALL_IN_LIB=ON" ];
4171
72+ preInstall = ''
73+ mkdir -p $out/lib/swipl/pack
74+ '';
75+
4276 postInstall = builtins.concatStringsSep "\n"
4377 ( builtins.map (packInstall "$out") extraPacks
4478 );