2021-01-21 17:00:13 +00:00
|
|
|
{ lib, stdenv, fetchFromGitHub, cmake
|
2021-11-06 22:29:49 +00:00
|
|
|
, fetchpatch
|
2021-01-03 21:40:14 +00:00
|
|
|
, static ? stdenv.hostPlatform.isStatic
|
|
|
|
}:
|
2013-02-18 21:12:11 +00:00
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
2019-08-15 12:41:18 +00:00
|
|
|
pname = "snappy";
|
2023-03-14 21:20:46 +00:00
|
|
|
version = "1.1.10";
|
2017-10-26 23:44:19 +00:00
|
|
|
|
2017-11-24 13:20:52 +00:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "google";
|
|
|
|
repo = "snappy";
|
2019-09-08 23:38:31 +00:00
|
|
|
rev = version;
|
2023-03-14 21:20:46 +00:00
|
|
|
hash = "sha256-wYZkKVDXKCugycx/ZYhjV0BjM/NrEM0R6A4WFhs/WPU=";
|
2013-02-18 21:12:11 +00:00
|
|
|
};
|
|
|
|
|
2021-11-06 22:29:49 +00:00
|
|
|
patches = [
|
2021-12-02 12:21:52 +00:00
|
|
|
# Re-enable RTTI, without which other applications can't subclass
|
|
|
|
# snappy::Source (this breaks Ceph, as one example)
|
|
|
|
# https://tracker.ceph.com/issues/53060
|
|
|
|
# https://build.opensuse.org/package/show/openSUSE:Factory/snappy
|
|
|
|
(fetchpatch {
|
|
|
|
url = "https://build.opensuse.org/public/source/openSUSE:Factory/snappy/reenable-rtti.patch?rev=a759aa6fba405cd40025e3f0ab89941d";
|
|
|
|
sha256 = "sha256-RMuM5yd6zP1eekN/+vfS54EyY4cFbGDVor1E1vj3134=";
|
|
|
|
})
|
2021-11-06 22:29:49 +00:00
|
|
|
];
|
|
|
|
|
2017-11-24 13:20:52 +00:00
|
|
|
outputs = [ "out" "dev" ];
|
2017-03-03 13:29:39 +00:00
|
|
|
|
2017-11-24 13:20:52 +00:00
|
|
|
nativeBuildInputs = [ cmake ];
|
2013-02-18 21:12:11 +00:00
|
|
|
|
2023-03-24 17:22:44 +00:00
|
|
|
# See https://github.com/NixOS/nixpkgs/pull/219778#issuecomment-1464884412
|
|
|
|
# and https://github.com/NixOS/nixpkgs/pull/221215#issuecomment-1482564003.
|
|
|
|
env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.isDarwin "-Wno-sign-compare";
|
2023-03-14 21:20:46 +00:00
|
|
|
|
2019-12-16 12:16:38 +00:00
|
|
|
cmakeFlags = [
|
|
|
|
"-DBUILD_SHARED_LIBS=${if static then "OFF" else "ON"}"
|
2021-10-26 22:41:17 +00:00
|
|
|
"-DSNAPPY_BUILD_TESTS=OFF"
|
|
|
|
"-DSNAPPY_BUILD_BENCHMARKS=OFF"
|
2019-12-16 12:16:38 +00:00
|
|
|
];
|
2017-12-20 03:28:14 +00:00
|
|
|
|
2019-04-05 23:07:15 +00:00
|
|
|
postInstall = ''
|
|
|
|
substituteInPlace "$out"/lib/cmake/Snappy/SnappyTargets.cmake \
|
|
|
|
--replace 'INTERFACE_INCLUDE_DIRECTORIES "''${_IMPORT_PREFIX}/include"' 'INTERFACE_INCLUDE_DIRECTORIES "'$dev'"'
|
2021-10-26 22:41:17 +00:00
|
|
|
|
|
|
|
mkdir -p $dev/lib/pkgconfig
|
|
|
|
cat <<EOF > $dev/lib/pkgconfig/snappy.pc
|
|
|
|
Name: snappy
|
|
|
|
Description: Fast compressor/decompressor library.
|
|
|
|
Version: ${version}
|
|
|
|
Libs: -L$out/lib -lsnappy
|
|
|
|
Cflags: -I$dev/include
|
|
|
|
EOF
|
2019-04-05 23:07:15 +00:00
|
|
|
'';
|
|
|
|
|
2021-10-26 22:41:17 +00:00
|
|
|
#checkTarget = "test";
|
2014-09-14 02:13:43 +00:00
|
|
|
|
2021-10-26 22:41:17 +00:00
|
|
|
# requires gbenchmark and gtest but it also installs them out $dev
|
|
|
|
doCheck = false;
|
2013-02-18 21:12:11 +00:00
|
|
|
|
2021-01-21 17:00:13 +00:00
|
|
|
meta = with lib; {
|
2019-12-16 12:16:38 +00:00
|
|
|
homepage = "https://google.github.io/snappy/";
|
2014-09-14 02:13:43 +00:00
|
|
|
license = licenses.bsd3;
|
2013-02-18 21:12:11 +00:00
|
|
|
description = "Compression/decompression library for very high speeds";
|
2019-11-12 19:48:23 +00:00
|
|
|
platforms = platforms.all;
|
2013-02-18 21:12:11 +00:00
|
|
|
};
|
|
|
|
}
|