lol
at 25.11-pre 60 lines 1.5 kB view raw
1{ 2 cmake, 3 fetchFromGitHub, 4 h3_4, 5 lib, 6 postgresql, 7 postgresqlBuildExtension, 8 postgresqlTestExtension, 9 stdenv, 10}: 11 12postgresqlBuildExtension (finalAttrs: { 13 pname = "h3-pg"; 14 version = "4.2.2"; 15 16 src = fetchFromGitHub { 17 owner = "zachasme"; 18 repo = "h3-pg"; 19 tag = "v${finalAttrs.version}"; 20 hash = "sha256-2xp9gssPMTroLT/1Me0VWvtIPyouIk9MW0Rp13uYBEw="; 21 }; 22 23 postPatch = 24 '' 25 substituteInPlace CMakeLists.txt \ 26 --replace-fail "add_subdirectory(cmake/h3)" "include_directories(${lib.getDev h3_4}/include/h3)" 27 '' 28 + lib.optionalString stdenv.hostPlatform.isDarwin '' 29 substituteInPlace cmake/AddPostgreSQLExtension.cmake \ 30 --replace-fail "INTERPROCEDURAL_OPTIMIZATION TRUE" "" 31 ''; 32 33 nativeBuildInputs = [ 34 cmake 35 ]; 36 37 buildInputs = [ 38 h3_4 39 ]; 40 41 passthru.tests.extension = postgresqlTestExtension { 42 inherit (finalAttrs) finalPackage; 43 withPackages = [ "postgis" ]; 44 sql = '' 45 CREATE EXTENSION h3; 46 CREATE EXTENSION h3_postgis CASCADE; 47 48 SELECT h3_lat_lng_to_cell(POINT('37.3615593,-122.0553238'), 5); 49 SELECT ST_NPoints(h3_cell_to_boundary_geometry('8a63a9a99047fff')); 50 ''; 51 }; 52 53 meta = { 54 description = "PostgreSQL bindings for H3, a hierarchical hexagonal geospatial indexing system"; 55 homepage = "https://github.com/zachasme/h3-pg"; 56 license = lib.licenses.asl20; 57 maintainers = [ ]; 58 inherit (postgresql.meta) platforms; 59 }; 60})