help-guix
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How do I correctly relocate PostGIS control files?


From: Gary Johnson
Subject: How do I correctly relocate PostGIS control files?
Date: Mon, 02 Nov 2020 17:40:09 -0500

Hi Guix,

I use Postgresql with PostGIS extensively for geospatial software
development. While the default set of postgresql (v10.13) and postgis
(v3.0.2) packages in Guix have worked well for me for some time, I am
now in need of upgrading to the latest version in order to utilize newer
functionality in the database software.

To do this, I created a derivative package for postgresql (v13.0) as
well as a derivative postgis package that uses the new postgresql
package as an input. These packages compile and install correctly with
"guix package -i".

Here's my code:

;;=============================================================================================================================

(define-module (my-packages postgresql-13)
  #:use-module ((guix packages)          #:select (package origin base32))
  #:use-module ((guix download)          #:select (url-fetch))
  #:use-module ((gnu packages databases) #:select (postgresql))
  #:use-module ((gnu packages geo)       #:select (postgis gdal geos proj))
  #:use-module ((gnu packages image)     #:select (giflib))
  #:use-module ((gnu packages web)       #:select (json-c))
  #:use-module ((gnu packages image)     #:select (libjpeg-turbo))
  #:use-module ((gnu packages xml)       #:select (libxml2))
  #:use-module ((gnu packages pcre)      #:select (pcre)))

(define-public postgresql-13
  (package
   (inherit postgresql)
   (name "postgresql")
   (version "13.0")
   (source (origin
            (method url-fetch)
            (uri (string-append "https://ftp.postgresql.org/pub/source/v";
                                version "/postgresql-" version ".tar.bz2"))
            (sha256
             (base32
              "15i2b7m9a9430idqdgvrcyx66cpxz0v2d81nfqcm8ss3inz51rw0"))))))

(define-public postgis-for-postgresql-13
  (package
   (inherit postgis)
   (name "postgis")
   (version "3.0.2")
   (inputs
    `(("gdal" ,gdal)
      ("geos" ,geos)
      ("giflib" ,giflib)
      ("json-c" ,json-c)
      ("libjpeg" ,libjpeg-turbo)
      ("libxml2" ,libxml2)
      ("pcre" ,pcre)
      ("postgresql" ,postgresql-13)
      ("proj" ,proj)))))

;;=============================================================================================================================

Next, I moved to my OS config.scm file to set up the Postgresql Shepherd
service and add PostGIS as an extension package for the DB, which should
make its control files available to Postgresql at runtime.

Here are the relevant sections:

;;=============================================================================================================================

(use-modules ...             
             ((gnu services databases)    #:select (postgresql-service-type 
postgresql-configuration postgresql-config-file))
             ((my-packages postgresql-13) #:select (postgresql-13 
postgis-for-postgresql-13)))

(operating-system
 ...
 (packages (cons* ...
                  postgresql-13 postgis-for-postgresql-13 ; psql, raster2pgsql, 
shp2pgsql, etc.
                  %base-packages))
 (services (cons* ...
                  (service postgresql-service-type (postgresql-configuration
                                                    (postgresql postgresql-13)
                                                    (extension-packages (list 
postgis-for-postgresql-13))
                                                    (config-file 
(postgresql-config-file
                                                                  (hba-file 
my-postgres-hba)
                                                                  (extra-config 
'(("max_worker_processes" "12")
                                                                                
  ("max_parallel_workers" "40")
                                                                                
  ("max_parallel_maintenance_workers" "8")
                                                                                
  ("max_parallel_workers_per_gather" "4")
                                                                                
  ("parallel_leader_participation" "on")))))))
                  %desktop-services)))

;;=============================================================================================================================

This compiles and installs successfully with "guix system reconfigure".

However, when I connect to the Postgresql server with "psql -U postgres"
and attempt to add the PostGIS extension to a database, I get the
dreaded "could not open extension control file" error:

;;=============================================================================================================================

db=# create extension postgis;
ERROR:  could not open extension control file
    
"/gnu/store/8m48v5132qpmxim9s4g9vca59qgay2d9-postgresql-13.0/share/extension/postgis.control":
 No such file or directory

;;=============================================================================================================================

This error does not occur when using the stock postgresql (v10.13) and
postgis (v3.0.2) packages that come with the current Guix, so something
is going wrong with the "extension-packages" code from my config.scm's
"postgresql-configuration" record.

I am very much hoping that one of the Guix maintainers can look into
this and help me resolve the issue as I suspect it may be affecting any
user that wants to use a different version of Postgres.

Thanks in advance,
  Gary

-- 
GPG Key ID: 7BC158ED
Use `gpg --search-keys lambdatronic' to find me
Protect yourself from surveillance: https://emailselfdefense.fsf.org
=======================================================================
()  ascii ribbon campaign - against html e-mail
/\  www.asciiribbon.org   - against proprietary attachments

Please avoid sending me MS-Office attachments.
See http://www.gnu.org/philosophy/no-word-attachments.html



reply via email to

[Prev in Thread] Current Thread [Next in Thread]