2023-04-12 12:48:02 +00:00
{ lib
, stdenv
, runCommand
, fetchurl
, fetchFromGitHub
# Build time
, cmake
2020-04-24 23:36:52 +00:00
, ensureNewerSourcesHook
2023-04-12 12:48:02 +00:00
, fmt
, git
2021-02-16 17:04:54 +00:00
, makeWrapper
2023-04-12 12:48:02 +00:00
, pkg-config
, which
# Tests
2021-02-16 17:04:54 +00:00
, nixosTests
2023-04-12 12:48:02 +00:00
# Runtime dependencies
, arrow-cpp
, babeltrace
, boost179
2021-04-22 02:08:21 +00:00
, bzip2
2023-04-12 12:48:02 +00:00
, cryptsetup
, cimg
, cunit
2021-04-22 02:08:21 +00:00
, doxygen
2023-04-12 12:48:02 +00:00
, gperf
2021-04-22 02:08:21 +00:00
, graphviz
2023-04-12 12:48:02 +00:00
, gtest
, icu
, jsoncpp
, libcap_ng
, libnl
, libxml2
, lttng-ust
, lua
, lz4
, oath-toolkit
, openldap
, python310
, rdkafka
, rocksdb
, snappy
, sqlite
, utf8proc
, zlib
, zstd
2020-04-24 23:36:52 +00:00
# Optional Dependencies
2023-04-12 12:48:02 +00:00
, curl ? null
, expat ? null
, fuse ? null
, libatomic_ops ? null
, libedit ? null
2020-04-24 23:36:52 +00:00
, libs3 ? null
2023-04-12 12:48:02 +00:00
, yasm ? null
2020-04-24 23:36:52 +00:00
# Mallocs
2023-04-12 12:48:02 +00:00
, gperftools ? null
, jemalloc ? null
2020-04-24 23:36:52 +00:00
# Crypto Dependencies
, cryptopp ? null
2023-04-12 12:48:02 +00:00
, nspr ? null
, nss ? null
2020-04-24 23:36:52 +00:00
# Linux Only Dependencies
2023-04-12 12:48:02 +00:00
, linuxHeaders
, util-linux
, libuuid
, udev
, keyutils
, rdma-core
, rabbitmq-c
, libaio ? null
, libxfs ? null
, liburing ? null
, zfs ? null
2020-04-24 23:36:52 +00:00
, . . .
} :
# We must have one crypto library
assert cryptopp != null || ( nss != null && nspr != null ) ;
let
shouldUsePkg = pkg : if pkg != null && pkg . meta . available then pkg else null ;
optYasm = shouldUsePkg yasm ;
optExpat = shouldUsePkg expat ;
optCurl = shouldUsePkg curl ;
optFuse = shouldUsePkg fuse ;
optLibedit = shouldUsePkg libedit ;
optLibatomic_ops = shouldUsePkg libatomic_ops ;
optLibs3 = shouldUsePkg libs3 ;
optJemalloc = shouldUsePkg jemalloc ;
optGperftools = shouldUsePkg gperftools ;
optCryptopp = shouldUsePkg cryptopp ;
optNss = shouldUsePkg nss ;
optNspr = shouldUsePkg nspr ;
optLibaio = shouldUsePkg libaio ;
optLibxfs = shouldUsePkg libxfs ;
optZfs = shouldUsePkg zfs ;
2023-04-12 12:48:02 +00:00
# Downgrade rocksdb, 7.10 breaks ceph
rocksdb' = rocksdb . overrideAttrs ( oldAttrs : {
version = " 7 . 9 . 2 " ;
src = fetchFromGitHub {
owner = " f a c e b o o k " ;
repo = " r o c k s d b " ;
rev = " r e f s / t a g s / v 7 . 9 . 2 " ;
hash = " s h a 2 5 6 - 5 P 7 I q J 1 4 E Z z D k b j a B v b i x 0 4 c e G G d l W B u V F H / 5 d p D 5 V M = " ;
} ;
} ) ;
2020-04-24 23:36:52 +00:00
2023-04-12 12:48:02 +00:00
hasRadosgw = optExpat != null && optCurl != null && optLibedit != null ;
2020-04-24 23:36:52 +00:00
# Malloc implementation (can be jemalloc, tcmalloc or null)
malloc = if optJemalloc != null then optJemalloc else optGperftools ;
# We prefer nss over cryptopp
cryptoStr = if optNss != null && optNspr != null then " n s s " else
if optCryptopp != null then " c r y p t o p p " else " n o n e " ;
cryptoLibsMap = {
nss = [ optNss optNspr ] ;
cryptopp = [ optCryptopp ] ;
none = [ ] ;
} ;
2021-02-05 17:12:51 +00:00
getMeta = description : with lib ; {
2022-01-13 20:06:32 +00:00
homepage = " h t t p s : / / c e p h . i o / e n / " ;
2020-07-18 16:06:22 +00:00
inherit description ;
license = with licenses ; [ lgpl21 gpl2 bsd3 mit publicDomain ] ;
maintainers = with maintainers ; [ adev ak johanot krav ] ;
2021-01-09 10:05:03 +00:00
platforms = [ " x 8 6 _ 6 4 - l i n u x " " a a r c h 6 4 - l i n u x " ] ;
2020-07-18 16:06:22 +00:00
} ;
2023-04-12 12:48:02 +00:00
ceph-common = with python . pkgs ; buildPythonPackage {
2020-07-18 16:06:22 +00:00
pname = " c e p h - c o m m o n " ;
inherit src version ;
sourceRoot = " c e p h - ${ version } / s r c / p y t h o n - c o m m o n " ;
2023-04-12 12:48:02 +00:00
propagatedBuildInputs = [
pyyaml
] ;
nativeCheckInputs = [
pytestCheckHook
] ;
disabledTests = [
# requires network access
" t e s t _ v a l i d _ a d d r "
] ;
2020-07-18 16:06:22 +00:00
meta = getMeta " C e p h c o m m o n m o d u l e f o r c o d e s h a r e d b y m a n a g e r m o d u l e s " ;
} ;
2023-04-12 12:48:02 +00:00
# Watch out for python <> boost compatibility
python = python310 . override {
2023-03-15 16:39:30 +00:00
packageOverrides = self : super : {
sqlalchemy = super . sqlalchemy . overridePythonAttrs ( oldAttrs : rec {
version = " 1 . 4 . 4 6 " ;
src = super . fetchPypi {
pname = " S Q L A l c h e m y " ;
inherit version ;
hash = " s h a 2 5 6 - a R O 4 J H 2 K K S 7 4 M V F i p R k x 4 r Q M 6 R a B 8 b b x j 2 l w R S A M S j A = " ;
} ;
nativeCheckInputs = oldAttrs . nativeCheckInputs ++ ( with super ; [
pytest-xdist
] ) ;
disabledTestPaths = ( oldAttrs . disabledTestPaths or [ ] ) ++ [
" t e s t / a a a _ p r o f i l i n g "
" t e s t / e x t / m y p y "
] ;
} ) ;
} ;
} ;
2022-06-26 10:26:21 +00:00
2023-04-12 12:48:02 +00:00
boost = boost179 . override {
2022-06-26 10:26:21 +00:00
enablePython = true ;
inherit python ;
} ;
2021-06-28 23:13:55 +00:00
2023-04-12 12:48:02 +00:00
# TODO: split this off in build and runtime environment
ceph-python-env = python . withPackages ( ps : with ps ; [
2020-07-18 16:06:22 +00:00
ceph-common
2023-04-12 12:48:02 +00:00
# build time
cython
# debian/control
bcrypt
cherrypy
influxdb
jinja2
kubernetes
natsort
numpy
pecan
prettytable
pyjwt
pyopenssl
python-dateutil
pyyaml
requests
routes
scikit-learn
scipy
setuptools
sphinx
virtualenv
werkzeug
# src/pybind/mgr/requirements-required.txt
cryptography
jsonpatch
# src/tools/cephfs/shell/setup.py
cmd2
colorama
2020-04-24 23:36:52 +00:00
] ) ;
2023-05-24 13:37:59 +00:00
inherit ( ceph-python-env . python ) sitePackages ;
2020-04-24 23:36:52 +00:00
2023-04-12 12:48:02 +00:00
version = " 1 7 . 2 . 5 " ;
2020-07-18 16:06:22 +00:00
src = fetchurl {
2023-05-24 13:37:59 +00:00
url = " h t t p s : / / d o w n l o a d . c e p h . c o m / t a r b a l l s / c e p h - ${ version } . t a r . g z " ;
2023-04-12 12:48:02 +00:00
hash = " s h a 2 5 6 - N i J p w U e R O v h 0 s i S a R o R r D m + C 0 s 6 1 C v R i I r b d 7 J m R s p o = " ;
2020-07-18 16:06:22 +00:00
} ;
2020-04-24 23:36:52 +00:00
in rec {
ceph = stdenv . mkDerivation {
pname = " c e p h " ;
2020-07-18 16:06:22 +00:00
inherit src version ;
2020-04-24 23:36:52 +00:00
nativeBuildInputs = [
cmake
2023-04-12 12:48:02 +00:00
fmt
git
makeWrapper
pkg-config
python
2021-06-28 23:13:55 +00:00
python . pkgs . python # for the toPythonPath function
2023-04-12 12:48:02 +00:00
python . pkgs . wrapPython
which
2020-04-24 23:36:52 +00:00
( ensureNewerSourcesHook { year = " 1 9 8 0 " ; } )
2021-04-22 02:08:21 +00:00
# for building docs/man-pages presumably
doxygen
graphviz
2020-04-24 23:36:52 +00:00
] ;
2023-04-12 12:48:02 +00:00
enableParallelBuilding = true ;
2020-04-24 23:36:52 +00:00
buildInputs = cryptoLibsMap . ${ cryptoStr } ++ [
2023-04-12 12:48:02 +00:00
arrow-cpp
babeltrace
boost
bzip2
ceph-python-env
cimg
cryptsetup
cunit
gperf
gtest
jsoncpp
icu
libcap_ng
libnl
libxml2
lttng-ust
lua
lz4
malloc
oath-toolkit
openldap
optLibatomic_ops
optLibs3
optYasm
rdkafka
rocksdb'
snappy
sqlite
utf8proc
zlib
zstd
2021-02-05 17:12:51 +00:00
] ++ lib . optionals stdenv . isLinux [
2023-04-12 12:48:02 +00:00
keyutils
liburing
libuuid
linuxHeaders
optLibaio
optLibxfs
optZfs
rabbitmq-c
rdma-core
udev
util-linux
2021-02-05 17:12:51 +00:00
] ++ lib . optionals hasRadosgw [
2023-04-12 12:48:02 +00:00
optCurl
optExpat
optFuse
optLibedit
2020-04-24 23:36:52 +00:00
] ;
pythonPath = [ ceph-python-env " ${ placeholder " o u t " } / ${ ceph-python-env . sitePackages } " ] ;
preConfigure = ''
substituteInPlace src/common/module.c - - replace " / s b i n / m o d i n f o " " m o d i n f o "
substituteInPlace src/common/module.c - - replace " / s b i n / m o d p r o b e " " m o d p r o b e "
2021-04-25 03:57:28 +00:00
substituteInPlace src/common/module.c - - replace " / b i n / g r e p " " g r e p "
2020-04-24 23:36:52 +00:00
# install target needs to be in PYTHONPATH for "*.pth support" check to succeed
# set PYTHONPATH, so the build system doesn't silently skip installing ceph-volume and others
export PYTHONPATH = $ { ceph-python-env } / $ { sitePackages }: $ lib / $ { sitePackages }: $ out / $ { sitePackages }
patchShebangs src/script src/spdk src/test src/tools
'' ;
cmakeFlags = [
" - D C M A K E _ I N S T A L L _ D A T A D I R = ${ placeholder " l i b " } / l i b "
" - D M G R _ P Y T H O N _ V E R S I O N = ${ ceph-python-env . python . pythonVersion } "
2023-04-12 12:48:02 +00:00
" - D W I T H _ C E P H F S _ S H E L L : B O O L = O N "
" - D W I T H _ S Y S T E M D : B O O L = O F F "
" - D W I T H _ T E S T S : B O O L = O F F "
# Use our own libraries, where possible
" - D W I T H _ S Y S T E M _ A R R O W : B O O L = O N "
" - D W I T H _ S Y S T E M _ B O O S T : B O O L = O N "
" - D W I T H _ S Y S T E M _ C I M G : B O O L = O N "
" - D W I T H _ S Y S T E M _ J S O N C P P : B O O L = O N "
" - D W I T H _ S Y S T E M _ G T E S T : B O O L = O N "
" - D W I T H _ S Y S T E M _ R O C K S D B : B O O L = O N "
" - D W I T H _ S Y S T E M _ U T F 8 P R O C : B O O L = O N "
" - D W I T H _ S Y S T E M _ Z S T D : B O O L = O N "
2020-04-24 23:36:52 +00:00
# TODO breaks with sandbox, tries to download stuff with npm
2023-04-12 12:48:02 +00:00
" - D W I T H _ M G R _ D A S H B O A R D _ F R O N T E N D : B O O L = O F F "
# no matching function for call to 'parquet::PageReader::Open(std::shared_ptr<arrow::io::InputStream>&, int64_t, arrow::Compression::type, parquet::MemoryPool*, parquet::CryptoContext*)'
" - D W I T H _ R A D O S G W _ S E L E C T _ P A R Q U E T : B O O L = O F F "
2021-04-22 02:08:21 +00:00
# WITH_XFS has been set default ON from Ceph 16, keeping it optional in nixpkgs for now
'' - D W I T H _ X F S = ${ if optLibxfs != null then " O N " else " O F F " } ''
2021-07-03 03:11:41 +00:00
] ++ lib . optional stdenv . isLinux " - D W I T H _ S Y S T E M _ L I B U R I N G = O N " ;
2020-04-24 23:36:52 +00:00
postFixup = ''
wrapPythonPrograms
wrapProgram $ out/bin/ceph-mgr - - prefix PYTHONPATH " : " " $ ( t o P y t h o n P a t h ${ placeholder " o u t " } ) : $ ( t o P y t h o n P a t h ${ ceph-python-env } ) "
# Test that ceph-volume exists since the build system has a tendency to
# silently drop it with misconfigurations.
test - f $ out/bin/ceph-volume
'' ;
outputs = [ " o u t " " l i b " " d e v " " d o c " " m a n " ] ;
doCheck = false ; # uses pip to install things from the internet
2021-04-26 19:14:03 +00:00
# Takes 7+h to build with 2 cores.
requiredSystemFeatures = [ " b i g - p a r a l l e l " ] ;
2020-07-18 16:06:22 +00:00
meta = getMeta " D i s t r i b u t e d s t o r a g e s y s t e m " ;
2020-04-24 23:36:52 +00:00
2023-04-12 12:48:02 +00:00
passthru = {
inherit version ;
tests = {
inherit ( nixosTests )
ceph-multi-node
ceph-single-node
ceph-single-node-bluestore ;
} ;
} ;
2020-04-24 23:36:52 +00:00
} ;
ceph-client = runCommand " c e p h - c l i e n t - ${ version } " {
2021-12-06 16:07:01 +00:00
meta = getMeta " T o o l s n e e d e d t o m o u n t C e p h ' s R A D O S B l o c k D e v i c e s / C e p h f s " ;
2020-04-24 23:36:52 +00:00
} ''
2020-11-21 19:51:51 +00:00
mkdir - p $ out / { bin , etc , ${ sitePackages } , share/bash-completion/completions }
2020-04-24 23:36:52 +00:00
cp - r $ { ceph } /bin / { ceph , . ceph-wrapped , rados , rbd , rbdmap } $ out/bin
cp - r $ { ceph } /bin/ceph- { authtool , conf , dencoder , rbdnamer , syn } $ out/bin
cp - r $ { ceph } /bin/rbd-replay * $ out/bin
2021-12-06 16:07:01 +00:00
cp - r $ { ceph } /sbin/mount.ceph $ out/bin
cp - r $ { ceph } /sbin/mount.fuse.ceph $ out/bin
ln - s bin $ out/sbin
cp - r $ { ceph } / $ { sitePackages } /* $ o u t / $ { s i t e P a c k a g e s }
2020-11-21 19:51:51 +00:00
cp - r $ { ceph } /etc/bash_completion.d $ out/share/bash-completion/completions
2020-04-24 23:36:52 +00:00
# wrapPythonPrograms modifies .ceph-wrapped, so lets just update its paths
substituteInPlace $ out/bin/ceph - - replace $ { ceph } $ out
substituteInPlace $ out/bin/.ceph-wrapped - - replace $ { ceph } $ out
'' ;
}