From c4ac0aeb7036cbd89d4e7bb77d6fb916716d3e1b Mon Sep 17 00:00:00 2001 From: Jonas Heinrich Date: Mon, 7 Apr 2025 13:29:22 +0200 Subject: [PATCH 1/2] python3Packages.foundationdb: init 7.3.42 --- .../python-modules/foundationdb/default.nix | 27 +++++++++++++++++++ pkgs/top-level/python-packages.nix | 4 +-- 2 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 pkgs/development/python-modules/foundationdb/default.nix diff --git a/pkgs/development/python-modules/foundationdb/default.nix b/pkgs/development/python-modules/foundationdb/default.nix new file mode 100644 index 000000000000..56d0b7eb9e02 --- /dev/null +++ b/pkgs/development/python-modules/foundationdb/default.nix @@ -0,0 +1,27 @@ +{ + buildPythonPackage, + lib, + foundationdb, +}: + +buildPythonPackage { + pname = "foundationdb"; + version = foundationdb.version; + + src = foundationdb.pythonsrc; + unpackCmd = "tar xf $curSrc"; + + patchPhase = '' + substituteInPlace ./fdb/impl.py \ + --replace libfdb_c.so "${foundationdb.lib}/lib/libfdb_c.so" + ''; + + doCheck = false; + + meta = { + description = "Python bindings for FoundationDB"; + homepage = "https://www.foundationdb.org"; + license = with lib.licenses; [ asl20 ]; + maintainers = with lib.maintainers; [ thoughtpolice ]; + }; +} diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index adb6667984aa..c35cf987efd7 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -5166,8 +5166,8 @@ self: super: with self; { fortiosapi = callPackage ../development/python-modules/fortiosapi { }; - foundationdb73 = callPackage ../servers/foundationdb/python.nix { - foundationdb = pkgs.foundationdb73; + foundationdb = callPackage ../development/python-modules/foundationdb { + inherit (pkgs) foundationdb; }; fountains = callPackage ../development/python-modules/fountains { }; From 17d089705092345a8eed561aad879d3f907293b4 Mon Sep 17 00:00:00 2001 From: Jonas Heinrich Date: Mon, 7 Apr 2025 13:29:40 +0200 Subject: [PATCH 2/2] foundationdb: move to pkgs/by-name --- .../fo/foundationdb}/disable-flowbench.patch | 0 .../don-t-use-static-boost-libs.patch | 0 pkgs/by-name/fo/foundationdb/package.nix | 175 +++++++++++++++++ pkgs/servers/foundationdb/cmake.nix | 178 ------------------ pkgs/servers/foundationdb/default.nix | 49 ----- pkgs/servers/foundationdb/python.nix | 27 --- pkgs/top-level/all-packages.nix | 8 - pkgs/top-level/packages-config.nix | 1 - 8 files changed, 175 insertions(+), 263 deletions(-) rename pkgs/{servers/foundationdb/patches => by-name/fo/foundationdb}/disable-flowbench.patch (100%) rename pkgs/{servers/foundationdb/patches => by-name/fo/foundationdb}/don-t-use-static-boost-libs.patch (100%) create mode 100644 pkgs/by-name/fo/foundationdb/package.nix delete mode 100644 pkgs/servers/foundationdb/cmake.nix delete mode 100644 pkgs/servers/foundationdb/default.nix delete mode 100644 pkgs/servers/foundationdb/python.nix diff --git a/pkgs/servers/foundationdb/patches/disable-flowbench.patch b/pkgs/by-name/fo/foundationdb/disable-flowbench.patch similarity index 100% rename from pkgs/servers/foundationdb/patches/disable-flowbench.patch rename to pkgs/by-name/fo/foundationdb/disable-flowbench.patch diff --git a/pkgs/servers/foundationdb/patches/don-t-use-static-boost-libs.patch b/pkgs/by-name/fo/foundationdb/don-t-use-static-boost-libs.patch similarity index 100% rename from pkgs/servers/foundationdb/patches/don-t-use-static-boost-libs.patch rename to pkgs/by-name/fo/foundationdb/don-t-use-static-boost-libs.patch diff --git a/pkgs/by-name/fo/foundationdb/package.nix b/pkgs/by-name/fo/foundationdb/package.nix new file mode 100644 index 000000000000..06fb2e1d85f0 --- /dev/null +++ b/pkgs/by-name/fo/foundationdb/package.nix @@ -0,0 +1,175 @@ +{ + stdenv, + fetchFromGitHub, + lib, + fetchpatch, + cmake, + ninja, + python3, + openjdk, + mono, + openssl, + boost186, + pkg-config, + msgpack-cxx, + toml11, + jemalloc, + doctest, +}: +let + boost = boost186; + # Only even numbered versions compile on aarch64; odd numbered versions have avx enabled. + avxEnabled = + version: + let + isOdd = n: lib.trivial.mod n 2 != 0; + patch = lib.toInt (lib.versions.patch version); + in + isOdd patch; +in +stdenv.mkDerivation rec { + name = "foundationdb"; + version = "7.3.42"; + + src = fetchFromGitHub { + owner = "apple"; + repo = "foundationdb"; + tag = version; + hash = "sha256-jQcm+HLai5da2pZZ7iLdN6fpQZxf5+/kkfv9OSXQ57c="; + }; + + patches = [ + ./disable-flowbench.patch + ./don-t-use-static-boost-libs.patch + # GetMsgpack: add 4+ versions of upstream + # https://github.com/apple/foundationdb/pull/10935 + (fetchpatch { + url = "https://github.com/apple/foundationdb/commit/c35a23d3f6b65698c3b888d76de2d93a725bff9c.patch"; + hash = "sha256-bneRoZvCzJp0Hp/G0SzAyUyuDrWErSpzv+ickZQJR5w="; + }) + # Add a dependency that prevents bindingtester to run before the python bindings are generated + # https://github.com/apple/foundationdb/pull/11859 + (fetchpatch { + url = "https://github.com/apple/foundationdb/commit/8d04c97a74c6b83dd8aa6ff5af67587044c2a572.patch"; + hash = "sha256-ZLIcmcfirm1+96DtTIr53HfM5z38uTLZrRNHAmZL6rc="; + }) + ]; + + hardeningDisable = [ "fortify" ]; + + postPatch = '' + # allow using any msgpack-cxx version + substituteInPlace cmake/GetMsgpack.cmake \ + --replace-warn 'find_package(msgpack-cxx 6 QUIET CONFIG)' 'find_package(msgpack-cxx QUIET CONFIG)' + + # Use our doctest package + substituteInPlace bindings/c/test/unit/third_party/CMakeLists.txt \ + --replace-fail '/opt/doctest_proj_2.4.8' '${doctest}/include' + + # Upstream upgraded to Boost 1.86 with no code changes; see: + # + substituteInPlace cmake/CompileBoost.cmake \ + --replace-fail 'find_package(Boost 1.78.0 EXACT ' 'find_package(Boost ' + ''; + + buildInputs = [ + boost + jemalloc + msgpack-cxx + openssl + toml11 + ]; + + checkInputs = [ doctest ]; + + nativeBuildInputs = [ + cmake + mono + ninja + openjdk + pkg-config + python3 + ]; + + separateDebugInfo = true; + dontFixCmake = true; + + cmakeFlags = [ + "-DFDB_RELEASE=TRUE" + + # Disable CMake warnings for project developers. + "-Wno-dev" + + # CMake Error at fdbserver/CMakeLists.txt:332 (find_library): + # > Could not find lz4_STATIC_LIBRARIES using the following names: liblz4.a + "-DSSD_ROCKSDB_EXPERIMENTAL=FALSE" + + "-DBUILD_DOCUMENTATION=FALSE" + + # LTO brings up overall build time, but results in much smaller + # binaries for all users and the cache. + "-DUSE_LTO=ON" + + # Gold helps alleviate the link time, especially when LTO is + # enabled. But even then, it still takes a majority of the time. + "-DUSE_LD=GOLD" + + # FIXME: why can't openssl be found automatically? + "-DOPENSSL_USE_STATIC_LIBS=FALSE" + "-DOPENSSL_CRYPTO_LIBRARY=${openssl.out}/lib/libcrypto.so" + "-DOPENSSL_SSL_LIBRARY=${openssl.out}/lib/libssl.so" + ]; + + # the install phase for cmake is pretty wonky right now since it's not designed to + # coherently install packages as most linux distros expect -- it's designed to build + # packaged artifacts that are shipped in RPMs, etc. we need to add some extra code to + # cmake upstream to fix this, and if we do, i think most of this can go away. + postInstall = '' + mv $out/sbin/fdbmonitor $out/bin/fdbmonitor + mkdir $out/libexec && mv $out/usr/lib/foundationdb/backup_agent/backup_agent $out/libexec/backup_agent + mv $out/sbin/fdbserver $out/bin/fdbserver + + rm -rf $out/etc $out/lib/foundationdb $out/lib/systemd $out/log $out/sbin $out/usr $out/var + + # move results into multi outputs + mkdir -p $dev $lib + mv $out/include $dev/include + mv $out/lib $lib/lib + + # python bindings + # NB: use the original setup.py.in, so we can substitute VERSION correctly + cp ../LICENSE ./bindings/python + substitute ../bindings/python/setup.py.in ./bindings/python/setup.py \ + --replace 'VERSION' "${version}" + rm -f ./bindings/python/setup.py.* ./bindings/python/CMakeLists.txt + rm -f ./bindings/python/fdb/*.pth # remove useless files + rm -f ./bindings/python/*.rst ./bindings/python/*.mk + + cp -R ./bindings/python/ tmp-pythonsrc/ + tar -zcf $pythonsrc --transform s/tmp-pythonsrc/python-foundationdb/ ./tmp-pythonsrc/ + + # java bindings + mkdir -p $lib/share/java + mv lib/fdb-java-*.jar $lib/share/java/fdb-java.jar + ''; + + outputs = [ + "out" + "dev" + "lib" + "pythonsrc" + ]; + + meta = { + description = "Open source, distributed, transactional key-value store"; + homepage = "https://www.foundationdb.org"; + license = lib.licenses.asl20; + platforms = [ "x86_64-linux" ] ++ lib.optionals (!(avxEnabled version)) [ "aarch64-linux" ]; + # Fails when cross-compiling with "/bin/sh: gcc-ar: not found" + broken = stdenv.buildPlatform != stdenv.hostPlatform; + maintainers = with lib.maintainers; [ + thoughtpolice + lostnet + ]; + }; +} diff --git a/pkgs/servers/foundationdb/cmake.nix b/pkgs/servers/foundationdb/cmake.nix deleted file mode 100644 index e8246a7813d2..000000000000 --- a/pkgs/servers/foundationdb/cmake.nix +++ /dev/null @@ -1,178 +0,0 @@ -# This builder is for FoundationDB CMake build system. - -{ - lib, - fetchFromGitHub, - cmake, - ninja, - python3, - openjdk, - mono, - pkg-config, - msgpack-cxx, - toml11, - jemalloc, - doctest, - - gccStdenv, - llvmPackages, - useClang ? false, - ... -}: - -let - stdenv = if useClang then llvmPackages.libcxxStdenv else gccStdenv; - - # Only even numbered versions compile on aarch64; odd numbered versions have avx enabled. - avxEnabled = - version: - let - isOdd = n: lib.trivial.mod n 2 != 0; - patch = lib.toInt (lib.versions.patch version); - in - isOdd patch; - - makeFdb = - { - version, - hash, - rev ? "refs/tags/${version}", - officialRelease ? true, - patches ? [ ], - boost, - ssl, - }: - stdenv.mkDerivation { - pname = "foundationdb"; - inherit version; - - src = fetchFromGitHub { - owner = "apple"; - repo = "foundationdb"; - inherit rev hash; - }; - - buildInputs = [ - ssl - boost - msgpack-cxx - toml11 - jemalloc - ]; - - checkInputs = [ doctest ]; - - nativeBuildInputs = [ - pkg-config - cmake - ninja - python3 - openjdk - mono - ] ++ lib.optionals useClang [ llvmPackages.lld ]; - - separateDebugInfo = true; - dontFixCmake = true; - - cmakeFlags = [ - (lib.optionalString officialRelease "-DFDB_RELEASE=TRUE") - - # Disable CMake warnings for project developers. - "-Wno-dev" - - # CMake Error at fdbserver/CMakeLists.txt:332 (find_library): - # > Could not find lz4_STATIC_LIBRARIES using the following names: liblz4.a - "-DSSD_ROCKSDB_EXPERIMENTAL=FALSE" - - "-DBUILD_DOCUMENTATION=FALSE" - - # LTO brings up overall build time, but results in much smaller - # binaries for all users and the cache. - (lib.optionalString (!useClang) "-DUSE_LTO=ON") - - # Gold helps alleviate the link time, especially when LTO is - # enabled. But even then, it still takes a majority of the time. - # Same with LLD when Clang is available. - (lib.optionalString useClang "-DUSE_LD=LLD") - (lib.optionalString (!useClang) "-DUSE_LD=GOLD") - - # FIXME: why can't openssl be found automatically? - "-DOPENSSL_USE_STATIC_LIBS=FALSE" - "-DOPENSSL_CRYPTO_LIBRARY=${ssl.out}/lib/libcrypto.so" - "-DOPENSSL_SSL_LIBRARY=${ssl.out}/lib/libssl.so" - ]; - - hardeningDisable = [ "fortify" ]; - - inherit patches; - - postPatch = '' - # allow using any msgpack-cxx version - substituteInPlace cmake/GetMsgpack.cmake \ - --replace-warn 'find_package(msgpack-cxx 6 QUIET CONFIG)' 'find_package(msgpack-cxx QUIET CONFIG)' - - # Use our doctest package - substituteInPlace bindings/c/test/unit/third_party/CMakeLists.txt \ - --replace-fail '/opt/doctest_proj_2.4.8' '${doctest}/include' - - # Upstream upgraded to Boost 1.86 with no code changes; see: - # - substituteInPlace cmake/CompileBoost.cmake \ - --replace-fail 'find_package(Boost 1.78.0 EXACT ' 'find_package(Boost ' - ''; - - # the install phase for cmake is pretty wonky right now since it's not designed to - # coherently install packages as most linux distros expect -- it's designed to build - # packaged artifacts that are shipped in RPMs, etc. we need to add some extra code to - # cmake upstream to fix this, and if we do, i think most of this can go away. - postInstall = '' - mv $out/sbin/fdbmonitor $out/bin/fdbmonitor - mkdir $out/libexec && mv $out/usr/lib/foundationdb/backup_agent/backup_agent $out/libexec/backup_agent - mv $out/sbin/fdbserver $out/bin/fdbserver - - rm -rf $out/etc $out/lib/foundationdb $out/lib/systemd $out/log $out/sbin $out/usr $out/var - - # move results into multi outputs - mkdir -p $dev $lib - mv $out/include $dev/include - mv $out/lib $lib/lib - - # python bindings - # NB: use the original setup.py.in, so we can substitute VERSION correctly - cp ../LICENSE ./bindings/python - substitute ../bindings/python/setup.py.in ./bindings/python/setup.py \ - --replace 'VERSION' "${version}" - rm -f ./bindings/python/setup.py.* ./bindings/python/CMakeLists.txt - rm -f ./bindings/python/fdb/*.pth # remove useless files - rm -f ./bindings/python/*.rst ./bindings/python/*.mk - - cp -R ./bindings/python/ tmp-pythonsrc/ - tar -zcf $pythonsrc --transform s/tmp-pythonsrc/python-foundationdb/ ./tmp-pythonsrc/ - - # java bindings - mkdir -p $lib/share/java - mv lib/fdb-java-*.jar $lib/share/java/fdb-java.jar - ''; - - outputs = [ - "out" - "dev" - "lib" - "pythonsrc" - ]; - - meta = with lib; { - description = "Open source, distributed, transactional key-value store"; - homepage = "https://www.foundationdb.org"; - license = licenses.asl20; - platforms = [ "x86_64-linux" ] ++ lib.optionals (!(avxEnabled version)) [ "aarch64-linux" ]; - # Fails when cross-compiling with "/bin/sh: gcc-ar: not found" - broken = stdenv.buildPlatform != stdenv.hostPlatform; - maintainers = with maintainers; [ - thoughtpolice - lostnet - ]; - }; - }; -in -makeFdb diff --git a/pkgs/servers/foundationdb/default.nix b/pkgs/servers/foundationdb/default.nix deleted file mode 100644 index 591e45485aea..000000000000 --- a/pkgs/servers/foundationdb/default.nix +++ /dev/null @@ -1,49 +0,0 @@ -{ - gccStdenv, - llvmPackages, - lib, - fetchFromGitHub, - fetchpatch, - - cmake, - ninja, - python3, - openjdk, - mono, - openssl, - boost186, - pkg-config, - msgpack-cxx, - toml11, - jemalloc, - doctest, -}@args: - -let - cmakeBuild = import ./cmake.nix args; -in -{ - foundationdb73 = cmakeBuild { - version = "7.3.42"; - hash = "sha256-jQcm+HLai5da2pZZ7iLdN6fpQZxf5+/kkfv9OSXQ57c="; - boost = boost186; - ssl = openssl; - - patches = [ - ./patches/disable-flowbench.patch - ./patches/don-t-use-static-boost-libs.patch - # GetMsgpack: add 4+ versions of upstream - # https://github.com/apple/foundationdb/pull/10935 - (fetchpatch { - url = "https://github.com/apple/foundationdb/commit/c35a23d3f6b65698c3b888d76de2d93a725bff9c.patch"; - hash = "sha256-bneRoZvCzJp0Hp/G0SzAyUyuDrWErSpzv+ickZQJR5w="; - }) - # Add a dependency that prevents bindingtester to run before the python bindings are generated - # https://github.com/apple/foundationdb/pull/11859 - (fetchpatch { - url = "https://github.com/apple/foundationdb/commit/8d04c97a74c6b83dd8aa6ff5af67587044c2a572.patch"; - hash = "sha256-ZLIcmcfirm1+96DtTIr53HfM5z38uTLZrRNHAmZL6rc="; - }) - ]; - }; -} diff --git a/pkgs/servers/foundationdb/python.nix b/pkgs/servers/foundationdb/python.nix deleted file mode 100644 index 152f704ee147..000000000000 --- a/pkgs/servers/foundationdb/python.nix +++ /dev/null @@ -1,27 +0,0 @@ -{ - buildPythonPackage, - lib, - foundationdb, -}: - -buildPythonPackage { - pname = "foundationdb"; - version = foundationdb.version; - - src = foundationdb.pythonsrc; - unpackCmd = "tar xf $curSrc"; - - patchPhase = '' - substituteInPlace ./fdb/impl.py \ - --replace libfdb_c.so "${foundationdb.lib}/lib/libfdb_c.so" - ''; - - doCheck = false; - - meta = with lib; { - description = "Python bindings for FoundationDB"; - homepage = "https://www.foundationdb.org"; - license = with licenses; [ asl20 ]; - maintainers = with maintainers; [ thoughtpolice ]; - }; -} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index df389f32233d..84bc5c9bef29 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -3508,14 +3508,6 @@ with pkgs; fstl = qt5.callPackage ../applications/graphics/fstl { }; - fdbPackages = dontRecurseIntoAttrs (callPackage ../servers/foundationdb { }); - - inherit (fdbPackages) - foundationdb73 - ; - - foundationdb = foundationdb73; - fuse-ext2 = darwin.apple_sdk_11_0.callPackage ../tools/filesystems/fuse-ext2 { }; fwknop = callPackage ../tools/security/fwknop { diff --git a/pkgs/top-level/packages-config.nix b/pkgs/top-level/packages-config.nix index 8c8d1686c70d..3c3253b797f7 100644 --- a/pkgs/top-level/packages-config.nix +++ b/pkgs/top-level/packages-config.nix @@ -13,7 +13,6 @@ inherit (super) agdaPackages apacheHttpdPackages - fdbPackages fusePackages gns3Packages haskellPackages