2016-03-03 16:55:17 +00:00
|
|
|
{ stdenv, ensureNewerSourcesHook, autoconf, automake, makeWrapper, pkgconfig
|
|
|
|
, libtool, which, git
|
2016-10-18 08:23:16 +01:00
|
|
|
, boost, python2Packages, libxml2, zlib
|
2015-04-21 22:57:48 +01: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 19:42:55 +01:00
|
|
|
, zfs ? null
|
|
|
|
|
|
|
|
# Version specific arguments
|
2015-04-22 20:34:34 +01:00
|
|
|
, version, src, patches ? [], buildInputs ? []
|
2015-04-20 19:42:55 +01:00
|
|
|
, ...
|
|
|
|
}:
|
|
|
|
|
2015-04-21 22:57:48 +01:00
|
|
|
# We must have one crypto library
|
|
|
|
assert cryptopp != null || (nss != null && nspr != null);
|
|
|
|
|
2015-06-25 02:25:53 +01:00
|
|
|
with stdenv;
|
2015-04-20 19:42:55 +01:00
|
|
|
with stdenv.lib;
|
|
|
|
let
|
2016-10-18 08:23:16 +01:00
|
|
|
inherit (python2Packages) python;
|
2017-04-17 21:48:10 +01:00
|
|
|
mkFlag = trueStr: falseStr: cond: name: val: "--"
|
|
|
|
+ (if cond then trueStr else falseStr)
|
|
|
|
+ name
|
|
|
|
+ optionalString (val != null && cond != false) "=${val}";
|
2015-06-01 20:29:47 +01:00
|
|
|
mkEnable = mkFlag "enable-" "disable-";
|
|
|
|
mkWith = mkFlag "with-" "without-";
|
|
|
|
mkOther = mkFlag "" "" true;
|
|
|
|
|
2015-06-25 02:25:53 +01:00
|
|
|
shouldUsePkg = pkg_: let pkg = (builtins.tryEval pkg_).value;
|
|
|
|
in if lib.any (x: x == system) (pkg.meta.platforms or [])
|
|
|
|
then pkg else null;
|
|
|
|
|
|
|
|
optSnappy = shouldUsePkg snappy;
|
|
|
|
optLeveldb = shouldUsePkg leveldb;
|
|
|
|
optYasm = shouldUsePkg yasm;
|
|
|
|
optFcgi = shouldUsePkg fcgi;
|
|
|
|
optExpat = shouldUsePkg expat;
|
|
|
|
optCurl = shouldUsePkg curl;
|
|
|
|
optFuse = shouldUsePkg fuse;
|
|
|
|
optAccelio = shouldUsePkg accelio;
|
|
|
|
optLibibverbs = shouldUsePkg libibverbs;
|
|
|
|
optLibrdmacm = shouldUsePkg librdmacm;
|
|
|
|
optLibedit = shouldUsePkg libedit;
|
|
|
|
optLibatomic_ops = shouldUsePkg libatomic_ops;
|
|
|
|
optKinetic-cpp-client = shouldUsePkg kinetic-cpp-client;
|
|
|
|
optRocksdb = shouldUsePkg rocksdb;
|
2015-08-02 02:05:40 +01:00
|
|
|
optLibs3 = if versionAtLeast version "10.0.0" then null else shouldUsePkg libs3;
|
2015-06-25 02:25:53 +01:00
|
|
|
|
|
|
|
optJemalloc = shouldUsePkg jemalloc;
|
|
|
|
optGperftools = shouldUsePkg gperftools;
|
|
|
|
|
|
|
|
optCryptopp = shouldUsePkg cryptopp;
|
|
|
|
optNss = shouldUsePkg nss;
|
|
|
|
optNspr = shouldUsePkg nspr;
|
|
|
|
|
|
|
|
optLibaio = shouldUsePkg libaio;
|
|
|
|
optLibxfs = shouldUsePkg libxfs;
|
|
|
|
optZfs = shouldUsePkg zfs;
|
|
|
|
|
|
|
|
hasServer = optSnappy != null && optLeveldb != null;
|
2015-04-21 22:57:48 +01:00
|
|
|
hasMon = hasServer;
|
|
|
|
hasMds = hasServer;
|
|
|
|
hasOsd = hasServer;
|
2015-06-25 02:25:53 +01:00
|
|
|
hasRadosgw = optFcgi != null && optExpat != null && optCurl != null && optLibedit != null;
|
2015-04-21 22:57:48 +01:00
|
|
|
|
2015-07-30 02:14:00 +01:00
|
|
|
hasXio = (stdenv.isLinux || stdenv.isFreeBSD) &&
|
2015-09-01 08:26:14 +01:00
|
|
|
versionAtLeast version "9.0.3" &&
|
2015-07-30 02:14:00 +01:00
|
|
|
optAccelio != null && optLibibverbs != null && optLibrdmacm != null;
|
2015-04-21 22:57:48 +01:00
|
|
|
|
2015-06-25 02:25:53 +01:00
|
|
|
hasRocksdb = versionAtLeast version "9.0.0" && optRocksdb != null;
|
2015-04-22 20:34:34 +01:00
|
|
|
|
|
|
|
# TODO: Reenable when kinetic support is fixed
|
2015-06-25 02:25:53 +01:00
|
|
|
#hasKinetic = versionAtLeast version "9.0.0" && optKinetic-cpp-client != null;
|
|
|
|
hasKinetic = false;
|
2015-04-22 20:34:34 +01:00
|
|
|
|
2015-04-21 22:57:48 +01:00
|
|
|
# Malloc implementation (can be jemalloc, tcmalloc or null)
|
2015-06-25 02:25:53 +01:00
|
|
|
malloc = if optJemalloc != null then optJemalloc else optGperftools;
|
2015-04-21 22:57:48 +01:00
|
|
|
|
|
|
|
# We prefer nss over cryptopp
|
2015-06-25 02:25:53 +01:00
|
|
|
cryptoStr = if optNss != null && optNspr != null then "nss" else
|
|
|
|
if optCryptopp != null then "cryptopp" else "none";
|
2015-04-21 22:57:48 +01:00
|
|
|
cryptoLibsMap = {
|
2015-06-25 02:25:53 +01:00
|
|
|
nss = [ optNss optNspr ];
|
|
|
|
cryptopp = [ optCryptopp ];
|
2015-04-21 22:57:48 +01:00
|
|
|
none = [ ];
|
|
|
|
};
|
|
|
|
|
2015-06-25 02:25:53 +01:00
|
|
|
wrapArgs = "--set PYTHONPATH \"$(toPythonPath $lib)\""
|
2016-10-18 08:23:16 +01:00
|
|
|
+ " --prefix PYTHONPATH : \"$(toPythonPath ${python2Packages.flask})\""
|
2015-07-20 03:44:37 +01:00
|
|
|
+ " --set PATH \"$out/bin\"";
|
2015-04-20 19:42:55 +01:00
|
|
|
in
|
2015-04-20 20:01:40 +01:00
|
|
|
stdenv.mkDerivation {
|
2015-04-20 19:42:55 +01:00
|
|
|
name="ceph-${version}";
|
|
|
|
|
|
|
|
inherit src;
|
|
|
|
|
2015-04-20 20:01:40 +01:00
|
|
|
patches = patches ++ [
|
2015-04-20 19:42:55 +01:00
|
|
|
./0001-Makefile-env-Don-t-force-sbin.patch
|
|
|
|
];
|
|
|
|
|
2016-03-03 16:55:17 +00:00
|
|
|
nativeBuildInputs = [
|
|
|
|
autoconf automake makeWrapper pkgconfig libtool which git
|
|
|
|
(ensureNewerSourcesHook { year = "1980"; })
|
|
|
|
]
|
2015-07-16 01:46:31 +01:00
|
|
|
++ optionals (versionAtLeast version "9.0.2") [
|
2016-10-18 08:23:16 +01:00
|
|
|
python2Packages.setuptools python2Packages.argparse
|
2015-07-16 01:46:31 +01:00
|
|
|
];
|
2015-04-22 20:34:34 +01:00
|
|
|
buildInputs = buildInputs ++ cryptoLibsMap.${cryptoStr} ++ [
|
2016-10-18 08:23:16 +01:00
|
|
|
boost python libxml2 optYasm optLibatomic_ops optLibs3 malloc python2Packages.flask zlib
|
2016-08-30 16:34:45 +01:00
|
|
|
] ++ optionals (versionAtLeast version "9.0.0") [
|
2016-10-18 08:23:16 +01:00
|
|
|
python2Packages.sphinx # Used for docs
|
2016-08-30 16:34:45 +01:00
|
|
|
] ++ optionals stdenv.isLinux [
|
2015-06-25 02:25:53 +01:00
|
|
|
linuxHeaders libuuid udev keyutils optLibaio optLibxfs optZfs
|
2016-08-30 16:34:45 +01:00
|
|
|
] ++ optionals hasServer [
|
2015-06-25 02:25:53 +01:00
|
|
|
optSnappy optLeveldb
|
2016-08-30 16:34:45 +01:00
|
|
|
] ++ optionals hasRadosgw [
|
2015-06-25 02:25:53 +01:00
|
|
|
optFcgi optExpat optCurl optFuse optLibedit
|
2016-08-30 16:34:45 +01:00
|
|
|
] ++ optionals hasXio [
|
2015-06-25 02:25:53 +01:00
|
|
|
optAccelio optLibibverbs optLibrdmacm
|
2016-08-30 16:34:45 +01:00
|
|
|
] ++ optionals hasRocksdb [
|
2015-06-25 02:25:53 +01:00
|
|
|
optRocksdb
|
2016-08-30 16:34:45 +01:00
|
|
|
] ++ optionals hasKinetic [
|
2015-06-25 02:25:53 +01:00
|
|
|
optKinetic-cpp-client
|
2015-04-20 19:42:55 +01:00
|
|
|
];
|
|
|
|
|
2015-04-21 22:57:48 +01: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-06-25 02:25:53 +01:00
|
|
|
'' + optionalString (versionAtLeast version "9.0.0") ''
|
|
|
|
# Fix gmock
|
|
|
|
patchShebangs src/gmock
|
2015-04-21 22:57:48 +01:00
|
|
|
'';
|
|
|
|
|
2015-04-20 19:42:55 +01:00
|
|
|
preConfigure = ''
|
2015-04-21 22:57:48 +01:00
|
|
|
# Ceph expects the arch command to be usable during configure
|
|
|
|
# for detecting the assembly type
|
2015-07-16 01:46:31 +01:00
|
|
|
mkdir -p mybin
|
2015-04-21 22:57:48 +01:00
|
|
|
echo "#${stdenv.shell} -e" >> mybin/arch
|
|
|
|
echo "uname -m" >> mybin/arch
|
|
|
|
chmod +x mybin/arch
|
|
|
|
PATH="$PATH:$(pwd)/mybin"
|
|
|
|
|
2015-04-20 19:42:55 +01:00
|
|
|
./autogen.sh
|
2015-04-21 22:57:48 +01:00
|
|
|
|
|
|
|
# Fix the python site-packages install directory
|
|
|
|
sed -i "s,\(PYTHON\(\|_EXEC\)_PREFIX=\).*,\1'$lib',g" configure
|
2015-07-16 01:46:31 +01:00
|
|
|
|
|
|
|
# Fix the PYTHONPATH for installing ceph-detect-init to $out
|
|
|
|
mkdir -p "$(toPythonPath $out)"
|
|
|
|
export PYTHONPATH="$(toPythonPath $out):$PYTHONPATH"
|
2015-04-20 19:42:55 +01:00
|
|
|
'';
|
|
|
|
|
|
|
|
configureFlags = [
|
2015-08-06 03:28:01 +01:00
|
|
|
(mkOther "exec_prefix" "\${out}")
|
|
|
|
(mkOther "sysconfdir" "/etc")
|
|
|
|
(mkOther "localstatedir" "/var")
|
|
|
|
(mkOther "libdir" "\${lib}/lib")
|
|
|
|
(mkOther "includedir" "\${lib}/include")
|
|
|
|
(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)
|
|
|
|
(mkWith (optFuse != null) "fuse" null)
|
|
|
|
(mkWith (malloc == optJemalloc) "jemalloc" null)
|
|
|
|
(mkWith (malloc == optGperftools) "tcmalloc" null)
|
|
|
|
(mkEnable false "pgrefdebugging" null)
|
|
|
|
(mkEnable false "cephfs-java" null)
|
|
|
|
(mkEnable hasXio "xio" null)
|
|
|
|
(mkWith (optLibatomic_ops != null) "libatomic-ops" null)
|
|
|
|
(mkWith true "ocf" null)
|
|
|
|
(mkWith hasKinetic "kinetic" null)
|
|
|
|
(mkWith hasRocksdb "librocksdb" null)
|
|
|
|
(mkWith false "librocksdb-static" null)
|
2015-04-21 22:57:48 +01:00
|
|
|
] ++ optional stdenv.isLinux [
|
2015-08-06 03:28:01 +01:00
|
|
|
(mkWith (optLibaio != null) "libaio" null)
|
|
|
|
(mkWith (optLibxfs != null) "libxfs" null)
|
|
|
|
(mkWith (optZfs != null) "libzfs" null)
|
|
|
|
] ++ optional (versionAtLeast version "0.94.3") [
|
|
|
|
(mkWith false "tcmalloc-minimal" null)
|
2015-06-25 02:25:53 +01:00
|
|
|
] ++ optional (versionAtLeast version "9.0.1") [
|
2015-08-06 03:28:01 +01:00
|
|
|
(mkWith false "valgrind" null)
|
2015-07-16 01:46:31 +01:00
|
|
|
] ++ optional (versionAtLeast version "9.0.2") [
|
2015-08-06 03:28:01 +01:00
|
|
|
(mkWith true "man-pages" null)
|
|
|
|
(mkWith true "systemd-libexec-dir" "\${out}/libexec")
|
2015-10-17 00:44:46 +01:00
|
|
|
] ++ optional (versionOlder version "9.1.0") [
|
2015-08-06 03:28:01 +01:00
|
|
|
(mkWith (optLibs3 != null) "system-libs3" null)
|
|
|
|
(mkWith true "rest-bench" null)
|
2015-10-17 00:44:46 +01:00
|
|
|
] ++ optional (versionAtLeast version "9.1.0") [
|
2015-08-06 03:28:01 +01:00
|
|
|
(mkWith true "rgw-user" "rgw")
|
|
|
|
(mkWith true "rgw-group" "rgw")
|
|
|
|
(mkWith true "systemd-unit-dir" "\${out}/etc/systemd/system")
|
2015-08-07 22:18:26 +01:00
|
|
|
(mkWith false "selinux" null) # TODO: Implement
|
2015-04-21 22:57:48 +01:00
|
|
|
];
|
2015-04-20 19:42:55 +01:00
|
|
|
|
2015-06-25 02:25:53 +01:00
|
|
|
preBuild = optionalString (versionAtLeast version "9.0.0") ''
|
|
|
|
(cd src/gmock; make -j $NIX_BUILD_CORES)
|
|
|
|
'';
|
|
|
|
|
2015-04-20 19:42:55 +01:00
|
|
|
installFlags = [ "sysconfdir=\${out}/etc" ];
|
|
|
|
|
2015-04-21 22:57:48 +01:00
|
|
|
outputs = [ "out" "lib" ];
|
|
|
|
|
2015-04-20 19:42:55 +01:00
|
|
|
postInstall = ''
|
2015-04-21 22:57:48 +01:00
|
|
|
# Wrap all of the python scripts
|
2015-04-20 19:42:55 +01: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-21 22:57:48 +01: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 20:34:34 +01:00
|
|
|
LIBS="$(sed -n "s/.*find_library('\([^)]*\)').*/\1/p" "$PY")"
|
|
|
|
|
2015-08-02 02:45:23 +01:00
|
|
|
# Delete any calls to find_library
|
|
|
|
sed -i '/find_library/d' "$PY"
|
|
|
|
|
2015-04-22 20:34:34 +01:00
|
|
|
# Fix each find_library call
|
|
|
|
for LIB in $LIBS; do
|
|
|
|
REALLIB="$lib/lib/lib$LIB.so"
|
2015-08-02 02:45:23 +01:00
|
|
|
sed -i "s,\(lib$LIB = CDLL(\).*,\1'$REALLIB'),g" "$PY"
|
2015-04-22 20:34:34 +01:00
|
|
|
done
|
2015-04-21 22:57:48 +01:00
|
|
|
|
|
|
|
# Reapply compilation optimizations
|
|
|
|
NAME=$(basename -s .py "$PY")
|
2015-08-02 02:45:23 +01:00
|
|
|
rm -f "$PY"{c,o}
|
|
|
|
pushd "$(dirname $PY)"
|
|
|
|
python -c "import $NAME"
|
|
|
|
python -O -c "import $NAME"
|
|
|
|
popd
|
|
|
|
test -f "$PY"c
|
|
|
|
test -f "$PY"o
|
2015-04-21 22:57:48 +01:00
|
|
|
done
|
2015-09-18 22:52:20 +01:00
|
|
|
|
|
|
|
# Fix .la file link dependencies
|
|
|
|
find "$lib/lib" -name \*.la | xargs sed -i \
|
2016-04-27 22:41:28 +01:00
|
|
|
-e 's,-lboost_[a-z]*,-L${boost.out}/lib \0,g' \
|
2015-09-18 22:52:20 +01:00
|
|
|
'' + optionalString (cryptoStr == "cryptopp") ''
|
|
|
|
-e 's,-lcryptopp,-L${optCryptopp}/lib \0,g' \
|
|
|
|
'' + optionalString (cryptoStr == "nss") ''
|
|
|
|
-e 's,-l\(plds4\|plc4\|nspr4\),-L${optNss}/lib \0,g' \
|
|
|
|
-e 's,-l\(ssl3\|smime3\|nss3\|nssutil3\),-L${optNspr}/lib \0,g' \
|
|
|
|
'' + ''
|
|
|
|
|
2015-04-20 19:42:55 +01:00
|
|
|
'';
|
|
|
|
|
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
|
|
|
meta = {
|
|
|
|
homepage = http://ceph.com/;
|
|
|
|
description = "Distributed storage system";
|
|
|
|
license = licenses.lgpl21;
|
|
|
|
maintainers = with maintainers; [ ak wkennington ];
|
2015-11-17 20:29:29 +00:00
|
|
|
platforms = platforms.unix;
|
2016-12-29 22:45:15 +00:00
|
|
|
# Broken because of https://lwn.net/Vulnerabilities/709844/
|
|
|
|
# and our version is quite out of date.
|
|
|
|
broken = true;
|
2015-04-20 19:42:55 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
passthru.version = version;
|
|
|
|
}
|