1{ stdenv, lib, fetchFromGitHub, fetchpatch, cmake, pkg-config, openssl, gtest }:
2
3stdenv.mkDerivation rec {
4 pname = "s2geometry";
5 version = "0.9.0";
6
7 src = fetchFromGitHub {
8 owner = "google";
9 repo = "s2geometry";
10 rev = "v${version}";
11 sha256 = "1mx61bnn2f6bd281qlhn667q6yfg1pxzd2js88l5wpkqlfzzhfaz";
12 };
13
14 patches = [
15 # Fix build https://github.com/google/s2geometry/issues/165
16 (fetchpatch {
17 url = "https://github.com/google/s2geometry/commit/a4dddf40647c68cd0104eafc31e9c8fb247a6308.patch";
18 sha256 = "0fp3w4bg7pgf5vv4vacp9g06rbqzhxc2fg6i5appp93q6phiinvi";
19 })
20 ];
21
22 nativeBuildInputs = [ cmake pkg-config ];
23 buildInputs = [ openssl gtest ];
24
25 # Default of C++11 is too low for gtest.
26 # In newer versions of s2geometry this can be done with cmakeFlags.
27 postPatch = ''
28 substituteInPlace CMakeLists.txt --replace "CMAKE_CXX_STANDARD 11" "CMAKE_CXX_STANDARD 14"
29 '';
30
31 meta = with lib; {
32 description = "Computational geometry and spatial indexing on the sphere";
33 homepage = "http://s2geometry.io/";
34 license = licenses.asl20;
35 maintainers = [ maintainers.Thra11 ];
36 platforms = platforms.linux;
37 };
38}