2015-04-20 21:42:55 +03:00
|
|
|
{ stdenv, autoconf, automake, makeWrapper, pkgconfig, libtool, which
|
2015-05-02 18:57:35 +03:00
|
|
|
, boost, python, pythonPackages, libxml2, git, zlib
|
2015-04-22 00:57:48 +03:00
|
|
|
|
|
|
|
# Optional Dependencies
|
|
|
|
, snappy ? null, leveldb ? null, yasm ? null, fcgi ? null, expat ? null
|
|
|
|
, curl ? null, fuse ? null, accelio ? null, libibverbs ? null, librdmacm ? null
|
|
|
|
, libedit ? null, libatomic_ops ? null, kinetic-cpp-client ? null
|
|
|
|
, rocksdb ? null, libs3 ? null
|
|
|
|
|
|
|
|
# Mallocs
|
|
|
|
, jemalloc ? null, gperftools ? null
|
|
|
|
|
|
|
|
# Crypto Dependencies
|
|
|
|
, cryptopp ? null
|
|
|
|
, nss ? null, nspr ? null
|
|
|
|
|
|
|
|
# Linux Only Dependencies
|
|
|
|
, linuxHeaders, libuuid, udev, keyutils, libaio ? null, libxfs ? null
|
2015-04-20 21:42:55 +03:00
|
|
|
, zfs ? null
|
|
|
|
|
|
|
|
# Version specific arguments
|
2015-04-22 22:34:34 +03:00
|
|
|
, version, src, patches ? [], buildInputs ? []
|
2015-04-20 21:42:55 +03:00
|
|
|
, ...
|
|
|
|
}:
|
|
|
|
|
2015-04-22 00:57:48 +03:00
|
|
|
# We must have one crypto library
|
|
|
|
assert cryptopp != null || (nss != null && nspr != null);
|
|
|
|
|
2015-04-20 21:42:55 +03:00
|
|
|
with stdenv.lib;
|
|
|
|
let
|
2015-06-01 22:29:47 +03:00
|
|
|
mkFlag = trueStr: falseStr: cond: name: val:
|
|
|
|
if cond == null then null else
|
|
|
|
"--${if cond != false then trueStr else falseStr}${name}${if val != null && cond != false then "=${val}" else ""}";
|
|
|
|
mkEnable = mkFlag "enable-" "disable-";
|
|
|
|
mkWith = mkFlag "with-" "without-";
|
|
|
|
mkOther = mkFlag "" "" true;
|
|
|
|
|
2015-06-01 22:28:56 +03:00
|
|
|
hasServer = snappy != null && leveldb != null;
|
2015-04-22 00:57:48 +03:00
|
|
|
hasMon = hasServer;
|
|
|
|
hasMds = hasServer;
|
|
|
|
hasOsd = hasServer;
|
2015-06-01 22:28:56 +03:00
|
|
|
hasRadosgw = fcgi != null && expat != null && curl != null && libedit != null;
|
2015-04-22 00:57:48 +03:00
|
|
|
|
2015-04-23 22:45:13 +03:00
|
|
|
hasXio = (stdenv.isLinux || stdenv.isFreeBSD) &&
|
2015-06-01 22:28:51 +03:00
|
|
|
versionAtLeast version "0.95" &&
|
2015-06-01 22:28:56 +03:00
|
|
|
accelio != null && libibverbs != null && librdmacm != null;
|
2015-04-22 00:57:48 +03:00
|
|
|
|
2015-06-01 22:28:56 +03:00
|
|
|
hasRocksdb = versionAtLeast version "0.95" && rocksdb != null;
|
2015-04-22 22:34:34 +03:00
|
|
|
|
|
|
|
# TODO: Reenable when kinetic support is fixed
|
2015-06-01 22:28:56 +03:00
|
|
|
hasKinetic = versionAtLeast version "0.95" && kinetic-cpp-client != null && false;
|
2015-04-22 22:34:34 +03:00
|
|
|
|
2015-04-22 00:57:48 +03:00
|
|
|
# Malloc implementation (can be jemalloc, tcmalloc or null)
|
2015-06-01 22:28:56 +03:00
|
|
|
malloc = if jemalloc != null then jemalloc else gperftools;
|
2015-04-22 00:57:48 +03:00
|
|
|
|
|
|
|
# We prefer nss over cryptopp
|
2015-06-01 22:28:56 +03:00
|
|
|
cryptoStr = if nss != null && nspr != null then "nss" else
|
|
|
|
if cryptopp != null then "cryptopp" else "none";
|
2015-04-22 00:57:48 +03:00
|
|
|
cryptoLibsMap = {
|
2015-06-01 22:28:56 +03:00
|
|
|
nss = [ nss nspr ];
|
|
|
|
cryptopp = [ cryptopp ];
|
2015-04-22 00:57:48 +03:00
|
|
|
none = [ ];
|
|
|
|
};
|
|
|
|
|
2015-05-20 08:56:44 +03:00
|
|
|
wrapArgs = "--set PYTHONPATH : \"$(toPythonPath $lib)\""
|
2015-04-20 21:42:55 +03:00
|
|
|
+ " --prefix PYTHONPATH : \"$(toPythonPath ${python.modules.readline})\""
|
2015-04-22 00:57:48 +03:00
|
|
|
+ " --prefix PYTHONPATH : \"$(toPythonPath ${pythonPackages.flask})\""
|
2015-05-20 08:56:44 +03:00
|
|
|
+ " --set PATH : \"$out/bin\"";
|
2015-04-20 21:42:55 +03:00
|
|
|
in
|
2015-04-20 22:01:40 +03:00
|
|
|
stdenv.mkDerivation {
|
2015-04-20 21:42:55 +03:00
|
|
|
name="ceph-${version}";
|
|
|
|
|
|
|
|
inherit src;
|
|
|
|
|
2015-04-20 22:01:40 +03:00
|
|
|
patches = patches ++ [
|
2015-04-20 21:42:55 +03:00
|
|
|
./0001-Makefile-env-Don-t-force-sbin.patch
|
|
|
|
];
|
|
|
|
|
2015-06-01 22:28:45 +03:00
|
|
|
nativeBuildInputs = [ autoconf automake makeWrapper pkgconfig libtool which ];
|
2015-04-22 22:34:34 +03:00
|
|
|
buildInputs = buildInputs ++ cryptoLibsMap.${cryptoStr} ++ [
|
2015-06-01 22:28:56 +03:00
|
|
|
boost python libxml2 yasm libatomic_ops libs3 malloc pythonPackages.flask zlib
|
2015-05-20 08:56:44 +03:00
|
|
|
] ++ optional (versionAtLeast version "9.0.0") [
|
2015-04-23 00:32:41 +03:00
|
|
|
git # Used for the gitversion string
|
|
|
|
pythonPackages.sphinx # Used for docs
|
2015-04-22 22:34:34 +03:00
|
|
|
] ++ optional stdenv.isLinux [
|
2015-06-01 22:28:56 +03:00
|
|
|
linuxHeaders libuuid udev keyutils libaio libxfs zfs
|
2015-04-22 22:34:34 +03:00
|
|
|
] ++ optional hasServer [
|
2015-06-01 22:28:56 +03:00
|
|
|
snappy leveldb
|
2015-04-22 22:34:34 +03:00
|
|
|
] ++ optional hasRadosgw [
|
2015-06-01 22:28:56 +03:00
|
|
|
fcgi expat curl fuse libedit
|
2015-04-22 22:34:34 +03:00
|
|
|
] ++ optional hasXio [
|
2015-06-01 22:28:56 +03:00
|
|
|
accelio libibverbs librdmacm
|
2015-04-22 22:34:34 +03:00
|
|
|
] ++ optional hasRocksdb [
|
2015-06-01 22:28:56 +03:00
|
|
|
rocksdb
|
2015-04-22 22:34:34 +03:00
|
|
|
] ++ optional hasKinetic [
|
2015-06-01 22:28:56 +03:00
|
|
|
kinetic-cpp-client
|
2015-04-20 21:42:55 +03:00
|
|
|
];
|
|
|
|
|
2015-04-22 00:57:48 +03:00
|
|
|
postPatch = ''
|
|
|
|
# Fix zfs pkgconfig detection
|
|
|
|
sed -i 's,\[zfs\],\[libzfs\],g' configure.ac
|
|
|
|
|
|
|
|
# Fix seagate kinetic linking
|
|
|
|
sed -i 's,libcrypto.a,-lcrypto,g' src/os/Makefile.am
|
|
|
|
'';
|
|
|
|
|
2015-04-20 21:42:55 +03:00
|
|
|
preConfigure = ''
|
2015-04-22 00:57:48 +03:00
|
|
|
# Ceph expects the arch command to be usable during configure
|
|
|
|
# for detecting the assembly type
|
|
|
|
mkdir mybin
|
|
|
|
echo "#${stdenv.shell} -e" >> mybin/arch
|
|
|
|
echo "uname -m" >> mybin/arch
|
|
|
|
chmod +x mybin/arch
|
|
|
|
PATH="$PATH:$(pwd)/mybin"
|
|
|
|
|
2015-04-20 21:42:55 +03:00
|
|
|
./autogen.sh
|
2015-04-22 00:57:48 +03:00
|
|
|
|
|
|
|
# Fix the python site-packages install directory
|
|
|
|
sed -i "s,\(PYTHON\(\|_EXEC\)_PREFIX=\).*,\1'$lib',g" configure
|
2015-04-20 21:42:55 +03:00
|
|
|
'';
|
|
|
|
|
|
|
|
configureFlags = [
|
|
|
|
"--exec_prefix=\${out}"
|
|
|
|
"--sysconfdir=/etc"
|
|
|
|
"--localstatedir=/var"
|
2015-04-22 00:57:48 +03:00
|
|
|
"--libdir=\${lib}/lib"
|
|
|
|
"--includedir=\${lib}/include"
|
|
|
|
|
2015-06-01 22:28:45 +03:00
|
|
|
(mkWith true "rbd" null)
|
|
|
|
(mkWith true "cephfs" null)
|
|
|
|
(mkWith hasRadosgw "radosgw" null)
|
|
|
|
(mkWith true "radosstriper" null)
|
|
|
|
(mkWith hasServer "mon" null)
|
|
|
|
(mkWith hasServer "osd" null)
|
|
|
|
(mkWith hasServer "mds" null)
|
|
|
|
(mkEnable true "client" null)
|
|
|
|
(mkEnable hasServer "server" null)
|
|
|
|
(mkWith (cryptoStr == "cryptopp") "cryptopp" null)
|
|
|
|
(mkWith (cryptoStr == "nss") "nss" null)
|
|
|
|
(mkEnable false "root-make-check" null)
|
|
|
|
(mkWith false "profiler" null)
|
|
|
|
(mkWith false "debug" null)
|
|
|
|
(mkEnable false "coverage" null)
|
2015-06-01 22:28:56 +03:00
|
|
|
(mkWith (fuse != null) "fuse" null)
|
|
|
|
(mkWith (malloc == jemalloc) "jemalloc" null)
|
|
|
|
(mkWith (malloc == gperftools) "tcmalloc" null)
|
2015-06-01 22:28:45 +03:00
|
|
|
(mkEnable false "pgrefdebugging" null)
|
|
|
|
(mkEnable false "cephfs-java" null)
|
|
|
|
(mkEnable hasXio "xio" null)
|
2015-06-01 22:28:56 +03:00
|
|
|
(mkWith (libatomic_ops != null) "libatomic-ops" null)
|
2015-06-01 22:28:45 +03:00
|
|
|
(mkWith true "ocf" null)
|
|
|
|
(mkWith hasKinetic "kinetic" null)
|
|
|
|
(mkWith hasRocksdb "librocksdb" null)
|
|
|
|
(mkWith false "librocksdb-static" null)
|
2015-06-01 22:28:56 +03:00
|
|
|
(mkWith (libs3 != null) "system-libs3" null)
|
2015-06-01 22:28:45 +03:00
|
|
|
(mkWith true "rest-bench" null)
|
2015-04-22 00:57:48 +03:00
|
|
|
] ++ optional stdenv.isLinux [
|
2015-06-01 22:28:56 +03:00
|
|
|
(mkWith (libaio != null) "libaio" null)
|
|
|
|
(mkWith (libxfs != null) "libxfs" null)
|
|
|
|
(mkWith (zfs != null) "libzfs" null)
|
2015-05-20 08:56:44 +03:00
|
|
|
] ++ optional (versionAtLeast version "10.0.0") [
|
2015-06-01 22:28:45 +03:00
|
|
|
(mkWith true "man-pages" null)
|
|
|
|
(mkWith false "tcmalloc-minimal" null)
|
|
|
|
(mkWith false "valgrind" null)
|
2015-04-22 00:57:48 +03:00
|
|
|
];
|
2015-04-20 21:42:55 +03:00
|
|
|
|
|
|
|
installFlags = [ "sysconfdir=\${out}/etc" ];
|
|
|
|
|
2015-04-22 00:57:48 +03:00
|
|
|
outputs = [ "out" "lib" ];
|
|
|
|
|
2015-04-20 21:42:55 +03:00
|
|
|
postInstall = ''
|
2015-04-22 00:57:48 +03:00
|
|
|
# Wrap all of the python scripts
|
2015-04-20 21:42:55 +03:00
|
|
|
wrapProgram $out/bin/ceph ${wrapArgs}
|
|
|
|
wrapProgram $out/bin/ceph-brag ${wrapArgs}
|
|
|
|
wrapProgram $out/bin/ceph-rest-api ${wrapArgs}
|
|
|
|
wrapProgram $out/sbin/ceph-create-keys ${wrapArgs}
|
|
|
|
wrapProgram $out/sbin/ceph-disk ${wrapArgs}
|
2015-04-22 00:57:48 +03:00
|
|
|
|
|
|
|
# Bring in lib as a native build input
|
|
|
|
mkdir -p $out/nix-support
|
|
|
|
echo "$lib" > $out/nix-support/propagated-native-build-inputs
|
|
|
|
|
|
|
|
# Fix the python library loading
|
|
|
|
find $lib/lib -name \*.pyc -or -name \*.pyd -exec rm {} \;
|
|
|
|
for PY in $(find $lib/lib -name \*.py); do
|
2015-04-22 22:34:34 +03:00
|
|
|
LIBS="$(sed -n "s/.*find_library('\([^)]*\)').*/\1/p" "$PY")"
|
|
|
|
|
|
|
|
# Fix each find_library call
|
|
|
|
for LIB in $LIBS; do
|
|
|
|
REALLIB="$lib/lib/lib$LIB.so"
|
|
|
|
sed -i "s,find_library('$LIB'),'$REALLIB',g" "$PY"
|
|
|
|
done
|
2015-04-22 00:57:48 +03:00
|
|
|
|
|
|
|
# Reapply compilation optimizations
|
|
|
|
NAME=$(basename -s .py "$PY")
|
|
|
|
(cd "$(dirname $PY)"; python -c "import $NAME"; python -O -c "import $NAME")
|
|
|
|
done
|
2015-04-20 21:42:55 +03:00
|
|
|
'';
|
|
|
|
|
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
|
|
|
meta = {
|
|
|
|
homepage = http://ceph.com/;
|
|
|
|
description = "Distributed storage system";
|
|
|
|
license = licenses.lgpl21;
|
|
|
|
maintainers = with maintainers; [ ak wkennington ];
|
2015-04-22 00:57:48 +03:00
|
|
|
platforms = with platforms; unix;
|
2015-04-20 21:42:55 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
passthru.version = version;
|
|
|
|
}
|