From 56d71be11e769402d8ca1b279373ff0707797e6c Mon Sep 17 00:00:00 2001 From: benaryorg Date: Fri, 24 Oct 2025 09:34:59 +0000 Subject: [PATCH] pkgs/ceph: client as output Moving the ceph client to a separate output allows moving the entire package to the by-name structure more easily. Signed-off-by: benaryorg --- pkgs/tools/filesystems/ceph/default.nix | 478 ++++++++++++------------ pkgs/top-level/all-packages.nix | 6 +- 2 files changed, 237 insertions(+), 247 deletions(-) diff --git a/pkgs/tools/filesystems/ceph/default.nix b/pkgs/tools/filesystems/ceph/default.nix index 1aea3ea3b5ff..a468bc88985d 100644 --- a/pkgs/tools/filesystems/ceph/default.nix +++ b/pkgs/tools/filesystems/ceph/default.nix @@ -373,262 +373,254 @@ let hash = "sha256-zlgp28C81SZbaFJ4yvQk4ZgYz4K/aZqtcISTO8LscSU="; }; in -rec { - ceph = stdenv.mkDerivation { - pname = "ceph"; - inherit src version; +stdenv.mkDerivation rec { + pname = "ceph"; + inherit src version; - patches = [ - ./boost-1.85.patch + patches = [ + ./boost-1.85.patch - (fetchpatch2 { - name = "ceph-boost-1.86-uuid.patch"; - url = "https://github.com/ceph/ceph/commit/01306208eac492ee0e67bff143fc32d0551a2a6f.patch?full_index=1"; - hash = "sha256-OnDrr72inzGXXYxPFQevsRZImSvI0uuqFHqtFU2dPQE="; - }) + (fetchpatch2 { + name = "ceph-boost-1.86-uuid.patch"; + url = "https://github.com/ceph/ceph/commit/01306208eac492ee0e67bff143fc32d0551a2a6f.patch?full_index=1"; + hash = "sha256-OnDrr72inzGXXYxPFQevsRZImSvI0uuqFHqtFU2dPQE="; + }) - # See: - # * - # * - # * - ./boost-1.86-PyModule.patch + # See: + # * + # * + # * + ./boost-1.86-PyModule.patch - (fetchpatch2 { - name = "ceph-cmake-4.patch"; - url = "https://gitlab.alpinelinux.org/ashpool/aports/-/raw/d22b70eafe33c3daabe4eea6913c5be87d9463ad/community/ceph19/cpp_redis.patch"; - hash = "sha256-wxPIsYt25CjXhJ6kmr/MXwFD58Sl4y4W+r9jAMND+uw="; - }) - ]; + (fetchpatch2 { + name = "ceph-cmake-4.patch"; + url = "https://gitlab.alpinelinux.org/ashpool/aports/-/raw/d22b70eafe33c3daabe4eea6913c5be87d9463ad/community/ceph19/cpp_redis.patch"; + hash = "sha256-wxPIsYt25CjXhJ6kmr/MXwFD58Sl4y4W+r9jAMND+uw="; + }) + ]; - nativeBuildInputs = [ - autoconf # `autoreconf` is called, e.g. for `qatlib_ext` - automake # `aclocal` is called, e.g. for `qatlib_ext` - cmake - fmt_9 - git - makeWrapper - libtool # used e.g. for `qatlib_ext` - nasm - pkg-config - python - python.pkgs.python # for the toPythonPath function - python.pkgs.wrapPython - which - (ensureNewerSourcesHook { year = "1980"; }) - # for building docs/man-pages presumably - doxygen - graphviz - ]; + nativeBuildInputs = [ + autoconf # `autoreconf` is called, e.g. for `qatlib_ext` + automake # `aclocal` is called, e.g. for `qatlib_ext` + cmake + fmt_9 + git + makeWrapper + libtool # used e.g. for `qatlib_ext` + nasm + pkg-config + python + python.pkgs.python # for the toPythonPath function + python.pkgs.wrapPython + which + (ensureNewerSourcesHook { year = "1980"; }) + # for building docs/man-pages presumably + doxygen + graphviz + ]; - buildInputs = - cryptoLibsMap.${cryptoStr} - ++ [ - ceph-arrow-cpp - babeltrace - boost' - bzip2 - # Adding `ceph-python-env` here adds the env's `site-packages` to `PYTHONPATH` during the build. - # This is important, otherwise the build system may not find the Python deps and then - # silently skip installing ceph-volume and other Ceph python tools. - ceph-python-env - cryptsetup - cunit - e2fsprogs # according to `debian/control` file, `ceph-volume` is supposed to use it - gperf - gtest - icu - libcap - libnbd - libnl - libxml2 - lmdb - lttng-ust - lua5_4 - lvm2 # according to `debian/control` file, e.g. `pvs` command used by `src/ceph-volume/ceph_volume/api/lvm.py` - lz4 - malloc - oath-toolkit - openldap - optLibatomic_ops - optLibs3 - optYasm - parted # according to `debian/control` file, used by `src/ceph-volume/ceph_volume/util/disk.py` - rdkafka - rocksdb' - snappy - openssh # according to `debian/control` file, `ssh` command used by `cephadm` - sqlite - utf8proc - xfsprogs # according to `debian/control` file, `ceph-volume` is supposed to use it - zlib - zstd - ] - ++ lib.optionals stdenv.hostPlatform.isLinux [ - keyutils - libcap_ng - liburing - libuuid - linuxHeaders - optLibaio - optLibxfs - optZfs - rabbitmq-c - rdma-core - udev - util-linux - ] - ++ lib.optionals hasRadosgw [ - optCurl - optExpat - optFuse - optLibedit - ]; - - # Picked up, amongst others, by `wrapPythonPrograms`. - pythonPath = [ + buildInputs = + cryptoLibsMap.${cryptoStr} + ++ [ + ceph-arrow-cpp + babeltrace + boost' + bzip2 + # Adding `ceph-python-env` here adds the env's `site-packages` to `PYTHONPATH` during the build. + # This is important, otherwise the build system may not find the Python deps and then + # silently skip installing ceph-volume and other Ceph python tools. ceph-python-env - "${placeholder "out"}/${ceph-python-env.sitePackages}" - ]; - - # * `unset AS` because otherwise the Ceph CMake build errors with - # configure: error: No modern nasm or yasm found as required. Nasm should be v2.11.01 or later (v2.13 for AVX512) and yasm should be 1.2.0 or later. - # because the code at - # https://github.com/intel/isa-l/blob/633add1b569fe927bace3960d7c84ed9c1b38bb9/configure.ac#L99-L191 - # doesn't even consider using `nasm` or `yasm` but instead uses `$AS` - # from `gcc-wrapper`. - # (Ceph's error message is extra confusing, because it says - # `No modern nasm or yasm found` when in fact it found e.g. `nasm` - # but then uses `$AS` instead. - # * replace /sbin and /bin based paths with direct nix store paths - # * increase the `command` buffer size since 2 nix store paths cannot fit within 128 characters - preConfigure = '' - unset AS - - substituteInPlace src/common/module.c \ - --replace "char command[128];" "char command[256];" \ - --replace "/sbin/modinfo" "${kmod}/bin/modinfo" \ - --replace "/sbin/modprobe" "${kmod}/bin/modprobe" \ - --replace "/bin/grep" "${gnugrep}/bin/grep" - - # Patch remount to use full path to mount(8), otherwise ceph-fuse fails when run - # from a systemd unit for example. - substituteInPlace src/client/fuse_ll.cc \ - --replace-fail "mount -i -o remount" "${util-linux}/bin/mount -i -o remount" - - # The install target needs to be in PYTHONPATH for "*.pth support" check to succeed - export PYTHONPATH=$PYTHONPATH:$lib/${sitePackages}:$out/${sitePackages} - patchShebangs src/ - ''; - - cmakeFlags = [ - "-DCMAKE_INSTALL_DATADIR=${placeholder "lib"}/lib" - - "-DWITH_CEPHFS_SHELL:BOOL=ON" - "-DWITH_SYSTEMD:BOOL=OFF" - # `WITH_JAEGER` requires `thrift` as a depenedncy (fine), but the build fails with: - # CMake Error at src/opentelemetry-cpp-stamp/opentelemetry-cpp-build-Release.cmake:49 (message): - # Command failed: 2 - # - # 'make' 'opentelemetry_trace' 'opentelemetry_exporter_jaeger_trace' - # - # See also - # - # /build/ceph-18.2.0/build/src/opentelemetry-cpp/src/opentelemetry-cpp-stamp/opentelemetry-cpp-build-*.log - # and that file contains: - # /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()': - # /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'? - # 71 | ::THRIFT_CLOSESOCKET(socket_); - # | ^~~~~~~~~~~~~~~~~~ - # Looks like `close()` is somehow not included. - # But the relevant code is already removed in `open-telemetry` 1.10: https://github.com/open-telemetry/opentelemetry-cpp/pull/2031 - # So it's probably not worth trying to fix that for this Ceph version, - # and instead just disable Ceph's Jaeger support. - "-DWITH_JAEGER:BOOL=OFF" - "-DWITH_TESTS:BOOL=OFF" - - # Use our own libraries, where possible - "-DWITH_SYSTEM_ARROW:BOOL=ON" # Only used if other options enable Arrow support. - "-DWITH_SYSTEM_BOOST:BOOL=ON" - "-DWITH_SYSTEM_GTEST:BOOL=ON" - "-DWITH_SYSTEM_ROCKSDB:BOOL=ON" - "-DWITH_SYSTEM_UTF8PROC:BOOL=ON" - "-DWITH_SYSTEM_ZSTD:BOOL=ON" - - # Use our own python libraries too, see: - # https://github.com/NixOS/nixpkgs/pull/344993#issuecomment-2391046329 - "-DCEPHADM_BUNDLED_DEPENDENCIES=none" - - # TODO breaks with sandbox, tries to download stuff with npm - "-DWITH_MGR_DASHBOARD_FRONTEND:BOOL=OFF" - # WITH_XFS has been set default ON from Ceph 16, keeping it optional in nixpkgs for now - ''-DWITH_XFS=${if optLibxfs != null then "ON" else "OFF"}'' + cryptsetup + cunit + e2fsprogs # according to `debian/control` file, `ceph-volume` is supposed to use it + gperf + gtest + icu + libcap + libnbd + libnl + libxml2 + lmdb + lttng-ust + lua5_4 + lvm2 # according to `debian/control` file, e.g. `pvs` command used by `src/ceph-volume/ceph_volume/api/lvm.py` + lz4 + malloc + oath-toolkit + openldap + optLibatomic_ops + optLibs3 + optYasm + parted # according to `debian/control` file, used by `src/ceph-volume/ceph_volume/util/disk.py` + rdkafka + rocksdb' + snappy + openssh # according to `debian/control` file, `ssh` command used by `cephadm` + sqlite + utf8proc + xfsprogs # according to `debian/control` file, `ceph-volume` is supposed to use it + zlib + zstd ] - ++ lib.optional stdenv.hostPlatform.isLinux "-DWITH_SYSTEM_LIBURING=ON"; - - preBuild = - # The legacy-option-headers target is not correctly empbedded in the build graph. - # It also contains some internal race conditions that we work around by building with `-j 1`. - # Upstream discussion for additional context at https://tracker.ceph.com/issues/63402. - '' - cmake --build . --target legacy-option-headers -j 1 - ''; - - postFixup = '' - wrapPythonPrograms - wrapProgram $out/bin/ceph-mgr --prefix PYTHONPATH ":" "$(toPythonPath ${placeholder "out"}):$(toPythonPath ${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 = [ - "out" - "lib" - "dev" - "doc" - "man" + ++ lib.optionals stdenv.hostPlatform.isLinux [ + keyutils + libcap_ng + liburing + libuuid + linuxHeaders + optLibaio + optLibxfs + optZfs + rabbitmq-c + rdma-core + udev + util-linux + ] + ++ lib.optionals hasRadosgw [ + optCurl + optExpat + optFuse + optLibedit ]; - doCheck = false; # uses pip to install things from the internet + # Picked up, amongst others, by `wrapPythonPrograms`. + pythonPath = [ + ceph-python-env + "${placeholder "out"}/${ceph-python-env.sitePackages}" + ]; - # Takes 7+h to build with 2 cores. - requiredSystemFeatures = [ "big-parallel" ]; + # * `unset AS` because otherwise the Ceph CMake build errors with + # configure: error: No modern nasm or yasm found as required. Nasm should be v2.11.01 or later (v2.13 for AVX512) and yasm should be 1.2.0 or later. + # because the code at + # https://github.com/intel/isa-l/blob/633add1b569fe927bace3960d7c84ed9c1b38bb9/configure.ac#L99-L191 + # doesn't even consider using `nasm` or `yasm` but instead uses `$AS` + # from `gcc-wrapper`. + # (Ceph's error message is extra confusing, because it says + # `No modern nasm or yasm found` when in fact it found e.g. `nasm` + # but then uses `$AS` instead. + # * replace /sbin and /bin based paths with direct nix store paths + # * increase the `command` buffer size since 2 nix store paths cannot fit within 128 characters + preConfigure = '' + unset AS - meta = getMeta "Distributed storage system"; + substituteInPlace src/common/module.c \ + --replace "char command[128];" "char command[256];" \ + --replace "/sbin/modinfo" "${kmod}/bin/modinfo" \ + --replace "/sbin/modprobe" "${kmod}/bin/modprobe" \ + --replace "/bin/grep" "${gnugrep}/bin/grep" - passthru = { - inherit version; - inherit python; # to be able to test our overridden packages above individually with `nix-build -A` - arrow-cpp = ceph-arrow-cpp; - tests = { - inherit (nixosTests) - ceph-multi-node - ceph-single-node - ceph-single-node-bluestore - ceph-single-node-bluestore-dmcrypt - ; - }; + # Patch remount to use full path to mount(8), otherwise ceph-fuse fails when run + # from a systemd unit for example. + substituteInPlace src/client/fuse_ll.cc \ + --replace-fail "mount -i -o remount" "${util-linux}/bin/mount -i -o remount" + + # The install target needs to be in PYTHONPATH for "*.pth support" check to succeed + export PYTHONPATH=$PYTHONPATH:$lib/${sitePackages}:$out/${sitePackages} + patchShebangs src/ + ''; + + cmakeFlags = [ + "-DCMAKE_INSTALL_DATADIR=${placeholder "lib"}/lib" + + "-DWITH_CEPHFS_SHELL:BOOL=ON" + "-DWITH_SYSTEMD:BOOL=OFF" + # `WITH_JAEGER` requires `thrift` as a depenedncy (fine), but the build fails with: + # CMake Error at src/opentelemetry-cpp-stamp/opentelemetry-cpp-build-Release.cmake:49 (message): + # Command failed: 2 + # + # 'make' 'opentelemetry_trace' 'opentelemetry_exporter_jaeger_trace' + # + # See also + # + # /build/ceph-18.2.0/build/src/opentelemetry-cpp/src/opentelemetry-cpp-stamp/opentelemetry-cpp-build-*.log + # and that file contains: + # /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()': + # /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'? + # 71 | ::THRIFT_CLOSESOCKET(socket_); + # | ^~~~~~~~~~~~~~~~~~ + # Looks like `close()` is somehow not included. + # But the relevant code is already removed in `open-telemetry` 1.10: https://github.com/open-telemetry/opentelemetry-cpp/pull/2031 + # So it's probably not worth trying to fix that for this Ceph version, + # and instead just disable Ceph's Jaeger support. + "-DWITH_JAEGER:BOOL=OFF" + "-DWITH_TESTS:BOOL=OFF" + + # Use our own libraries, where possible + "-DWITH_SYSTEM_ARROW:BOOL=ON" # Only used if other options enable Arrow support. + "-DWITH_SYSTEM_BOOST:BOOL=ON" + "-DWITH_SYSTEM_GTEST:BOOL=ON" + "-DWITH_SYSTEM_ROCKSDB:BOOL=ON" + "-DWITH_SYSTEM_UTF8PROC:BOOL=ON" + "-DWITH_SYSTEM_ZSTD:BOOL=ON" + + # Use our own python libraries too, see: + # https://github.com/NixOS/nixpkgs/pull/344993#issuecomment-2391046329 + "-DCEPHADM_BUNDLED_DEPENDENCIES=none" + + # TODO breaks with sandbox, tries to download stuff with npm + "-DWITH_MGR_DASHBOARD_FRONTEND:BOOL=OFF" + # WITH_XFS has been set default ON from Ceph 16, keeping it optional in nixpkgs for now + ''-DWITH_XFS=${if optLibxfs != null then "ON" else "OFF"}'' + ] + ++ lib.optional stdenv.hostPlatform.isLinux "-DWITH_SYSTEM_LIBURING=ON"; + + preBuild = + # The legacy-option-headers target is not correctly empbedded in the build graph. + # It also contains some internal race conditions that we work around by building with `-j 1`. + # Upstream discussion for additional context at https://tracker.ceph.com/issues/63402. + '' + cmake --build . --target legacy-option-headers -j 1 + ''; + + postFixup = '' + wrapPythonPrograms + wrapProgram $out/bin/ceph-mgr --prefix PYTHONPATH ":" "$(toPythonPath ${placeholder "out"}):$(toPythonPath ${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 + + mkdir -p $client/{bin,etc,${sitePackages},share/bash-completion/completions} + cp -r $out/bin/{ceph,.ceph-wrapped,rados,rbd,rbdmap} $client/bin + cp -r $out/bin/ceph-{authtool,conf,dencoder,rbdnamer,syn} $client/bin + cp -r $out/bin/rbd-replay* $client/bin + cp -r $out/sbin/mount.ceph $client/bin + cp -r $out/sbin/mount.fuse.ceph $client/bin + ln -s bin $client/sbin + cp -r $out/${sitePackages}/* $client/${sitePackages} + cp -r $out/etc/bash_completion.d $client/share/bash-completion/completions + # wrapPythonPrograms modifies .ceph-wrapped, so lets just update its paths + substituteInPlace $client/bin/ceph --replace $out $client + substituteInPlace $client/bin/.ceph-wrapped --replace $out $client + ''; + + outputs = [ + "out" + "lib" + "client" + "dev" + "doc" + "man" + ]; + + doCheck = false; # uses pip to install things from the internet + + # Takes 7+h to build with 2 cores. + requiredSystemFeatures = [ "big-parallel" ]; + + meta = getMeta "Distributed storage system"; + + passthru = { + inherit version; + inherit python; # to be able to test our overridden packages above individually with `nix-build -A` + arrow-cpp = ceph-arrow-cpp; + tests = { + inherit (nixosTests) + ceph-multi-node + ceph-single-node + ceph-single-node-bluestore + ceph-single-node-bluestore-dmcrypt + ; }; }; - - ceph-client = - runCommand "ceph-client-${version}" - { - meta = getMeta "Tools needed to mount Ceph's RADOS Block Devices/Cephfs"; - } - '' - mkdir -p $out/{bin,etc,${sitePackages},share/bash-completion/completions} - 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 - 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}/* $out/${sitePackages} - cp -r ${ceph}/etc/bash_completion.d $out/share/bash-completion/completions - # 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 - ''; } diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 6409aa7e6003..3c053a094c79 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -2345,11 +2345,9 @@ with pkgs; cemu-ti = qt5.callPackage ../applications/science/math/cemu-ti { }; + ceph = callPackage ../tools/filesystems/ceph { }; libceph = ceph.lib; - inherit (callPackages ../tools/filesystems/ceph { }) - ceph - ceph-client - ; + ceph-client = ceph.client; ceph-dev = ceph; clementine = libsForQt5.callPackage ../applications/audio/clementine {