tangled
alpha
login
or
join now
tjh.dev
/
nixpkgs
Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
0
fork
atom
overview
issues
pulls
pipelines
gerbil: 0.17 -> 0.18
Francois-Rene Rideau
2 years ago
2fdfcc53
bca2b0c9
+105
-57
4 changed files
expand all
collapse all
unified
split
pkgs
development
compilers
gerbil
build.nix
default.nix
gerbil-support.nix
gerbil-utils.nix
+58
-25
pkgs/development/compilers/gerbil/build.nix
···
1
{ pkgs, gccStdenv, lib, coreutils,
2
-
openssl, zlib, sqlite, libxml2, libyaml, libmysqlclient, lmdb, leveldb, postgresql,
3
-
version, git-version,
4
gambit-support,
5
-
gambit ? pkgs.gambit, gambit-params ? pkgs.gambit-support.stable-params, src }:
0
0
0
6
7
# We use Gambit, that works 10x better with GCC than Clang. See ../gambit/build.nix
8
let stdenv = gccStdenv; in
···
12
inherit version;
13
inherit src;
14
15
-
buildInputs_libraries = [ openssl zlib sqlite libxml2 libyaml libmysqlclient lmdb leveldb postgresql ];
16
17
# TODO: either fix all of Gerbil's dependencies to provide static libraries,
18
# or give up and delete all tentative support for static libraries.
19
#buildInputs_staticLibraries = map makeStaticLibraries buildInputs_libraries;
20
21
-
buildInputs = [ gambit ]
22
-
++ buildInputs_libraries; # ++ buildInputs_staticLibraries;
23
-
24
-
env.NIX_CFLAGS_COMPILE = "-I${libmysqlclient}/include/mysql -L${libmysqlclient}/lib/mysql";
25
26
postPatch = ''
27
echo '(define (gerbil-version-string) "v${git-version}")' > src/gerbil/runtime/gx-version.scm ;
···
29
grep -Fl '#!/usr/bin/env' `find . -type f -executable` | while read f ; do
30
substituteInPlace "$f" --replace '#!/usr/bin/env' '#!${coreutils}/bin/env' ;
31
done ;
0
0
0
0
0
0
0
0
0
0
0
32
'';
33
34
## TODO: make static compilation work.
···
40
# OPENSSL_LIBSSL=${makeStaticLibraries openssl}/lib/libssl.a # MISSING!
41
# ZLIB=${makeStaticLibraries zlib}/lib/libz.a
42
# SQLITE=${makeStaticLibraries sqlite}/lib/sqlite.a # MISSING!
43
-
# LIBXML2=${makeStaticLibraries libxml2}/lib/libxml2.a # MISSING!
44
-
# YAML=${makeStaticLibraries libyaml}/lib/libyaml.a # MISSING!
45
-
# MYSQL=${makeStaticLibraries libmysqlclient}/lib/mariadb/libmariadb.a
46
-
# LMDB=${makeStaticLibraries lmdb}/lib/mysql/libmysqlclient_r.a # MISSING!
47
-
# LEVELDB=${makeStaticLibraries leveldb}/lib/libleveldb.a
48
# EOF
49
0
0
0
0
0
0
0
0
0
50
configurePhase = ''
51
-
(cd src && ./configure \
52
-
--prefix=$out/gerbil \
53
-
--with-gambit=${gambit}/gambit \
54
-
--enable-libxml \
55
-
--enable-libyaml \
56
-
--enable-zlib \
57
-
--enable-sqlite \
58
-
--enable-mysql \
59
-
--enable-lmdb \
60
-
--enable-leveldb)
0
0
0
0
0
0
61
'';
0
0
0
0
0
0
62
63
buildPhase = ''
64
runHook preBuild
···
68
export GERBIL_BUILD_CORES=$NIX_BUILD_CORES
69
export GERBIL_GXC=$PWD/bin/gxc
70
export GERBIL_BASE=$PWD
71
-
export GERBIL_HOME=$PWD
72
export GERBIL_PATH=$PWD/lib
73
export PATH=$PWD/bin:$PATH
74
${gambit-support.export-gambopt gambit-params}
···
76
# Build, replacing make by build.sh
77
( cd src && sh build.sh )
78
0
0
0
0
79
runHook postBuild
80
'';
81
82
installPhase = ''
83
runHook preInstall
84
mkdir -p $out/gerbil $out/bin
85
-
(cd src; ./install)
86
(cd $out/bin ; ln -s ../gerbil/bin/* .)
87
runHook postInstall
88
'';
···
98
platforms = lib.platforms.unix;
99
maintainers = with lib.maintainers; [ fare ];
100
};
0
0
101
}
···
1
{ pkgs, gccStdenv, lib, coreutils,
2
+
openssl, zlib, sqlite,
3
+
version, git-version, src,
4
gambit-support,
5
+
gambit-git-version,
6
+
gambit-stampYmd,
7
+
gambit-stampHms,
8
+
gambit-params }:
9
10
# We use Gambit, that works 10x better with GCC than Clang. See ../gambit/build.nix
11
let stdenv = gccStdenv; in
···
15
inherit version;
16
inherit src;
17
18
+
buildInputs_libraries = [ openssl zlib sqlite ];
19
20
# TODO: either fix all of Gerbil's dependencies to provide static libraries,
21
# or give up and delete all tentative support for static libraries.
22
#buildInputs_staticLibraries = map makeStaticLibraries buildInputs_libraries;
23
24
+
buildInputs = buildInputs_libraries;
0
0
0
25
26
postPatch = ''
27
echo '(define (gerbil-version-string) "v${git-version}")' > src/gerbil/runtime/gx-version.scm ;
···
29
grep -Fl '#!/usr/bin/env' `find . -type f -executable` | while read f ; do
30
substituteInPlace "$f" --replace '#!/usr/bin/env' '#!${coreutils}/bin/env' ;
31
done ;
32
+
substituteInPlace ./configure --replace 'set -e' 'set -e ; git () { echo "v${git-version}" ;}' ;
33
+
substituteInPlace ./src/build/build-version.scm --replace "with-exception-catcher" '(lambda _ "v${git-version}")' ;
34
+
#rmdir src/gambit
35
+
#cp -a ${pkgs.gambit-unstable.src} ./src/gambit
36
+
chmod -R u+w ./src/gambit
37
+
( cd src/gambit ; ${gambit-params.fixStamp gambit-git-version gambit-stampYmd gambit-stampHms} )
38
+
for f in src/bootstrap/gerbil/compiler/driver__0.scm \
39
+
src/build/build-libgerbil.ss \
40
+
src/gerbil/compiler/driver.ss ; do
41
+
substituteInPlace "$f" --replace '"gcc"' '"${gccStdenv.cc}/bin/${gccStdenv.cc.targetPrefix}gcc"' ;
42
+
done
43
'';
44
45
## TODO: make static compilation work.
···
51
# OPENSSL_LIBSSL=${makeStaticLibraries openssl}/lib/libssl.a # MISSING!
52
# ZLIB=${makeStaticLibraries zlib}/lib/libz.a
53
# SQLITE=${makeStaticLibraries sqlite}/lib/sqlite.a # MISSING!
0
0
0
0
0
54
# EOF
55
56
+
configureFlags = [
57
+
"--prefix=$out/gerbil"
58
+
"--enable-zlib"
59
+
"--enable-sqlite"
60
+
"--enable-shared"
61
+
"--disable-deprecated"
62
+
"--enable-march=" # Avoid non-portable invalid instructions
63
+
];
64
+
65
configurePhase = ''
66
+
export CC=${gccStdenv.cc}/bin/${gccStdenv.cc.targetPrefix}gcc \
67
+
CXX=${gccStdenv.cc}/bin/${gccStdenv.cc.targetPrefix}g++ \
68
+
CPP=${gccStdenv.cc}/bin/${gccStdenv.cc.targetPrefix}cpp \
69
+
CXXCPP=${gccStdenv.cc}/bin/${gccStdenv.cc.targetPrefix}cpp \
70
+
LD=${gccStdenv.cc}/bin/${gccStdenv.cc.targetPrefix}ld \
71
+
XMKMF=${coreutils}/bin/false
72
+
unset CFLAGS LDFLAGS LIBS CPPFLAGS CXXFLAGS
73
+
(cd src/gambit ; ${gambit-params.fixStamp gambit-git-version gambit-stampYmd gambit-stampHms})
74
+
./configure ${builtins.concatStringsSep " " configureFlags}
75
+
(cd src/gambit ;
76
+
substituteInPlace config.status \
77
+
${lib.optionalString (gccStdenv.isDarwin && !gambit-params.stable)
78
+
''--replace "/usr/local/opt/openssl@1.1" "${lib.getLib openssl}"''} \
79
+
--replace "/usr/local/opt/openssl" "${lib.getLib openssl}"
80
+
./config.status
81
+
)
82
'';
83
+
84
+
extraLdOptions = [
85
+
"-L${zlib}/lib"
86
+
"-L${openssl.out}/lib"
87
+
"-L${sqlite.out}/lib"
88
+
];
89
90
buildPhase = ''
91
runHook preBuild
···
95
export GERBIL_BUILD_CORES=$NIX_BUILD_CORES
96
export GERBIL_GXC=$PWD/bin/gxc
97
export GERBIL_BASE=$PWD
98
+
export GERBIL_PREFIX=$PWD
99
export GERBIL_PATH=$PWD/lib
100
export PATH=$PWD/bin:$PATH
101
${gambit-support.export-gambopt gambit-params}
···
103
# Build, replacing make by build.sh
104
( cd src && sh build.sh )
105
106
+
f=build/lib/libgerbil.so.ldd ; [ -f $f ] && :
107
+
substituteInPlace "$f" --replace '(' \
108
+
'(${lib.strings.concatStrings (map (x: "\"${x}\" " ) extraLdOptions)}'
109
+
110
runHook postBuild
111
'';
112
113
installPhase = ''
114
runHook preInstall
115
mkdir -p $out/gerbil $out/bin
116
+
./install.sh
117
(cd $out/bin ; ln -s ../gerbil/bin/* .)
118
runHook postInstall
119
'';
···
129
platforms = lib.platforms.unix;
130
maintainers = with lib.maintainers; [ fare ];
131
};
132
+
133
+
outputsToInstall = [ "out" ];
134
}
+12
-6
pkgs/development/compilers/gerbil/default.nix
···
1
-
{ callPackage, fetchFromGitHub }:
2
3
callPackage ./build.nix rec {
4
-
version = "0.17";
5
-
git-version = version;
6
src = fetchFromGitHub {
7
-
owner = "vyzo";
8
repo = "gerbil";
9
-
rev = "v${version}";
10
-
sha256 = "0xzi9mhrmzcajhlz5qcnz4yjlljvbkbm9426iifgjn47ac0965zw";
0
11
};
0
0
0
0
0
12
}
···
1
+
{ callPackage, fetchFromGitHub, gambit-unstable, gambit-support, pkgs, gccStdenv }:
2
3
callPackage ./build.nix rec {
4
+
version = "0.18";
5
+
git-version = "0.18";
6
src = fetchFromGitHub {
7
+
owner = "mighty-gerbils";
8
repo = "gerbil";
9
+
rev = "8ca36a928bc9345f9d28e5f2dfcb55ca558e85f9";
10
+
sha256 = "sha256-EMiYgQM/Gl+dh6AxLYRZ0BKZ+VKFd+Lkyy9Pw11ivE8=";
11
+
fetchSubmodules = true;
12
};
13
+
inherit gambit-support;
14
+
gambit-params = gambit-support.unstable-params;
15
+
gambit-git-version = "4.9.5-40-g24201248"; # pkgs.gambit-unstable.passthru.git-version
16
+
gambit-stampYmd = "20230917"; # pkgs.gambit-unstable.passthru.git-stampYmd
17
+
gambit-stampHms = "182043"; # pkgs.gambit-unstable.passthru.git-stampHms
18
}
+31
-22
pkgs/development/compilers/gerbil/gerbil-support.nix
···
1
{ pkgs, lib, callPackage, ... }:
2
3
-
with pkgs.gerbil-support; {
0
0
0
0
0
4
5
prePackages-unstable =
6
-
let pks = [ ./gerbil-libp2p.nix ./smug-gerbil.nix ./ftw.nix
7
-
./gerbil-utils.nix ./gerbil-crypto.nix ./gerbil-poo.nix
8
-
./gerbil-persist.nix ./gerbil-ethereum.nix ./glow-lang.nix ];
9
-
call = pkg: callPackage pkg prePackage-defaults;
10
-
pkgName = pkg: lib.removeSuffix ".nix" (baseNameOf pkg);
11
-
f = pkg: { name = pkgName pkg; value = call pkg; }; in
12
-
builtins.listToAttrs (map f pks);
0
0
13
14
prePackage-defaults = {
15
gerbil = pkgs.gerbil-unstable;
···
25
softwareName = "";
26
};
27
28
-
gerbilPackages-unstable =
29
-
builtins.mapAttrs (_: gerbilPackage) prePackages-unstable;
30
31
resolve-pre-src = pre-src: pre-src.fun (removeAttrs pre-src ["fun"]);
32
33
-
gerbilVersionFromGit = pkg:
34
-
let version-path = "${pkg.passthru.pre-pkg.version-path}.ss"; in
35
-
if builtins.pathExists version-path then
36
let m =
37
builtins.match "\\(import :clan/versioning.*\\)\n\\(register-software \"([-_.A-Za-z0-9]+)\" \"([-_.A-Za-z0-9]+)\"\\) ;; ([-0-9]+)\n"
38
-
(builtins.readFile version-path); in
39
-
{ version = builtins.elemAt m 2; git-version = builtins.elemAt m 1; }
40
-
else { version = "0.0";
41
-
git-version = let gitpath = "${toString pkg.src}/.git"; in
42
if builtins.pathExists gitpath then lib.commitIdFromGitRepo gitpath else "0"; };
43
44
-
gerbilSkippableFiles = [".git" ".build" ".build_outputs" "run" "result" "dep" "BLAH"
45
-
"version.ss" "tmp.nix"];
46
47
gerbilSourceFilter = path: type:
48
let baseName = baseNameOf path; in
···
66
if old-sha256 == new-sha256 then {} else
67
view "Overriding ${name} old-sha256: ${old-sha256} new-sha256: ${new-sha256}"
68
{ ${name} = super.${name} // {
69
-
pre-src = new-pre-src;
70
-
version = "override";
71
-
git-version = if new-pre-src ? rev then lib.substring 0 7 new-pre-src.rev else "unknown";};};
0
0
0
72
73
pkgsOverrideGerbilPackageSrc = name: pre-src: pkgs: super: {
74
gerbil-support = (super-support:
···
1
{ pkgs, lib, callPackage, ... }:
2
3
+
with pkgs.gerbil-support; {
4
+
5
+
pppToName = ppp: lib.removeSuffix ".nix" (baseNameOf ppp); # from pre-package path to name
6
+
callPpp = ppp: callPackage ppp prePackage-defaults; # from pre-package path to pre-package
7
+
pppToKV = ppp: { name = pppToName ppp; value = callPpp ppp; }; # from pre-package path to name
8
+
ppplToPpa = ppps: builtins.listToAttrs (map pppToKV ppps); # from pre-package path list to name/pre-package attr
9
10
prePackages-unstable =
11
+
ppplToPpa
12
+
[ ./gerbil-leveldb.nix ./gerbil-lmdb.nix ./gerbil-mysql.nix
13
+
./gerbil-libxml.nix ./gerbil-libyaml.nix
14
+
./smug-gerbil.nix ./ftw.nix
15
+
./gerbil-utils.nix ./gerbil-crypto.nix ./gerbil-poo.nix
16
+
./gerbil-persist.nix ./gerbil-ethereum.nix
17
+
# ./gerbil-libp2p.nix
18
+
# ./glow-lang.nix
19
+
];
20
21
prePackage-defaults = {
22
gerbil = pkgs.gerbil-unstable;
···
32
softwareName = "";
33
};
34
35
+
ppaToPl = builtins.mapAttrs (_: gerbilPackage);
36
+
gerbilPackages-unstable = ppaToPl prePackages-unstable;
37
38
resolve-pre-src = pre-src: pre-src.fun (removeAttrs pre-src ["fun"]);
39
40
+
gerbilVersionFromGit = srcDir: version-path:
41
+
let version-file = "${srcDir}/${version-path}.ss"; in
42
+
if builtins.pathExists version-file then
43
let m =
44
builtins.match "\\(import :clan/versioning.*\\)\n\\(register-software \"([-_.A-Za-z0-9]+)\" \"([-_.A-Za-z0-9]+)\"\\) ;; ([-0-9]+)\n"
45
+
(builtins.readFile version-file); in
46
+
{ version = "${builtins.elemAt m 2}-git"; git-version = builtins.elemAt m 1; }
47
+
else { version = "0.0-git";
48
+
git-version = let gitpath = "${srcDir}/.git"; in
49
if builtins.pathExists gitpath then lib.commitIdFromGitRepo gitpath else "0"; };
50
51
+
gerbilSkippableFiles = [".git" ".build" ".build_outputs" "run" "result" "dep" "BLAH" "tmp.nix"];
0
52
53
gerbilSourceFilter = path: type:
54
let baseName = baseNameOf path; in
···
72
if old-sha256 == new-sha256 then {} else
73
view "Overriding ${name} old-sha256: ${old-sha256} new-sha256: ${new-sha256}"
74
{ ${name} = super.${name} // {
75
+
pre-src = new-pre-src;
76
+
version = "override";
77
+
git-version = if new-pre-src ? rev
78
+
then lib.substring 0 7 new-pre-src.rev
79
+
else "unknown";};
80
+
};
81
82
pkgsOverrideGerbilPackageSrc = name: pre-src: pkgs: super: {
83
gerbil-support = (super-support:
+4
-4
pkgs/development/compilers/gerbil/gerbil-utils.nix
···
2
3
{
4
pname = "gerbil-utils";
5
-
version = "unstable-2023-07-22";
6
-
git-version = "0.2-198-g2fb01ce";
7
softwareName = "Gerbil-utils";
8
gerbil-package = "clan";
9
version-path = "version";
···
12
fun = fetchFromGitHub;
13
owner = "fare";
14
repo = "gerbil-utils";
15
-
rev = "2fb01ce0b302f232f5c4daf4987457b6357d609d";
16
-
sha256 = "127q98gk1x6y1nlkkpnbnkz989ybpszy7aiy43hzai2q6xn4nv72";
17
};
18
19
meta = with lib; {
···
2
3
{
4
pname = "gerbil-utils";
5
+
version = "unstable-2023-09-18";
6
+
git-version = "0.2-199-ga604965";
7
softwareName = "Gerbil-utils";
8
gerbil-package = "clan";
9
version-path = "version";
···
12
fun = fetchFromGitHub;
13
owner = "fare";
14
repo = "gerbil-utils";
15
+
rev = "a6049651d163a23bb4a876b9745dd572f1eaf536";
16
+
sha256 = "1k4g4qdzrx72bb14y5cb045bwkfzvmlsaxlga1j7w1vm6ann5lp2";
17
};
18
19
meta = with lib; {