14 ensureNewerSourcesHook,
26 # Runtime dependencies
29 boost182, # using the version installed by ceph's `install-deps.sh`
53 python311, # to get an idea which Python versions are supported by Ceph, see upstream `do_cmake.sh` (see `PYBUILD=` variable)
64 # Dependencies of overridden Python dependencies, hopefully we can remove these soon.
67 # Optional Dependencies
85 # Linux Only Dependencies
100 # We must have one crypto library
101 assert cryptopp != null || (nss != null && nspr != null);
105 pkg: if pkg != null && lib.meta.availableOn stdenv.hostPlatform pkg then pkg else null;
107 optYasm = shouldUsePkg yasm;
108 optExpat = shouldUsePkg expat;
109 optCurl = shouldUsePkg curl;
110 optFuse = shouldUsePkg fuse;
111 optLibedit = shouldUsePkg libedit;
112 optLibatomic_ops = shouldUsePkg libatomic_ops;
113 optLibs3 = shouldUsePkg libs3;
115 optJemalloc = shouldUsePkg jemalloc;
116 optGperftools = shouldUsePkg gperftools;
118 optCryptopp = shouldUsePkg cryptopp;
119 optNss = shouldUsePkg nss;
120 optNspr = shouldUsePkg nspr;
122 optLibaio = shouldUsePkg libaio;
123 optLibxfs = shouldUsePkg libxfs;
124 optZfs = shouldUsePkg zfs;
126 # Downgrade rocksdb, 7.10 breaks ceph
127 rocksdb' = rocksdb.overrideAttrs {
129 src = fetchFromGitHub {
132 rev = "refs/tags/v7.9.2";
133 hash = "sha256-5P7IqJ14EZzDkbjaBvbix04ceGGdlWBuVFH/5dpD5VM=";
137 hasRadosgw = optExpat != null && optCurl != null && optLibedit != null;
139 # Malloc implementation (can be jemalloc, tcmalloc or null)
140 malloc = if optJemalloc != null then optJemalloc else optGperftools;
142 # We prefer nss over cryptopp
144 if optNss != null && optNspr != null then
146 else if optCryptopp != null then
156 cryptopp = [ optCryptopp ];
160 getMeta = description: {
161 homepage = "https://ceph.io/en/";
163 license = with lib.licenses; [
170 maintainers = with lib.maintainers; [
186 pname = "ceph-common";
189 sourceRoot = "ceph-${version}/src/python-common";
191 propagatedBuildInputs = [
195 nativeCheckInputs = [
200 # requires network access
204 meta = getMeta "Ceph common module for code shared by manager modules";
207 # Watch out for python <> boost compatibility
208 python = python311.override {
213 bcryptOverrideVersion = "4.0.1";
216 # Ceph does not support the following yet:
218 # * `cryptography` > 40
220 # * https://github.com/NixOS/nixpkgs/pull/281858#issuecomment-1899358602
221 # * Upstream issue: https://tracker.ceph.com/issues/63529
222 # > Python Sub-Interpreter Model Used by ceph-mgr Incompatible With Python Modules Based on PyO3
223 # * Moved to issue: https://tracker.ceph.com/issues/64213
224 # > MGR modules incompatible with later PyO3 versions - PyO3 modules may only be initialized once per interpreter process
226 bcrypt = super.bcrypt.overridePythonAttrs (old: rec {
228 version = bcryptOverrideVersion;
230 inherit pname version;
231 hash = "sha256-J9N1kDrIJhz+QEf2cJ0W99GNObHskqr3KvmJVSplDr0=";
233 cargoRoot = "src/_bcrypt";
234 cargoDeps = rustPlatform.fetchCargoTarball {
236 sourceRoot = "${pname}-${version}/${cargoRoot}";
237 name = "${pname}-${version}";
238 hash = "sha256-lDWX69YENZFMu7pyBmavUZaalGvFqbHSHfkwkzmDQaY=";
242 # We pin the older `cryptography` 40 here;
243 # this also forces us to pin other packages, see below
244 cryptography = self.callPackage ./old-python-packages/cryptography.nix { };
246 # This is the most recent version of `pyopenssl` that's still compatible with `cryptography` 40.
247 # See https://github.com/NixOS/nixpkgs/pull/281858#issuecomment-1899358602
248 # and https://github.com/pyca/pyopenssl/blob/d9752e44127ba36041b045417af8a0bf16ec4f1e/CHANGELOG.rst#2320-2023-05-30
249 pyopenssl = super.pyopenssl.overridePythonAttrs (old: rec {
254 hash = "sha256-hBSYub7GFiOxtsR+u8AjZ8B9YODhlfGXkIF/EMyNsLc=";
256 disabledTests = old.disabledTests or [ ] ++ [
257 "test_export_md5_digest"
259 propagatedBuildInputs = old.propagatedBuildInputs or [ ] ++ [
264 # This is the most recent version of `trustme` that's still compatible with `cryptography` 40.
265 # See https://github.com/NixOS/nixpkgs/issues/359723
266 # and https://github.com/python-trio/trustme/commit/586f7759d5c27beb44da60615a71848eb2a5a490
267 trustme = self.callPackage ./old-python-packages/trustme.nix { };
269 fastapi = super.fastapi.overridePythonAttrs (old: {
271 # ResourceWarning: Unclosed <MemoryObjectSendStream>
272 # Unclear whether it's flaky in general or only in this overridden package set.
276 # Ceph does not support `kubernetes` >= 19, see:
277 # https://github.com/NixOS/nixpkgs/pull/281858#issuecomment-1900324090
278 kubernetes = super.kubernetes.overridePythonAttrs (old: rec {
280 src = fetchFromGitHub {
281 owner = "kubernetes-client";
284 sha256 = "1sawp62j7h0yksmg9jlv4ik9b9i1a1w9syywc9mv8x89wibf5ql1";
285 fetchSubmodules = true;
292 boost = boost182.override {
297 # TODO: split this off in build and runtime environment
298 ceph-python-env = python.withPackages (
328 # src/cephadm/zipapp-reqs.txt
331 # src/pybind/mgr/requirements-required.txt
335 # src/tools/cephfs/shell/setup.py
340 inherit (ceph-python-env.python) sitePackages;
344 url = "https://download.ceph.com/tarballs/ceph-${version}.tar.gz";
345 hash = "sha256-30vkW1j49hFIxyxzkssSKVSq0VqiwLfDtOb62xfxadM=";
349 ceph = stdenv.mkDerivation {
355 name = "ceph-s3select-arrow-18-compat.patch";
356 url = "https://github.com/ceph/s3select/commit/f333ec82e6e8a3f7eb9ba1041d1442b2c7cd0f05.patch";
357 hash = "sha256-21fi5tMIs/JmuhwPYMWtampv/aqAe+EoPAXZLJlOvgo=";
359 extraPrefix = "src/s3select/";
363 nativeBuildInputs = [
364 autoconf # `autoreconf` is called, e.g. for `qatlib_ext`
365 automake # `aclocal` is called, e.g. for `qatlib_ext`
370 libtool # used e.g. for `qatlib_ext`
374 python.pkgs.python # for the toPythonPath function
375 python.pkgs.wrapPython
377 (ensureNewerSourcesHook { year = "1980"; })
378 # for building docs/man-pages presumably
384 cryptoLibsMap.${cryptoStr}
390 # Adding `ceph-python-env` here adds the env's `site-packages` to `PYTHONPATH` during the build.
391 # This is important, otherwise the build system may not find the Python deps and then
392 # silently skip installing ceph-volume and other Ceph python tools.
396 e2fsprogs # according to `debian/control` file, `ceph-volume` is supposed to use it
406 lvm2 # according to `debian/control` file, e.g. `pvs` command used by `src/ceph-volume/ceph_volume/api/lvm.py`
414 parted # according to `debian/control` file, used by `src/ceph-volume/ceph_volume/util/disk.py`
418 openssh # according to `debian/control` file, `ssh` command used by `cephadm`
421 xfsprogs # according to `debian/control` file, `ceph-volume` is supposed to use it
425 ++ lib.optionals stdenv.hostPlatform.isLinux [
439 ++ lib.optionals hasRadosgw [
446 # Picked up, amongst others, by `wrapPythonPrograms`.
449 "${placeholder "out"}/${ceph-python-env.sitePackages}"
452 # replace /sbin and /bin based paths with direct nix store paths
453 # increase the `command` buffer size since 2 nix store paths cannot fit within 128 characters
455 substituteInPlace src/common/module.c \
456 --replace "char command[128];" "char command[256];" \
457 --replace "/sbin/modinfo" "${kmod}/bin/modinfo" \
458 --replace "/sbin/modprobe" "${kmod}/bin/modprobe" \
459 --replace "/bin/grep" "${gnugrep}/bin/grep"
461 # The install target needs to be in PYTHONPATH for "*.pth support" check to succeed
462 export PYTHONPATH=$PYTHONPATH:$lib/${sitePackages}:$out/${sitePackages}
467 "-DCMAKE_INSTALL_DATADIR=${placeholder "lib"}/lib"
469 "-DWITH_CEPHFS_SHELL:BOOL=ON"
470 "-DWITH_SYSTEMD:BOOL=OFF"
471 # `WITH_JAEGER` requires `thrift` as a depenedncy (fine), but the build fails with:
472 # CMake Error at src/opentelemetry-cpp-stamp/opentelemetry-cpp-build-Release.cmake:49 (message):
475 # 'make' 'opentelemetry_trace' 'opentelemetry_exporter_jaeger_trace'
479 # /build/ceph-18.2.0/build/src/opentelemetry-cpp/src/opentelemetry-cpp-stamp/opentelemetry-cpp-build-*.log
480 # and that file contains:
481 # /build/ceph-18.2.0/src/jaegertracing/opentelemetry-cpp/exporters/jaeger/src/TUDPTransport.cc: In member function 'virtual void opentelemetry::v1::exporter::jaeger::TUDPTransport::close()':
482 # /build/ceph-18.2.0/src/jaegertracing/opentelemetry-cpp/exporters/jaeger/src/TUDPTransport.cc:71:7: error: '::close' has not been declared; did you mean 'pclose'?
483 # 71 | ::THRIFT_CLOSESOCKET(socket_);
484 # | ^~~~~~~~~~~~~~~~~~
485 # Looks like `close()` is somehow not included.
486 # But the relevant code is already removed in `open-telemetry` 1.10: https://github.com/open-telemetry/opentelemetry-cpp/pull/2031
487 # So it's proably not worth trying to fix that for this Ceph version,
488 # and instead just disable Ceph's Jaeger support.
489 "-DWITH_JAEGER:BOOL=OFF"
490 "-DWITH_TESTS:BOOL=OFF"
492 # Use our own libraries, where possible
493 "-DWITH_SYSTEM_ARROW:BOOL=ON" # Only used if other options enable Arrow support.
494 "-DWITH_SYSTEM_BOOST:BOOL=ON"
495 "-DWITH_SYSTEM_GTEST:BOOL=ON"
496 "-DWITH_SYSTEM_ROCKSDB:BOOL=ON"
497 "-DWITH_SYSTEM_UTF8PROC:BOOL=ON"
498 "-DWITH_SYSTEM_ZSTD:BOOL=ON"
500 # Use our own python libraries too, see:
501 # https://github.com/NixOS/nixpkgs/pull/344993#issuecomment-2391046329
502 "-DCEPHADM_BUNDLED_DEPENDENCIES=none"
504 # TODO breaks with sandbox, tries to download stuff with npm
505 "-DWITH_MGR_DASHBOARD_FRONTEND:BOOL=OFF"
506 # WITH_XFS has been set default ON from Ceph 16, keeping it optional in nixpkgs for now
507 ''-DWITH_XFS=${if optLibxfs != null then "ON" else "OFF"}''
508 ] ++ lib.optional stdenv.hostPlatform.isLinux "-DWITH_SYSTEM_LIBURING=ON";
511 # The legacy-option-headers target is not correctly empbedded in the build graph.
512 # It also contains some internal race conditions that we work around by building with `-j 1`.
513 # Upstream discussion for additional context at https://tracker.ceph.com/issues/63402.
515 cmake --build . --target legacy-option-headers -j 1
520 wrapProgram $out/bin/ceph-mgr --prefix PYTHONPATH ":" "$(toPythonPath ${placeholder "out"}):$(toPythonPath ${ceph-python-env})"
522 # Test that ceph-volume exists since the build system has a tendency to
523 # silently drop it with misconfigurations.
524 test -f $out/bin/ceph-volume
535 doCheck = false; # uses pip to install things from the internet
537 # Takes 7+h to build with 2 cores.
538 requiredSystemFeatures = [ "big-parallel" ];
540 meta = getMeta "Distributed storage system";
544 inherit python; # to be able to test our overridden packages above individually with `nix-build -A`
549 ceph-single-node-bluestore
550 ceph-single-node-bluestore-dmcrypt
557 runCommand "ceph-client-${version}"
559 meta = getMeta "Tools needed to mount Ceph's RADOS Block Devices/Cephfs";
562 mkdir -p $out/{bin,etc,${sitePackages},share/bash-completion/completions}
563 cp -r ${ceph}/bin/{ceph,.ceph-wrapped,rados,rbd,rbdmap} $out/bin
564 cp -r ${ceph}/bin/ceph-{authtool,conf,dencoder,rbdnamer,syn} $out/bin
565 cp -r ${ceph}/bin/rbd-replay* $out/bin
566 cp -r ${ceph}/sbin/mount.ceph $out/bin
567 cp -r ${ceph}/sbin/mount.fuse.ceph $out/bin
569 cp -r ${ceph}/${sitePackages}/* $out/${sitePackages}
570 cp -r ${ceph}/etc/bash_completion.d $out/share/bash-completion/completions
571 # wrapPythonPrograms modifies .ceph-wrapped, so lets just update its paths
572 substituteInPlace $out/bin/ceph --replace ${ceph} $out
573 substituteInPlace $out/bin/.ceph-wrapped --replace ${ceph} $out