Skip to content

Commit 5fb6ead

Browse files
committed
feat: create a nix package for sfcgal
1 parent b8f2b22 commit 5fb6ead

File tree

4 files changed

+44
-3
lines changed

4 files changed

+44
-3
lines changed

ansible/tasks/stage2/setup-extensions.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
# apt-get install -y --no-install-recommends /tmp/extensions/*.deb
1212
# TODO remove
1313

14+
# The following tasks were moved to stage 2 from the original ansible/tasks/setup-docker.yml
15+
# due to these configurations being required to be applied at this stage, after the database package
16+
# has been installed and before the database is started.
17+
# These tasks are required to be run before the database is started, as they modify the database configuration
1418

1519
- name: pg_cron - set cron.database_name
1620
become: yes
@@ -79,4 +83,4 @@
7983
# file:
8084
# path: /tmp/extensions
8185
# state: absent
82-
# TODO remove
86+
# TODO remove extensions are already packaged in the nix build

flake.nix

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,10 @@
5757
#(import ./nix/overlays/gdal-small.nix)
5858

5959
];
60+
6061
};
6162

63+
sfcgal = pkgs.callPackage ./nix/ext/sfcgal/sfcgal.nix { };
6264

6365
# FIXME (aseipp): pg_prove is yet another perl program that needs
6466
# LOCALE_ARCHIVE set in non-NixOS environments. upstream this. once that's done, we
@@ -139,6 +141,7 @@
139141
#this var is a convenience setting to import the orioledb patched version of postgresql
140142
postgresql_orioledb_16 = oriole_pkgs.postgresql_orioledb_16;
141143

144+
142145
# Create a 'receipt' file for a given postgresql package. This is a way
143146
# of adding a bit of metadata to the package, which can be used by other
144147
# tools to inspect what the contents of the install are: the PSQL
@@ -400,6 +403,8 @@
400403
#psql_16 = makePostgres "16";
401404
#psql_orioledb_16 = makeOrioleDbPostgres "16_23" postgresql_orioledb_16;
402405
pg_prove = pg_prove;
406+
sfcgal = sfcgal;
407+
403408
# Start a version of the server.
404409
start-server =
405410
let

nix/ext/postgis.nix

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@
1313
, libiconv
1414
, pcre2
1515
, nixosTests
16+
, callPackage
1617
}:
1718

1819
let
1920
gdal = gdalMinimal;
21+
sfcgal = callPackage ./sfcgal/sfcgal.nix { };
2022
in
2123
stdenv.mkDerivation rec {
2224
pname = "postgis";
@@ -29,7 +31,7 @@ stdenv.mkDerivation rec {
2931
sha256 = "sha256-miohnaAFoXMKOdGVmhx87GGbHvsAm2W+gP/CW60pkGg=";
3032
};
3133

32-
buildInputs = [ libxml2 postgresql geos proj gdal json_c protobufc pcre2.dev ]
34+
buildInputs = [ libxml2 postgresql geos proj gdal json_c protobufc pcre2.dev sfcgal ]
3335
++ lib.optional stdenv.isDarwin libiconv;
3436
nativeBuildInputs = [ perl pkg-config ];
3537
dontDisableStatic = true;
@@ -40,7 +42,7 @@ stdenv.mkDerivation rec {
4042

4143
preConfigure = ''
4244
sed -i 's@/usr/bin/file@${file}/bin/file@' configure
43-
configureFlags="--datadir=$out/share/postgresql --datarootdir=$out/share/postgresql --bindir=$out/bin --docdir=$doc/share/doc/${pname} --with-gdalconfig=${gdal}/bin/gdal-config --with-jsondir=${json_c.dev} --disable-extension-upgrades-install"
45+
configureFlags="--datadir=$out/share/postgresql --datarootdir=$out/share/postgresql --bindir=$out/bin --docdir=$doc/share/doc/${pname} --with-gdalconfig=${gdal}/bin/gdal-config --with-jsondir=${json_c.dev} --disable-extension-upgrades-install --with-sfcgal"
4446
4547
makeFlags="PERL=${perl}/bin/perl datadir=$out/share/postgresql pkglibdir=$out/lib bindir=$out/bin docdir=$doc/share/doc/${pname}"
4648
'';

nix/ext/sfcgal/sfcgal.nix

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{ lib, stdenv, fetchFromGitLab, cgal, cmake, pkg-config, gmp, mpfr, boost }:
2+
3+
stdenv.mkDerivation rec {
4+
pname = "sfcgal";
5+
version = "61f3b08ade49493b56c6bafa98c7c1f84addbc10";
6+
7+
src = fetchFromGitLab {
8+
owner = "sfcgal";
9+
repo = "SFCGAL";
10+
rev = "${version}";
11+
hash = "sha256-nKSqiFyMkZAYptIeShb1zFg9lYSny3kcGJfxdeTFqxw=";
12+
};
13+
14+
nativeBuildInputs = [ cmake pkg-config cgal gmp mpfr boost ];
15+
16+
cmakeFlags = [ "-DCGAL_DIR=${cgal}" "-DCMAKE_PREFIX_PATH=${cgal}" ];
17+
18+
19+
postPatch = ''
20+
substituteInPlace sfcgal.pc.in \
21+
--replace '$'{prefix}/@CMAKE_INSTALL_LIBDIR@ @CMAKE_INSTALL_FULL_LIBDIR@
22+
'';
23+
24+
meta = with lib; {
25+
description = "A wrapper around CGAL that intents to implement 2D and 3D operations on OGC standards models";
26+
homepage = "https://sfcgal.gitlab.io/SFCGAL/";
27+
license = licenses.gpl2Only;
28+
maintainers = with maintainers; [ samrose ];
29+
};
30+
}

0 commit comments

Comments
 (0)