@@ -1,34 +1,35 @@
1−{ stdenv, makeStaticLibraries,
2− coreutils, rsync, bash,
1+{ pkgs, gccStdenv, lib, coreutils, # makeStaticLibraries,
32 openssl, zlib, sqlite, libxml2, libyaml, libmysqlclient, lmdb, leveldb, postgresql,
4− version, git-version, gambit, src }:
3+ version, git-version,
4+ gambit-support,
5+ gambit ? pkgs.gambit, gambit-params ? pkgs.gambit-support.stable-params,
6+ src, configurePhase, installPhase }:
7+
8+# We use Gambit, that works 10x better with GCC than Clang. See ../gambit/build.nix
9+let stdenv = gccStdenv; in
510
611stdenv.mkDerivation rec {
712 pname = "gerbil";
813 inherit version;
914 inherit src;
1015
11− # Use makeStaticLibraries to enable creation of statically linked binaries
1216 buildInputs_libraries = [ openssl zlib sqlite libxml2 libyaml libmysqlclient lmdb leveldb postgresql ];
13− buildInputs_staticLibraries = map makeStaticLibraries buildInputs_libraries;
1417
15− buildInputs = [ gambit rsync bash ]
16− ++ buildInputs_libraries ++ buildInputs_staticLibraries;
18+ # TODO: either fix all of Gerbil's dependencies to provide static libraries,
19+ # or give up and delete all tentative support for static libraries.
20+ #buildInputs_staticLibraries = map makeStaticLibraries buildInputs_libraries;
21+
22+ buildInputs = [ gambit ]
23+ ++ buildInputs_libraries; # ++ buildInputs_staticLibraries;
1724
1825 NIX_CFLAGS_COMPILE = "-I${libmysqlclient}/include/mysql -L${libmysqlclient}/lib/mysql";
1926
2027 postPatch = ''
21− echo '(define (gerbil-version-string) "v${git-version}")' > src/gerbil/runtime/gx-version.scm
22−
23− patchShebangs .
24−
28+ echo '(define (gerbil-version-string) "v${git-version}")' > src/gerbil/runtime/gx-version.scm ;
29+ patchShebangs . ;
2530 grep -Fl '#!/usr/bin/env' `find . -type f -executable` | while read f ; do
26− substituteInPlace "$f" --replace '#!/usr/bin/env' '#!${coreutils}/bin/env'
27− done
28− grep -Fl '"gsc"' `find . -type f -name '*.s*'` | while read f ; do
29− substituteInPlace "$f" --replace '"gsc"' '"${gambit}/bin/gsc"'
30− done
31− substituteInPlace "etc/gerbil.el" --replace '"gxc"' "\"$out/bin/gxc\""
31+ substituteInPlace "$f" --replace '#!/usr/bin/env' '#!${coreutils}/bin/env' ;
32+ done ;
3233'';
3334
3435## TODO: make static compilation work.
@@ -47,22 +48,20 @@ stdenv.mkDerivation rec {
4748# LEVELDB=${makeStaticLibraries leveldb}/lib/libleveldb.a
4849# EOF
4950
51+ inherit configurePhase installPhase;
52+
5053 buildPhase = ''
5154 runHook preBuild
5255
53− # Enable all optional libraries
54− substituteInPlace "src/std/build-features.ss" --replace '#f' '#t'
55−
56− # Enable autodetection of a default GERBIL_HOME
57− for i in src/gerbil/boot/gx-init-exe.scm src/gerbil/boot/gx-init.scm ; do
58− substituteInPlace "$i" --replace '(getenv "GERBIL_HOME" #f)' "(getenv \"GERBIL_HOME\" \"$out\")"
59− done
60− for i in src/gerbil/boot/gxi-init.scm src/gerbil/compiler/driver.ss src/gerbil/runtime/gx-gambc.scm src/std/build.ss src/tools/build.ss ; do
61− substituteInPlace "$i" --replace '(getenv "GERBIL_HOME")' "(getenv \"GERBIL_HOME\" \"$out\")"
62− done
63−
6456 # gxprof testing uses $HOME/.cache/gerbil/gxc
65− export HOME=$$PWD
57+ export HOME=$PWD
58+ export GERBIL_BUILD_CORES=$NIX_BUILD_CORES
59+ export GERBIL_GXC=$PWD/bin/gxc
60+ export GERBIL_BASE=$PWD
61+ export GERBIL_HOME=$PWD
62+ export GERBIL_PATH=$PWD/lib
63+ export PATH=$PWD/bin:$PATH
64+ ${gambit-support.export-gambopt gambit-params}
6665
6766 # Build, replacing make by build.sh
6867 ( cd src && sh build.sh )
@@ -70,33 +69,15 @@ stdenv.mkDerivation rec {
7069 runHook postBuild
7170 '';
7271
73− installPhase = ''
74− runHook preInstall
75− mkdir -p $out/
76− cp -fa bin lib etc doc $out/
77−
78− cat > $out/bin/gxi <<EOF
79−#!${bash}/bin/bash -e
80−export GERBIL_HOME=$out
81−case "\$1" in -:*) GSIOPTIONS=\$1 ; shift ;; esac
82−if [[ \$# = 0 ]] ; then
83− exec ${gambit}/bin/gsi \$GSIOPTIONS \$GERBIL_HOME/lib/gxi-init \$GERBIL_HOME/lib/gxi-interactive -
84−else
85− exec ${gambit}/bin/gsi \$GSIOPTIONS \$GERBIL_HOME/lib/gxi-init "\$@"
86−fi
87−EOF
88− runHook postInstall
89− '';
90−
9172 dontStrip = true;
9273
9374 meta = {
9475 description = "Gerbil Scheme";
9576 homepage = "https://github.com/vyzo/gerbil";
96− license = stdenv.lib.licenses.lgpl2;
77+ license = lib.licenses.lgpl21; # also asl20, like Gambit
9778 # NB regarding platforms: regularly tested on Linux, only occasionally on macOS.
9879 # Please report success and/or failure to fare.
99− platforms = stdenv.lib.platforms.unix;
100− maintainers = with stdenv.lib.maintainers; [ fare ];
80+ platforms = lib.platforms.unix;
81+ maintainers = with lib.maintainers; [ fare ];
10182 };
10283}