2021-03-09 09:52:26 +00:00
|
|
|
{ pkgs, gccStdenv, lib, coreutils,
|
2019-09-22 08:38:09 +01:00
|
|
|
openssl, zlib, sqlite, libxml2, libyaml, libmysqlclient, lmdb, leveldb, postgresql,
|
2020-03-21 04:53:33 +00:00
|
|
|
version, git-version,
|
|
|
|
gambit-support,
|
2020-05-17 21:10:03 +01:00
|
|
|
gambit ? pkgs.gambit, gambit-params ? pkgs.gambit-support.stable-params, src }:
|
2020-03-21 04:53:33 +00:00
|
|
|
|
|
|
|
# We use Gambit, that works 10x better with GCC than Clang. See ../gambit/build.nix
|
|
|
|
let stdenv = gccStdenv; in
|
2018-03-03 06:28:08 +00:00
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
2019-08-13 22:52:01 +01:00
|
|
|
pname = "gerbil";
|
|
|
|
inherit version;
|
2018-11-19 14:14:15 +00:00
|
|
|
inherit src;
|
2018-03-03 06:28:08 +00:00
|
|
|
|
2019-09-22 08:38:09 +01:00
|
|
|
buildInputs_libraries = [ openssl zlib sqlite libxml2 libyaml libmysqlclient lmdb leveldb postgresql ];
|
2018-03-03 06:28:08 +00:00
|
|
|
|
2020-03-21 04:53:33 +00:00
|
|
|
# TODO: either fix all of Gerbil's dependencies to provide static libraries,
|
|
|
|
# or give up and delete all tentative support for static libraries.
|
|
|
|
#buildInputs_staticLibraries = map makeStaticLibraries buildInputs_libraries;
|
|
|
|
|
|
|
|
buildInputs = [ gambit ]
|
|
|
|
++ buildInputs_libraries; # ++ buildInputs_staticLibraries;
|
2018-03-03 06:28:08 +00:00
|
|
|
|
2019-10-30 01:29:30 +00:00
|
|
|
NIX_CFLAGS_COMPILE = "-I${libmysqlclient}/include/mysql -L${libmysqlclient}/lib/mysql";
|
2018-03-03 06:28:08 +00:00
|
|
|
|
|
|
|
postPatch = ''
|
2020-03-21 04:53:33 +00:00
|
|
|
echo '(define (gerbil-version-string) "v${git-version}")' > src/gerbil/runtime/gx-version.scm ;
|
|
|
|
patchShebangs . ;
|
2018-12-26 00:41:15 +00:00
|
|
|
grep -Fl '#!/usr/bin/env' `find . -type f -executable` | while read f ; do
|
2020-03-21 04:53:33 +00:00
|
|
|
substituteInPlace "$f" --replace '#!/usr/bin/env' '#!${coreutils}/bin/env' ;
|
|
|
|
done ;
|
2019-12-23 22:35:10 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
## TODO: make static compilation work.
|
|
|
|
## For that, get all the packages below to somehow expose static libraries,
|
|
|
|
## so we can offer users the option to statically link them into Gambit and/or Gerbil.
|
|
|
|
## Then add the following to the postPatch script above:
|
|
|
|
# cat > etc/gerbil_static_libraries.sh <<EOF
|
|
|
|
# OPENSSL_LIBCRYPTO=${makeStaticLibraries openssl}/lib/libcrypto.a # MISSING!
|
|
|
|
# OPENSSL_LIBSSL=${makeStaticLibraries openssl}/lib/libssl.a # MISSING!
|
|
|
|
# ZLIB=${makeStaticLibraries zlib}/lib/libz.a
|
2018-03-03 06:28:08 +00:00
|
|
|
# SQLITE=${makeStaticLibraries sqlite}/lib/sqlite.a # MISSING!
|
|
|
|
# LIBXML2=${makeStaticLibraries libxml2}/lib/libxml2.a # MISSING!
|
|
|
|
# YAML=${makeStaticLibraries libyaml}/lib/libyaml.a # MISSING!
|
2019-12-23 22:35:10 +00:00
|
|
|
# MYSQL=${makeStaticLibraries libmysqlclient}/lib/mariadb/libmariadb.a
|
2018-03-03 06:28:08 +00:00
|
|
|
# LMDB=${makeStaticLibraries lmdb}/lib/mysql/libmysqlclient_r.a # MISSING!
|
2019-12-23 22:35:10 +00:00
|
|
|
# LEVELDB=${makeStaticLibraries leveldb}/lib/libleveldb.a
|
|
|
|
# EOF
|
2018-03-03 06:28:08 +00:00
|
|
|
|
2020-05-17 21:10:03 +01:00
|
|
|
configurePhase = ''
|
|
|
|
(cd src && ./configure \
|
|
|
|
--prefix=$out/gerbil \
|
|
|
|
--with-gambit=${gambit}/gambit \
|
|
|
|
--enable-libxml \
|
|
|
|
--enable-libyaml \
|
|
|
|
--enable-zlib \
|
|
|
|
--enable-sqlite \
|
|
|
|
--enable-mysql \
|
|
|
|
--enable-lmdb \
|
|
|
|
--enable-leveldb)
|
|
|
|
'';
|
2020-03-21 04:53:33 +00:00
|
|
|
|
2018-03-03 06:28:08 +00:00
|
|
|
buildPhase = ''
|
|
|
|
runHook preBuild
|
|
|
|
|
|
|
|
# gxprof testing uses $HOME/.cache/gerbil/gxc
|
2020-03-21 04:53:33 +00:00
|
|
|
export HOME=$PWD
|
|
|
|
export GERBIL_BUILD_CORES=$NIX_BUILD_CORES
|
|
|
|
export GERBIL_GXC=$PWD/bin/gxc
|
|
|
|
export GERBIL_BASE=$PWD
|
|
|
|
export GERBIL_HOME=$PWD
|
|
|
|
export GERBIL_PATH=$PWD/lib
|
|
|
|
export PATH=$PWD/bin:$PATH
|
|
|
|
${gambit-support.export-gambopt gambit-params}
|
2018-03-03 06:28:08 +00:00
|
|
|
|
|
|
|
# Build, replacing make by build.sh
|
|
|
|
( cd src && sh build.sh )
|
|
|
|
|
|
|
|
runHook postBuild
|
|
|
|
'';
|
|
|
|
|
2020-05-17 21:10:03 +01:00
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
|
|
|
mkdir -p $out/gerbil $out/bin
|
|
|
|
(cd src; ./install)
|
|
|
|
(cd $out/bin ; ln -s ../gerbil/bin/* .)
|
|
|
|
runHook postInstall
|
|
|
|
'';
|
|
|
|
|
2018-03-03 06:28:08 +00:00
|
|
|
dontStrip = true;
|
|
|
|
|
|
|
|
meta = {
|
|
|
|
description = "Gerbil Scheme";
|
|
|
|
homepage = "https://github.com/vyzo/gerbil";
|
2020-03-21 04:53:33 +00:00
|
|
|
license = lib.licenses.lgpl21; # also asl20, like Gambit
|
2019-12-23 22:35:10 +00:00
|
|
|
# NB regarding platforms: regularly tested on Linux, only occasionally on macOS.
|
|
|
|
# Please report success and/or failure to fare.
|
2020-03-21 04:53:33 +00:00
|
|
|
platforms = lib.platforms.unix;
|
|
|
|
maintainers = with lib.maintainers; [ fare ];
|
2018-03-03 06:28:08 +00:00
|
|
|
};
|
|
|
|
}
|