about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/libraries/libphonenumber
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/development/libraries/libphonenumber')
-rw-r--r--nixpkgs/pkgs/development/libraries/libphonenumber/build-reproducibility.patch24
-rw-r--r--nixpkgs/pkgs/development/libraries/libphonenumber/default.nix46
2 files changed, 70 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/development/libraries/libphonenumber/build-reproducibility.patch b/nixpkgs/pkgs/development/libraries/libphonenumber/build-reproducibility.patch
new file mode 100644
index 000000000000..202370a80fc5
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/libphonenumber/build-reproducibility.patch
@@ -0,0 +1,24 @@
+diff --git a/tools/cpp/src/cpp-build/generate_geocoding_data.cc b/tools/cpp/src/cpp-build/generate_geocoding_data.cc
+index 205947e831..1e628e2cd2 100644
+--- a/tools/cpp/src/cpp-build/generate_geocoding_data.cc
++++ b/tools/cpp/src/cpp-build/generate_geocoding_data.cc
+@@ -97,7 +97,8 @@ class DirEntry {
+   DirEntryKinds kind_;
+ };
+ 
+-// Lists directory entries in path. "." and ".." are excluded. Returns true on
++// Lists directory entries in path. "." and ".." are excluded. Entries are
++// returned in a consistent order to ensure reproducibility. Returns true on
+ // success.
+ bool ListDirectory(const string& path, vector<DirEntry>* entries) {
+   entries->clear();
+@@ -135,6 +136,9 @@ bool ListDirectory(const string& path, vector<DirEntry>* entries) {
+     }
+     entries->push_back(DirEntry(entry->d_name, kind));
+   }
++  std::sort(
++      entries->begin(), entries->end(),
++      [](const DirEntry& a, const DirEntry& b) { return a.name() < b.name(); });
+ }
+ 
+ // Returns true if s ends with suffix.
diff --git a/nixpkgs/pkgs/development/libraries/libphonenumber/default.nix b/nixpkgs/pkgs/development/libraries/libphonenumber/default.nix
new file mode 100644
index 000000000000..a9b0df3304be
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/libphonenumber/default.nix
@@ -0,0 +1,46 @@
+{ lib, stdenv, fetchFromGitHub, cmake, gtest, boost, pkg-config, protobuf, icu, Foundation, buildPackages }:
+
+stdenv.mkDerivation rec {
+  pname = "phonenumber";
+  version = "8.12.37";
+
+  src = fetchFromGitHub {
+    owner = "googlei18n";
+    repo = "libphonenumber";
+    rev = "v${version}";
+    sha256 = "sha256-xLxadSxVY3DjFDQrqj3BuOvdMaKdFSLjocfzovJCBB0=";
+  };
+
+  patches = [
+    # Submitted upstream: https://github.com/google/libphonenumber/pull/2921
+    ./build-reproducibility.patch
+  ];
+
+  nativeBuildInputs = [
+    cmake
+    pkg-config
+  ];
+
+  buildInputs = [
+    boost
+    protobuf
+    icu
+    gtest
+  ] ++ lib.optional stdenv.isDarwin Foundation;
+
+  cmakeDir = "../cpp";
+  cmakeFlags =
+    lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
+      "-DBUILD_GEOCODER=OFF"
+      "-DPROTOC_BIN=${buildPackages.protobuf}/bin/protoc"
+    ];
+
+  checkPhase = "./libphonenumber_test";
+
+  meta = with lib; {
+    description = "Google's i18n library for parsing and using phone numbers";
+    homepage = "https://github.com/google/libphonenumber";
+    license = licenses.asl20;
+    maintainers = with maintainers; [ illegalprime ];
+  };
+}