From 3653909bb94711ab83e8fbc36976873e3a594cab Mon Sep 17 00:00:00 2001 From: ryan4729 Date: Mon, 15 Oct 2018 00:22:24 -0700 Subject: [PATCH 1/4] protobuf3: support cross compilation Provide a native c compiler, which, and protoc --- pkgs/development/libraries/protobuf/3.1.nix | 4 ++- pkgs/development/libraries/protobuf/3.4.nix | 4 ++- pkgs/development/libraries/protobuf/3.5.nix | 4 ++- pkgs/development/libraries/protobuf/3.6.nix | 4 ++- .../libraries/protobuf/generic-v3.nix | 9 ++++-- pkgs/top-level/all-packages.nix | 28 ++++++++++++++++--- 6 files changed, 43 insertions(+), 10 deletions(-) diff --git a/pkgs/development/libraries/protobuf/3.1.nix b/pkgs/development/libraries/protobuf/3.1.nix index 91ef87512c84..2af2d547d70b 100644 --- a/pkgs/development/libraries/protobuf/3.1.nix +++ b/pkgs/development/libraries/protobuf/3.1.nix @@ -1,6 +1,8 @@ -{ callPackage, ... }: +{ callPackage, externalProtoc, buildProtobuf, ... }: callPackage ./generic-v3.nix { version = "3.1.0"; sha256 = "0qlvpsmqgh9nw0k4zrxlxf75pafi3p0ahz99v6761b903y8qyv4i"; + externalProtoc = externalProtoc; + buildProtobuf = buildProtobuf; } diff --git a/pkgs/development/libraries/protobuf/3.4.nix b/pkgs/development/libraries/protobuf/3.4.nix index 5a9034a56a80..c7e4153b2bc1 100644 --- a/pkgs/development/libraries/protobuf/3.4.nix +++ b/pkgs/development/libraries/protobuf/3.4.nix @@ -1,6 +1,8 @@ -{ callPackage, lib, ... }: +{ callPackage, lib, externalProtoc, buildProtobuf, ... }: lib.overrideDerivation (callPackage ./generic-v3.nix { version = "3.4.1"; sha256 = "1lzxmbqlnmi34kymnf399azv86gmdbrf71xiad6wc24bzpkzqybb"; + externalProtoc = externalProtoc; + buildProtobuf = buildProtobuf; }) (attrs: { NIX_CFLAGS_COMPILE = "-Wno-error"; }) diff --git a/pkgs/development/libraries/protobuf/3.5.nix b/pkgs/development/libraries/protobuf/3.5.nix index db9cb6f0371b..2313067a2ac9 100644 --- a/pkgs/development/libraries/protobuf/3.5.nix +++ b/pkgs/development/libraries/protobuf/3.5.nix @@ -1,6 +1,8 @@ -{ callPackage, lib, ... }: +{ callPackage, lib, externalProtoc, buildProtobuf, ... }: lib.overrideDerivation (callPackage ./generic-v3.nix { version = "3.5.1.1"; sha256 = "1h4xydr5j2zg1888ncn8a1jvqq8fgpgckrmjg6lqzy9jpkvqvfdk"; + externalProtoc = externalProtoc; + buildProtobuf = buildProtobuf; }) (attrs: { NIX_CFLAGS_COMPILE = "-Wno-error"; }) diff --git a/pkgs/development/libraries/protobuf/3.6.nix b/pkgs/development/libraries/protobuf/3.6.nix index 0009209d9cef..b52cbbfe06e0 100644 --- a/pkgs/development/libraries/protobuf/3.6.nix +++ b/pkgs/development/libraries/protobuf/3.6.nix @@ -1,6 +1,8 @@ -{ callPackage, ... }: +{ callPackage, externalProtoc, buildProtobuf, ... }: callPackage ./generic-v3.nix { version = "3.6.1"; sha256 = "1bg40miylzpy2wgbd7l7zjgmk43l12q38fq0zkn0vzy1lsj457sq"; + externalProtoc = externalProtoc; + buildProtobuf = buildProtobuf; } diff --git a/pkgs/development/libraries/protobuf/generic-v3.nix b/pkgs/development/libraries/protobuf/generic-v3.nix index 79e4c387cdf5..c810558a070b 100644 --- a/pkgs/development/libraries/protobuf/generic-v3.nix +++ b/pkgs/development/libraries/protobuf/generic-v3.nix @@ -1,6 +1,8 @@ { stdenv , fetchFromGitHub -, autoreconfHook, zlib, gmock +, autoreconfHook, zlib, gmock, which, buildPackages +, externalProtoc +, buildProtobuf ? null , version, sha256 , ... }: @@ -28,8 +30,11 @@ stdenv.mkDerivation rec { --replace 'tmpnam(b)' '"'$TMPDIR'/foo"' ''; - nativeBuildInputs = [ autoreconfHook ]; + nativeBuildInputs = [ autoreconfHook buildPackages.which buildPackages.stdenv.cc ] + ++ stdenv.lib.optional externalProtoc [ buildProtobuf ]; + buildInputs = [ zlib ]; + configureFlags = stdenv.lib.optional externalProtoc [ "--with-protoc=${buildProtobuf}/bin/protoc" ]; enableParallelBuilding = true; diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 124c9f36e532..6fff2cd66f0a 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -11726,10 +11726,30 @@ with pkgs; protobuf = protobuf3_6; - protobuf3_6 = callPackage ../development/libraries/protobuf/3.6.nix { }; - protobuf3_5 = callPackage ../development/libraries/protobuf/3.5.nix { }; - protobuf3_4 = callPackage ../development/libraries/protobuf/3.4.nix { }; - protobuf3_1 = callPackage ../development/libraries/protobuf/3.1.nix { }; + protobuf3_6 = callPackage ../development/libraries/protobuf/3.6.nix { + externalProtoc = (stdenv.hostPlatform != stdenv.buildPlatform); + buildProtobuf = if (stdenv.hostPlatform != stdenv.buildPlatform) + then buildPackages.protobuf3_6 + else null; + }; + protobuf3_5 = callPackage ../development/libraries/protobuf/3.5.nix { + externalProtoc = (stdenv.hostPlatform != stdenv.buildPlatform); + buildProtobuf = if (stdenv.hostPlatform != stdenv.buildPlatform) + then buildPackages.protobuf3_5 + else null; + }; + protobuf3_4 = callPackage ../development/libraries/protobuf/3.4.nix { + externalProtoc = (stdenv.hostPlatform != stdenv.buildPlatform); + buildProtobuf = if (stdenv.hostPlatform != stdenv.buildPlatform) + then buildPackages.protobuf3_4 + else null; + }; + protobuf3_1 = callPackage ../development/libraries/protobuf/3.1.nix { + externalProtoc = (stdenv.hostPlatform != stdenv.buildPlatform); + buildProtobuf = if (stdenv.hostPlatform != stdenv.buildPlatform) + then buildPackages.protobuf3_1 + else null; + }; protobuf2_5 = callPackage ../development/libraries/protobuf/2.5.nix { }; protobufc = callPackage ../development/libraries/protobufc/1.3.nix { }; From 12ededf3d84dc3b4e1cf4845655c56fabfc8d5d2 Mon Sep 17 00:00:00 2001 From: ryan4729 Date: Mon, 15 Oct 2018 01:57:47 -0700 Subject: [PATCH 2/4] protobuf3: fix parameter naming --- pkgs/development/libraries/protobuf/3.1.nix | 5 ++--- pkgs/development/libraries/protobuf/3.4.nix | 5 ++--- pkgs/development/libraries/protobuf/3.5.nix | 5 ++--- pkgs/development/libraries/protobuf/3.6.nix | 5 ++--- pkgs/development/libraries/protobuf/generic-v3.nix | 6 +++--- pkgs/top-level/all-packages.nix | 8 ++++---- 6 files changed, 15 insertions(+), 19 deletions(-) diff --git a/pkgs/development/libraries/protobuf/3.1.nix b/pkgs/development/libraries/protobuf/3.1.nix index 2af2d547d70b..79e3711ff104 100644 --- a/pkgs/development/libraries/protobuf/3.1.nix +++ b/pkgs/development/libraries/protobuf/3.1.nix @@ -1,8 +1,7 @@ -{ callPackage, externalProtoc, buildProtobuf, ... }: +{ callPackage, useExternalProtoc, buildProtobuf, ... }: callPackage ./generic-v3.nix { version = "3.1.0"; sha256 = "0qlvpsmqgh9nw0k4zrxlxf75pafi3p0ahz99v6761b903y8qyv4i"; - externalProtoc = externalProtoc; - buildProtobuf = buildProtobuf; + inherit useExternalProtoc buildProtobuf; } diff --git a/pkgs/development/libraries/protobuf/3.4.nix b/pkgs/development/libraries/protobuf/3.4.nix index c7e4153b2bc1..a80517250f5d 100644 --- a/pkgs/development/libraries/protobuf/3.4.nix +++ b/pkgs/development/libraries/protobuf/3.4.nix @@ -1,8 +1,7 @@ -{ callPackage, lib, externalProtoc, buildProtobuf, ... }: +{ callPackage, lib, useExternalProtoc, buildProtobuf, ... }: lib.overrideDerivation (callPackage ./generic-v3.nix { version = "3.4.1"; sha256 = "1lzxmbqlnmi34kymnf399azv86gmdbrf71xiad6wc24bzpkzqybb"; - externalProtoc = externalProtoc; - buildProtobuf = buildProtobuf; + inherit useExternalProtoc buildProtobuf; }) (attrs: { NIX_CFLAGS_COMPILE = "-Wno-error"; }) diff --git a/pkgs/development/libraries/protobuf/3.5.nix b/pkgs/development/libraries/protobuf/3.5.nix index 2313067a2ac9..8558e60a5e86 100644 --- a/pkgs/development/libraries/protobuf/3.5.nix +++ b/pkgs/development/libraries/protobuf/3.5.nix @@ -1,8 +1,7 @@ -{ callPackage, lib, externalProtoc, buildProtobuf, ... }: +{ callPackage, lib, useExternalProtoc, buildProtobuf, ... }: lib.overrideDerivation (callPackage ./generic-v3.nix { version = "3.5.1.1"; sha256 = "1h4xydr5j2zg1888ncn8a1jvqq8fgpgckrmjg6lqzy9jpkvqvfdk"; - externalProtoc = externalProtoc; - buildProtobuf = buildProtobuf; + inherit useExternalProtoc buildProtobuf; }) (attrs: { NIX_CFLAGS_COMPILE = "-Wno-error"; }) diff --git a/pkgs/development/libraries/protobuf/3.6.nix b/pkgs/development/libraries/protobuf/3.6.nix index b52cbbfe06e0..a3fac7eb0641 100644 --- a/pkgs/development/libraries/protobuf/3.6.nix +++ b/pkgs/development/libraries/protobuf/3.6.nix @@ -1,8 +1,7 @@ -{ callPackage, externalProtoc, buildProtobuf, ... }: +{ callPackage, useExternalProtoc, buildProtobuf, ... }: callPackage ./generic-v3.nix { version = "3.6.1"; sha256 = "1bg40miylzpy2wgbd7l7zjgmk43l12q38fq0zkn0vzy1lsj457sq"; - externalProtoc = externalProtoc; - buildProtobuf = buildProtobuf; + inherit useExternalProtoc buildProtobuf; } diff --git a/pkgs/development/libraries/protobuf/generic-v3.nix b/pkgs/development/libraries/protobuf/generic-v3.nix index c810558a070b..3db4571d8bad 100644 --- a/pkgs/development/libraries/protobuf/generic-v3.nix +++ b/pkgs/development/libraries/protobuf/generic-v3.nix @@ -1,7 +1,7 @@ { stdenv , fetchFromGitHub , autoreconfHook, zlib, gmock, which, buildPackages -, externalProtoc +, useExternalProtoc , buildProtobuf ? null , version, sha256 , ... @@ -31,10 +31,10 @@ stdenv.mkDerivation rec { ''; nativeBuildInputs = [ autoreconfHook buildPackages.which buildPackages.stdenv.cc ] - ++ stdenv.lib.optional externalProtoc [ buildProtobuf ]; + ++ stdenv.lib.optional useExternalProtoc [ buildProtobuf ]; buildInputs = [ zlib ]; - configureFlags = stdenv.lib.optional externalProtoc [ "--with-protoc=${buildProtobuf}/bin/protoc" ]; + configureFlags = stdenv.lib.optional useExternalProtoc [ "--with-protoc=${buildProtobuf}/bin/protoc" ]; enableParallelBuilding = true; diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 6fff2cd66f0a..65e11ac65325 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -11727,25 +11727,25 @@ with pkgs; protobuf = protobuf3_6; protobuf3_6 = callPackage ../development/libraries/protobuf/3.6.nix { - externalProtoc = (stdenv.hostPlatform != stdenv.buildPlatform); + useExternalProtoc = (stdenv.hostPlatform != stdenv.buildPlatform); buildProtobuf = if (stdenv.hostPlatform != stdenv.buildPlatform) then buildPackages.protobuf3_6 else null; }; protobuf3_5 = callPackage ../development/libraries/protobuf/3.5.nix { - externalProtoc = (stdenv.hostPlatform != stdenv.buildPlatform); + useExternalProtoc = (stdenv.hostPlatform != stdenv.buildPlatform); buildProtobuf = if (stdenv.hostPlatform != stdenv.buildPlatform) then buildPackages.protobuf3_5 else null; }; protobuf3_4 = callPackage ../development/libraries/protobuf/3.4.nix { - externalProtoc = (stdenv.hostPlatform != stdenv.buildPlatform); + useExternalProtoc = (stdenv.hostPlatform != stdenv.buildPlatform); buildProtobuf = if (stdenv.hostPlatform != stdenv.buildPlatform) then buildPackages.protobuf3_4 else null; }; protobuf3_1 = callPackage ../development/libraries/protobuf/3.1.nix { - externalProtoc = (stdenv.hostPlatform != stdenv.buildPlatform); + useExternalProtoc = (stdenv.hostPlatform != stdenv.buildPlatform); buildProtobuf = if (stdenv.hostPlatform != stdenv.buildPlatform) then buildPackages.protobuf3_1 else null; From 1f9188b708da7d2ea973a840ac086e6542ed0d2a Mon Sep 17 00:00:00 2001 From: ryan4729 Date: Mon, 15 Oct 2018 03:01:29 -0700 Subject: [PATCH 3/4] protobuf3: clean up cross compile --- pkgs/development/libraries/protobuf/3.1.nix | 3 +- pkgs/development/libraries/protobuf/3.4.nix | 3 +- pkgs/development/libraries/protobuf/3.5.nix | 3 +- pkgs/development/libraries/protobuf/3.6.nix | 3 +- .../libraries/protobuf/generic-v3.nix | 14 ++++++---- pkgs/top-level/all-packages.nix | 28 +++---------------- 6 files changed, 16 insertions(+), 38 deletions(-) diff --git a/pkgs/development/libraries/protobuf/3.1.nix b/pkgs/development/libraries/protobuf/3.1.nix index 79e3711ff104..91ef87512c84 100644 --- a/pkgs/development/libraries/protobuf/3.1.nix +++ b/pkgs/development/libraries/protobuf/3.1.nix @@ -1,7 +1,6 @@ -{ callPackage, useExternalProtoc, buildProtobuf, ... }: +{ callPackage, ... }: callPackage ./generic-v3.nix { version = "3.1.0"; sha256 = "0qlvpsmqgh9nw0k4zrxlxf75pafi3p0ahz99v6761b903y8qyv4i"; - inherit useExternalProtoc buildProtobuf; } diff --git a/pkgs/development/libraries/protobuf/3.4.nix b/pkgs/development/libraries/protobuf/3.4.nix index a80517250f5d..5a9034a56a80 100644 --- a/pkgs/development/libraries/protobuf/3.4.nix +++ b/pkgs/development/libraries/protobuf/3.4.nix @@ -1,7 +1,6 @@ -{ callPackage, lib, useExternalProtoc, buildProtobuf, ... }: +{ callPackage, lib, ... }: lib.overrideDerivation (callPackage ./generic-v3.nix { version = "3.4.1"; sha256 = "1lzxmbqlnmi34kymnf399azv86gmdbrf71xiad6wc24bzpkzqybb"; - inherit useExternalProtoc buildProtobuf; }) (attrs: { NIX_CFLAGS_COMPILE = "-Wno-error"; }) diff --git a/pkgs/development/libraries/protobuf/3.5.nix b/pkgs/development/libraries/protobuf/3.5.nix index 8558e60a5e86..db9cb6f0371b 100644 --- a/pkgs/development/libraries/protobuf/3.5.nix +++ b/pkgs/development/libraries/protobuf/3.5.nix @@ -1,7 +1,6 @@ -{ callPackage, lib, useExternalProtoc, buildProtobuf, ... }: +{ callPackage, lib, ... }: lib.overrideDerivation (callPackage ./generic-v3.nix { version = "3.5.1.1"; sha256 = "1h4xydr5j2zg1888ncn8a1jvqq8fgpgckrmjg6lqzy9jpkvqvfdk"; - inherit useExternalProtoc buildProtobuf; }) (attrs: { NIX_CFLAGS_COMPILE = "-Wno-error"; }) diff --git a/pkgs/development/libraries/protobuf/3.6.nix b/pkgs/development/libraries/protobuf/3.6.nix index a3fac7eb0641..0009209d9cef 100644 --- a/pkgs/development/libraries/protobuf/3.6.nix +++ b/pkgs/development/libraries/protobuf/3.6.nix @@ -1,7 +1,6 @@ -{ callPackage, useExternalProtoc, buildProtobuf, ... }: +{ callPackage, ... }: callPackage ./generic-v3.nix { version = "3.6.1"; sha256 = "1bg40miylzpy2wgbd7l7zjgmk43l12q38fq0zkn0vzy1lsj457sq"; - inherit useExternalProtoc buildProtobuf; } diff --git a/pkgs/development/libraries/protobuf/generic-v3.nix b/pkgs/development/libraries/protobuf/generic-v3.nix index 3db4571d8bad..43e5e5d799d1 100644 --- a/pkgs/development/libraries/protobuf/generic-v3.nix +++ b/pkgs/development/libraries/protobuf/generic-v3.nix @@ -1,13 +1,12 @@ { stdenv , fetchFromGitHub , autoreconfHook, zlib, gmock, which, buildPackages -, useExternalProtoc -, buildProtobuf ? null , version, sha256 , ... }: -stdenv.mkDerivation rec { +let +mkProtobufDerivation = buildProtobuf: stdenv: stdenv.mkDerivation rec { name = "protobuf-${version}"; # make sure you test also -A pythonPackages.protobuf @@ -31,10 +30,10 @@ stdenv.mkDerivation rec { ''; nativeBuildInputs = [ autoreconfHook buildPackages.which buildPackages.stdenv.cc ] - ++ stdenv.lib.optional useExternalProtoc [ buildProtobuf ]; + ++ (if buildProtobuf == null then [] else [ buildProtobuf ]); buildInputs = [ zlib ]; - configureFlags = stdenv.lib.optional useExternalProtoc [ "--with-protoc=${buildProtobuf}/bin/protoc" ]; + configureFlags = if buildProtobuf == null then [] else [ "--with-protoc=${buildProtobuf}/bin/protoc" ]; enableParallelBuilding = true; @@ -59,4 +58,7 @@ stdenv.mkDerivation rec { }; passthru.version = version; -} +}; +in mkProtobufDerivation(if (stdenv.buildPlatform != stdenv.hostPlatform) + then (mkProtobufDerivation null buildPackages.stdenv) + else null) stdenv diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 65e11ac65325..124c9f36e532 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -11726,30 +11726,10 @@ with pkgs; protobuf = protobuf3_6; - protobuf3_6 = callPackage ../development/libraries/protobuf/3.6.nix { - useExternalProtoc = (stdenv.hostPlatform != stdenv.buildPlatform); - buildProtobuf = if (stdenv.hostPlatform != stdenv.buildPlatform) - then buildPackages.protobuf3_6 - else null; - }; - protobuf3_5 = callPackage ../development/libraries/protobuf/3.5.nix { - useExternalProtoc = (stdenv.hostPlatform != stdenv.buildPlatform); - buildProtobuf = if (stdenv.hostPlatform != stdenv.buildPlatform) - then buildPackages.protobuf3_5 - else null; - }; - protobuf3_4 = callPackage ../development/libraries/protobuf/3.4.nix { - useExternalProtoc = (stdenv.hostPlatform != stdenv.buildPlatform); - buildProtobuf = if (stdenv.hostPlatform != stdenv.buildPlatform) - then buildPackages.protobuf3_4 - else null; - }; - protobuf3_1 = callPackage ../development/libraries/protobuf/3.1.nix { - useExternalProtoc = (stdenv.hostPlatform != stdenv.buildPlatform); - buildProtobuf = if (stdenv.hostPlatform != stdenv.buildPlatform) - then buildPackages.protobuf3_1 - else null; - }; + protobuf3_6 = callPackage ../development/libraries/protobuf/3.6.nix { }; + protobuf3_5 = callPackage ../development/libraries/protobuf/3.5.nix { }; + protobuf3_4 = callPackage ../development/libraries/protobuf/3.4.nix { }; + protobuf3_1 = callPackage ../development/libraries/protobuf/3.1.nix { }; protobuf2_5 = callPackage ../development/libraries/protobuf/2.5.nix { }; protobufc = callPackage ../development/libraries/protobufc/1.3.nix { }; From 65a81afcf5ef9bc96c21089b370bece300849977 Mon Sep 17 00:00:00 2001 From: ryan4729 Date: Mon, 15 Oct 2018 03:13:20 -0700 Subject: [PATCH 4/4] protobuf3: remove unnecessary null check --- pkgs/development/libraries/protobuf/generic-v3.nix | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pkgs/development/libraries/protobuf/generic-v3.nix b/pkgs/development/libraries/protobuf/generic-v3.nix index 43e5e5d799d1..883dff56f2ee 100644 --- a/pkgs/development/libraries/protobuf/generic-v3.nix +++ b/pkgs/development/libraries/protobuf/generic-v3.nix @@ -29,8 +29,7 @@ mkProtobufDerivation = buildProtobuf: stdenv: stdenv.mkDerivation rec { --replace 'tmpnam(b)' '"'$TMPDIR'/foo"' ''; - nativeBuildInputs = [ autoreconfHook buildPackages.which buildPackages.stdenv.cc ] - ++ (if buildProtobuf == null then [] else [ buildProtobuf ]); + nativeBuildInputs = [ autoreconfHook buildPackages.which buildPackages.stdenv.cc buildProtobuf ]; buildInputs = [ zlib ]; configureFlags = if buildProtobuf == null then [] else [ "--with-protoc=${buildProtobuf}/bin/protoc" ];