From 4833b69b609bbe01b8ef5447de34fc76906a1817 Mon Sep 17 00:00:00 2001 From: Tobias Mayer Date: Fri, 11 Oct 2019 22:58:47 +0200 Subject: [PATCH 1/2] zstd: add static option CMake is used for static builds because the Makefile does not offer a way to disable the shared library. --- pkgs/tools/compression/zstd/default.nix | 24 ++++++++++++++++++------ pkgs/top-level/static.nix | 4 ++++ 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/pkgs/tools/compression/zstd/default.nix b/pkgs/tools/compression/zstd/default.nix index 5a153393ccdba..7c990fc8bf14d 100644 --- a/pkgs/tools/compression/zstd/default.nix +++ b/pkgs/tools/compression/zstd/default.nix @@ -1,9 +1,10 @@ -{ stdenv, fetchFromGitHub, gnugrep +{ stdenv, fetchFromGitHub, fetchpatch, gnugrep , fixDarwinDylibNames , file -, legacySupport ? false }: +, legacySupport ? false +, static ? false, cmake }: -stdenv.mkDerivation rec { +stdenv.mkDerivation (rec { pname = "zstd"; version = "1.4.3"; @@ -27,11 +28,11 @@ stdenv.mkDerivation rec { --replace 'MD5SUM="md5 -r"' 'MD5SUM="md5sum"' ''; - installFlags = [ + installFlags = stdenv.lib.optionals (!static) [ "PREFIX=$(out)" ]; - preInstall = '' + preInstall = stdenv.lib.optionalString (!static) '' substituteInPlace programs/zstdgrep \ --replace ":-grep" ":-${gnugrep}/bin/grep" \ --replace ":-zstdcat" ":-$out/bin/zstdcat" @@ -59,4 +60,15 @@ stdenv.mkDerivation rec { platforms = platforms.unix; maintainers = with maintainers; [ orivej ]; }; -} +} // stdenv.lib.optionalAttrs static { + nativeBuildInputs = [ cmake ]; + patches = [(fetchpatch { + url = "https://github.com/facebook/zstd/commit/bda4669edc38c61e033bcf3905932e6d79c9d64a.diff"; + sha256 = "0asnslwb5k6g8yfr263fddarfmawsmvpdvbfyww773na2mmvhk66"; + })]; + cmakeFlags = [ + "-DZSTD_BUILD_SHARED:BOOL=OFF" + "-DZSTD_LEGACY_SUPPORT:BOOl=${if legacySupport then "ON" else "OFF"}" + ]; + cmakeDir = "../build/cmake"; +}) diff --git a/pkgs/top-level/static.nix b/pkgs/top-level/static.nix index d17080960329a..8ccb1c87f8148 100644 --- a/pkgs/top-level/static.nix +++ b/pkgs/top-level/static.nix @@ -181,6 +181,10 @@ in { staticOnly = true; }; + zstd = super.zstd.override { + static = true; + }; + llvmPackages_8 = super.llvmPackages_8 // { libraries = super.llvmPackages_8.libraries // rec { libcxxabi = super.llvmPackages_8.libraries.libcxxabi.override { From 60041df69ce1e2479ecd0acf548d2c9fca692143 Mon Sep 17 00:00:00 2001 From: Tobias Mayer Date: Mon, 4 Nov 2019 07:40:15 +0100 Subject: [PATCH 2/2] zstd: Build with CMake --- pkgs/tools/compression/zstd/default.nix | 49 ++++++++++++------------- 1 file changed, 23 insertions(+), 26 deletions(-) diff --git a/pkgs/tools/compression/zstd/default.nix b/pkgs/tools/compression/zstd/default.nix index 7c990fc8bf14d..b96de3ce99886 100644 --- a/pkgs/tools/compression/zstd/default.nix +++ b/pkgs/tools/compression/zstd/default.nix @@ -1,10 +1,10 @@ -{ stdenv, fetchFromGitHub, fetchpatch, gnugrep +{ stdenv, fetchFromGitHub, fetchpatch, cmake, gnugrep , fixDarwinDylibNames , file , legacySupport ? false -, static ? false, cmake }: +, static ? false }: -stdenv.mkDerivation (rec { +stdenv.mkDerivation rec { pname = "zstd"; version = "1.4.3"; @@ -15,34 +15,42 @@ stdenv.mkDerivation (rec { owner = "facebook"; }; + outputs = [ "out" "lib" "dev" ]; + buildInputs = stdenv.lib.optional stdenv.isDarwin fixDarwinDylibNames; - makeFlags = [ - "ZSTD_LEGACY_SUPPORT=${if legacySupport then "1" else "0"}" + nativeBuildInputs = [ cmake ]; + patches = [(fetchpatch { + url = "https://github.com/facebook/zstd/commit/bda4669edc38c61e033bcf3905932e6d79c9d64a.diff"; + sha256 = "0asnslwb5k6g8yfr263fddarfmawsmvpdvbfyww773na2mmvhk66"; + })]; + cmakeFlags = [ + "-DZSTD_BUILD_SHARED:BOOL=${if static then "OFF" else "ON"}" + "-DZSTD_LEGACY_SUPPORT:BOOl=${if legacySupport then "ON" else "OFF"}" + "-DZSTD_BUILD_TESTS:BOOL=ON" ]; + cmakeDir = "../build/cmake"; + dontUseCmakeBuildDir = true; + preConfigure = '' + mkdir -p build_ && cd $_ + ''; checkInputs = [ file ]; doCheck = true; preCheck = '' - substituteInPlace tests/playTests.sh \ + substituteInPlace ../tests/playTests.sh \ --replace 'MD5SUM="md5 -r"' 'MD5SUM="md5sum"' ''; - installFlags = stdenv.lib.optionals (!static) [ - "PREFIX=$(out)" - ]; - preInstall = stdenv.lib.optionalString (!static) '' - substituteInPlace programs/zstdgrep \ + substituteInPlace ../programs/zstdgrep \ --replace ":-grep" ":-${gnugrep}/bin/grep" \ --replace ":-zstdcat" ":-$out/bin/zstdcat" - substituteInPlace programs/zstdless \ + substituteInPlace ../programs/zstdless \ --replace "zstdcat" "$out/bin/zstdcat" ''; - enableParallelBuilding = true; - meta = with stdenv.lib; { description = "Zstandard real-time compression algorithm"; longDescription = '' @@ -60,15 +68,4 @@ stdenv.mkDerivation (rec { platforms = platforms.unix; maintainers = with maintainers; [ orivej ]; }; -} // stdenv.lib.optionalAttrs static { - nativeBuildInputs = [ cmake ]; - patches = [(fetchpatch { - url = "https://github.com/facebook/zstd/commit/bda4669edc38c61e033bcf3905932e6d79c9d64a.diff"; - sha256 = "0asnslwb5k6g8yfr263fddarfmawsmvpdvbfyww773na2mmvhk66"; - })]; - cmakeFlags = [ - "-DZSTD_BUILD_SHARED:BOOL=OFF" - "-DZSTD_LEGACY_SUPPORT:BOOl=${if legacySupport then "ON" else "OFF"}" - ]; - cmakeDir = "../build/cmake"; -}) +}