2020-09-26 02:19:24 +01:00
|
|
|
{ pkgs, lib, gccStdenv, callPackage, fetchFromGitHub }:
|
2020-03-21 04:53:33 +00:00
|
|
|
# See ../gambit/build.nix regarding gccStdenv
|
|
|
|
|
|
|
|
rec {
|
|
|
|
# Gerbil libraries
|
|
|
|
gerbilPackages-unstable = {
|
2020-10-28 05:13:46 +00:00
|
|
|
gerbil-libp2p = callPackage ./gerbil-libp2p.nix { };
|
2020-05-07 22:24:11 +01:00
|
|
|
gerbil-utils = callPackage ./gerbil-utils.nix { };
|
2020-06-17 00:35:42 +01:00
|
|
|
gerbil-crypto = callPackage ./gerbil-crypto.nix { };
|
2020-07-14 17:36:47 +01:00
|
|
|
gerbil-poo = callPackage ./gerbil-poo.nix { };
|
2020-07-14 17:38:05 +01:00
|
|
|
gerbil-persist = callPackage ./gerbil-persist.nix { };
|
2020-07-07 14:44:07 +01:00
|
|
|
gerbil-ethereum = callPackage ./gerbil-ethereum.nix { };
|
2020-09-26 02:19:24 +01:00
|
|
|
smug-gerbil = callPackage ./smug-gerbil.nix { };
|
2020-03-21 04:53:33 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
# Use this function in any package that uses Gerbil libraries, to define the GERBIL_LOADPATH.
|
|
|
|
gerbilLoadPath =
|
|
|
|
gerbilInputs : builtins.concatStringsSep ":" (map (x : x + "/gerbil/lib") gerbilInputs);
|
|
|
|
|
|
|
|
# Use this function to create a Gerbil library. See gerbil-utils as an example.
|
|
|
|
gerbilPackage = {
|
2020-06-03 21:04:51 +01:00
|
|
|
pname, version, src, meta, gerbil-package,
|
|
|
|
git-version ? "", version-path ? "",
|
2020-03-21 04:53:33 +00:00
|
|
|
gerbil ? pkgs.gerbil-unstable,
|
|
|
|
gambit-params ? pkgs.gambit-support.stable-params,
|
|
|
|
gerbilInputs ? [],
|
|
|
|
buildInputs ? [],
|
2020-09-26 02:19:24 +01:00
|
|
|
buildScript ? "./build.ss",
|
2020-06-03 21:04:51 +01:00
|
|
|
softwareName ? ""} :
|
2020-03-21 04:53:33 +00:00
|
|
|
let buildInputs_ = buildInputs; in
|
|
|
|
gccStdenv.mkDerivation rec {
|
|
|
|
inherit src meta pname version;
|
2020-06-03 21:04:51 +01:00
|
|
|
passthru = { inherit gerbil-package version-path ;};
|
2020-03-21 04:53:33 +00:00
|
|
|
buildInputs = [ gerbil ] ++ gerbilInputs ++ buildInputs_;
|
|
|
|
postPatch = ''
|
|
|
|
set -e ;
|
2020-06-03 21:04:51 +01:00
|
|
|
if [ -n "${version-path}.ss" ] ; then
|
|
|
|
echo -e '(import :clan/versioning${builtins.concatStringsSep ""
|
2020-09-26 02:19:24 +01:00
|
|
|
(map (x : lib.optionalString (x.passthru.version-path != "")
|
|
|
|
" :${x.passthru.gerbil-package}/${x.passthru.version-path}")
|
2020-06-03 21:04:51 +01:00
|
|
|
gerbilInputs)
|
|
|
|
})\n(register-software "${softwareName}" "v${git-version}")\n' > "${passthru.version-path}.ss"
|
2020-03-21 04:53:33 +00:00
|
|
|
fi
|
|
|
|
patchShebangs . ;
|
|
|
|
'';
|
|
|
|
|
|
|
|
postConfigure = ''
|
|
|
|
export GERBIL_BUILD_CORES=$NIX_BUILD_CORES
|
|
|
|
export GERBIL_PATH=$PWD/.build
|
|
|
|
export GERBIL_LOADPATH=${gerbilLoadPath gerbilInputs}
|
|
|
|
${pkgs.gambit-support.export-gambopt gambit-params}
|
|
|
|
'';
|
|
|
|
|
|
|
|
buildPhase = ''
|
|
|
|
runHook preBuild
|
2020-09-26 02:19:24 +01:00
|
|
|
${buildScript}
|
2020-03-21 04:53:33 +00:00
|
|
|
runHook postBuild
|
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
|
|
|
mkdir -p $out/gerbil/lib
|
|
|
|
cp -fa .build/lib $out/gerbil/
|
|
|
|
bins=(.build/bin/*)
|
|
|
|
if [ 0 -lt ''${#bins} ] ; then
|
|
|
|
cp -fa .build/bin $out/gerbil/
|
|
|
|
mkdir $out/bin
|
|
|
|
cd $out/bin
|
|
|
|
ln -s ../gerbil/bin/* .
|
|
|
|
fi
|
|
|
|
runHook postInstall
|
|
|
|
'';
|
|
|
|
|
|
|
|
dontFixup = true;
|
|
|
|
};
|
|
|
|
}
|