@@ -35,16 +35,20 @@ stdenv.mkDerivation rec {
35
35
nativeBuildInputs = [ perl pkg-config ] ;
36
36
dontDisableStatic = true ;
37
37
38
- # postgis config directory assumes /include /lib from the same root for json-c library
39
- env . NIX_LDFLAGS = "-L${ lib . getLib json_c } /lib" ;
38
+ # Copy our SQL file into the source
39
+ postUnpack = ''
40
+ cp ${ ./tiger_search_path.sql } $sourceRoot/tiger_search_path.sql
41
+ '' ;
40
42
43
+ env . NIX_LDFLAGS = "-L${ lib . getLib json_c } /lib" ;
41
44
42
45
preConfigure = ''
43
46
sed -i 's@/usr/bin/file@${ file } /bin/file@' configure
44
47
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"
45
48
46
49
makeFlags="PERL=${ perl } /bin/perl datadir=$out/share/postgresql pkglibdir=$out/lib bindir=$out/bin docdir=$doc/share/doc/${ pname } "
47
50
'' ;
51
+
48
52
postConfigure = ''
49
53
sed -i "s|@mkdir -p \$(DESTDIR)\$(PGSQL_BINDIR)||g ;
50
54
s|\$(DESTDIR)\$(PGSQL_BINDIR)|$prefix/bin|g
@@ -54,28 +58,33 @@ stdenv.mkDerivation rec {
54
58
" \
55
59
"raster/scripts/python/Makefile";
56
60
mkdir -p $out/bin
57
-
58
- # postgis' build system assumes it is being installed to the same place as postgresql, and looks
59
- # for the postgres binary relative to $PREFIX. We gently support this system using an illusion.
60
61
ln -s ${ postgresql } /bin/postgres $out/bin/postgres
61
62
'' ;
62
63
63
- # create aliases for all commands adding version information
64
- postInstall = ''
65
- # Teardown the illusory postgres used for building; see postConfigure.
66
- rm $out/bin/postgres
64
+ postInstall = ''
65
+ rm $out/bin/postgres
67
66
68
- for prog in $out/bin/*; do # */
69
- ln -s $prog $prog-${ version }
70
- done
67
+ for prog in $out/bin/*; do # */
68
+ ln -s $prog $prog-${ version }
69
+ done
71
70
72
- for file in $out/share/postgresql/extension/postgis_topology*--${ version } .sql; do
73
- sed -i "/SELECT topology.AddToSearchPath('topology');/i SELECT topology.AddToSearchPath('extensions');" "$file"
74
- done
71
+ # Add AddToSearchPath function to tiger_geocoder files
72
+ for file in $out/share/postgresql/extension/postgis_tiger_geocoder*--${ version } .sql; do
73
+ # Insert the function near the start of the file
74
+ sed -i '/Copyright (C) 2010, 2011-2015 Regina Obe and Leo Hsu/r tiger_search_path.sql' "$file"
75
+
76
+ # Add the call to AddToSearchPath just before the install_geocode_settings function
77
+ #sed -i '/CREATE FUNCTION install_geocode_settings()/i SELECT tiger.AddToSearchPath('"'"'extensions'"'"');' "$file"
78
+ done
75
79
76
- mkdir -p $doc/share/doc/postgis
77
- mv doc/* $doc/share/doc/postgis/
78
- '' ;
80
+ # Original topology patching
81
+ for file in $out/share/postgresql/extension/postgis_topology*--${ version } .sql; do
82
+ sed -i "/SELECT topology.AddToSearchPath('topology');/i SELECT topology.AddToSearchPath('extensions');" "$file"
83
+ done
84
+
85
+ mkdir -p $doc/share/doc/postgis
86
+ mv doc/* $doc/share/doc/postgis/
87
+ '' ;
79
88
80
89
passthru . tests . postgis = nixosTests . postgis ;
81
90
@@ -87,4 +96,4 @@ stdenv.mkDerivation rec {
87
96
maintainers = with maintainers ; [ samrose ] ;
88
97
inherit ( postgresql . meta ) platforms ;
89
98
} ;
90
- }
99
+ }
0 commit comments