about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/libraries/proj
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/development/libraries/proj')
-rw-r--r--nixpkgs/pkgs/development/libraries/proj/7.nix59
-rw-r--r--nixpkgs/pkgs/development/libraries/proj/default.nix74
-rw-r--r--nixpkgs/pkgs/development/libraries/proj/only-add-curl-for-static-builds.patch37
-rw-r--r--nixpkgs/pkgs/development/libraries/proj/tests-sqlite-3.39.patch13
-rw-r--r--nixpkgs/pkgs/development/libraries/proj/tests.nix11
5 files changed, 194 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/development/libraries/proj/7.nix b/nixpkgs/pkgs/development/libraries/proj/7.nix
new file mode 100644
index 000000000000..4e1ade0bd56b
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/proj/7.nix
@@ -0,0 +1,59 @@
+{ lib
+, stdenv
+, fetchFromGitHub
+, cmake
+, pkg-config
+, sqlite
+, libtiff
+, curl
+, gtest
+, fetchpatch
+}:
+
+stdenv.mkDerivation rec {
+  pname = "proj";
+  version = "7.2.1";
+
+  src = fetchFromGitHub {
+    owner = "OSGeo";
+    repo = "PROJ";
+    rev = version;
+    sha256 = "0mymvfvs8xggl4axvlj7kc1ksd9g94kaz6w1vdv0x2y5mqk93gx9";
+  };
+
+  patches = [
+    (fetchpatch { # https://github.com/OSGeo/PROJ/issues/2557
+      name = "gie_self_tests-fail.diff"; # included in >= 8.0.1
+      url = "https://github.com/OSGeo/PROJ/commit/6f1a3c4648bf06862dca0b3725cbb3b7ee0284e3.diff";
+      sha256 = "0gapny0a9c3r0x9szjgn86sspjrrf4vwbija77b17w6ci5cq4pdf";
+    })
+    ./tests-sqlite-3.39.patch
+  ];
+
+  postPatch = lib.optionalString (version == "7.2.1") ''
+    substituteInPlace CMakeLists.txt \
+      --replace "MAJOR 7 MINOR 2 PATCH 0" "MAJOR 7 MINOR 2 PATCH 1"
+  '';
+
+  outputs = [ "out" "dev"];
+
+  nativeBuildInputs = [ cmake pkg-config ];
+
+  buildInputs = [ sqlite libtiff curl ];
+
+  nativeCheckInputs = [ gtest ];
+
+  cmakeFlags = [
+    "-DUSE_EXTERNAL_GTEST=ON"
+  ];
+
+  doCheck = true;
+
+  meta = with lib; {
+    description = "Cartographic Projections Library";
+    homepage = "https://proj4.org";
+    license = licenses.mit;
+    platforms = platforms.unix;
+    maintainers = with maintainers; [ dotlambda ];
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/proj/default.nix b/nixpkgs/pkgs/development/libraries/proj/default.nix
new file mode 100644
index 000000000000..ce1f74f0b153
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/proj/default.nix
@@ -0,0 +1,74 @@
+{ lib
+, stdenv
+, fetchFromGitHub
+, fetchpatch
+, cmake
+, pkg-config
+, buildPackages
+, callPackage
+, sqlite
+, libtiff
+, curl
+, gtest
+, nlohmann_json
+, python3
+, cacert
+}:
+
+stdenv.mkDerivation (finalAttrs: rec {
+  pname = "proj";
+  version = "9.3.0";
+
+  src = fetchFromGitHub {
+    owner = "OSGeo";
+    repo = "PROJ";
+    rev = version;
+    hash = "sha256-M1KUXzht4qIjPfHxvzPr7XUnisMwtbegKp18XQjNYHg=";
+  };
+
+  patches = [
+    # https://github.com/OSGeo/PROJ/pull/3252
+    ./only-add-curl-for-static-builds.patch
+  ];
+
+  outputs = [ "out" "dev" ];
+
+  nativeBuildInputs = [ cmake pkg-config ];
+
+  buildInputs = [ sqlite libtiff curl nlohmann_json ];
+
+  nativeCheckInputs = [ cacert gtest ];
+
+  cmakeFlags = [
+    "-DUSE_EXTERNAL_GTEST=ON"
+    "-DRUN_NETWORK_DEPENDENT_TESTS=OFF"
+    "-DNLOHMANN_JSON_ORIGIN=external"
+    "-DEXE_SQLITE3=${buildPackages.sqlite}/bin/sqlite3"
+  ];
+
+  preCheck =
+    let
+      libPathEnvVar = if stdenv.isDarwin then "DYLD_LIBRARY_PATH" else "LD_LIBRARY_PATH";
+    in
+      ''
+        export HOME=$TMPDIR
+        export TMP=$TMPDIR
+        export ${libPathEnvVar}=$PWD/lib
+      '';
+
+  doCheck = true;
+
+  passthru.tests = {
+    python = python3.pkgs.pyproj;
+    proj = callPackage ./tests.nix { proj = finalAttrs.finalPackage; };
+  };
+
+  meta = with lib; {
+    changelog = "https://github.com/OSGeo/PROJ/blob/${src.rev}/NEWS";
+    description = "Cartographic Projections Library";
+    homepage = "https://proj.org/";
+    license = licenses.mit;
+    maintainers = with maintainers; teams.geospatial.members ++ [ dotlambda ];
+    platforms = platforms.unix;
+  };
+})
diff --git a/nixpkgs/pkgs/development/libraries/proj/only-add-curl-for-static-builds.patch b/nixpkgs/pkgs/development/libraries/proj/only-add-curl-for-static-builds.patch
new file mode 100644
index 000000000000..394476787a91
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/proj/only-add-curl-for-static-builds.patch
@@ -0,0 +1,37 @@
+From 54b1dbc550b3daa2a7834a9bfd73a0c2f8aeba6a Mon Sep 17 00:00:00 2001
+From: Even Rouault <even.rouault@spatialys.com>
+Date: Tue, 5 Jul 2022 19:40:53 +0200
+Subject: [PATCH] proj-config.cmake generation: only add find_dependency(CURL)
+ for static builds
+
+---
+ cmake/project-config.cmake.in | 12 ++++++++----
+ 1 file changed, 8 insertions(+), 4 deletions(-)
+
+diff --git a/cmake/project-config.cmake.in b/cmake/project-config.cmake.in
+index 3f359668..db886396 100644
+--- a/cmake/project-config.cmake.in
++++ b/cmake/project-config.cmake.in
+@@ -19,11 +19,15 @@ include(CMakeFindDependencyMacro)
+ # Cf https://gitlab.kitware.com/cmake/cmake/-/issues/17612
+ cmake_policy(PUSH)
+ cmake_policy(SET CMP0012 NEW)
+-if("@ENABLE_TIFF@")
+-    set(PROJ_CONFIG_FIND_TIFF_DEP ON)
++if(NOT "@BUILD_SHARED_LIBS@")
++    if("@ENABLE_TIFF@")
++        set(PROJ_CONFIG_FIND_TIFF_DEP ON)
++    endif()
+ endif()
+-if("@CURL_ENABLED@")
+-    set(PROJ_CONFIG_FIND_CURL_DEP ON)
++if(NOT "@BUILD_SHARED_LIBS@")
++    if("@CURL_ENABLED@")
++        set(PROJ_CONFIG_FIND_CURL_DEP ON)
++    endif()
+ endif()
+ cmake_policy(POP)
+ 
+-- 
+2.41.0
+
diff --git a/nixpkgs/pkgs/development/libraries/proj/tests-sqlite-3.39.patch b/nixpkgs/pkgs/development/libraries/proj/tests-sqlite-3.39.patch
new file mode 100644
index 000000000000..0654ff5eadb6
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/proj/tests-sqlite-3.39.patch
@@ -0,0 +1,13 @@
+Drop tests that time out with newest sqlite.
+https://github.com/OSGeo/PROJ/issues/3254
+
+--- a/test/cli/CMakeLists.txt
++++ b/test/cli/CMakeLists.txt
+@@ -16 +15,0 @@
+-proj_add_test_script_sh("testprojinfo" PROJINFO_BIN)
+--- a/test/unit/CMakeLists.txt
++++ b/test/unit/CMakeLists.txt
+@@ -144,3 +143,0 @@
+-add_test(NAME proj_test_cpp_api COMMAND proj_test_cpp_api)
+-set_property(TEST proj_test_cpp_api
+-  PROPERTY ENVIRONMENT ${PROJ_TEST_ENVIRONMENT})
diff --git a/nixpkgs/pkgs/development/libraries/proj/tests.nix b/nixpkgs/pkgs/development/libraries/proj/tests.nix
new file mode 100644
index 000000000000..38126f06dd4d
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/proj/tests.nix
@@ -0,0 +1,11 @@
+{ runCommand, proj }:
+
+let
+  inherit (proj) pname;
+in
+runCommand "${pname}-tests" { meta.timeout = 60; }
+  ''
+    ${proj}/bin/projinfo EPSG:4326 \
+      | grep '+proj=longlat +datum=WGS84 +no_defs +type=crs'
+    touch $out
+  ''