Merge #17838: postgresql: Fix use with extensions

+63 -1
+3 -1
nixos/modules/services/databases/postgresql.nix
··· 11 11 if cfg.extraPlugins == [] then pg 12 12 else pkgs.buildEnv { 13 13 name = "postgresql-and-plugins-${(builtins.parseDrvName pg.name).version}"; 14 - paths = [ pg ] ++ cfg.extraPlugins; 14 + paths = [ pg pg.lib ] ++ cfg.extraPlugins; 15 + buildInputs = [ pkgs.makeWrapper ]; 15 16 postBuild = 16 17 '' 17 18 mkdir -p $out/bin 18 19 rm $out/bin/{pg_config,postgres,pg_ctl} 19 20 cp --target-directory=$out/bin ${pg}/bin/{postgres,pg_config,pg_ctl} 21 + wrapProgram $out/bin/postgres --set NIX_PGLIBDIR $out/lib 20 22 ''; 21 23 }; 22 24
+30
nixos/tests/postgis.nix
··· 1 + import ./make-test.nix ({ pkgs, ...} : { 2 + name = "postgis"; 3 + meta = with pkgs.stdenv.lib.maintainers; { 4 + maintainers = [ lsix ]; 5 + }; 6 + 7 + nodes = { 8 + master = 9 + { pkgs, config, ... }: 10 + 11 + { 12 + services.postgresql = let mypg = pkgs.postgresql95; in { 13 + enable = true; 14 + package = mypg; 15 + extraPlugins = [ (pkgs.postgis.override { postgresql = mypg; }).v_2_2_1 ]; 16 + initialScript = pkgs.writeText "postgresql-init.sql" 17 + '' 18 + CREATE ROLE postgres WITH superuser login createdb; 19 + ''; 20 + }; 21 + }; 22 + }; 23 + 24 + testScript = '' 25 + startAll; 26 + $master->waitForUnit("postgresql"); 27 + $master->sleep(10); # Hopefully this is long enough!! 28 + $master->succeed("sudo -u postgres psql -c 'CREATE EXTENSION postgis;'"); 29 + ''; 30 + })
+1
pkgs/servers/sql/postgresql/default.nix
··· 33 33 [ (if lib.versionAtLeast version "9.4" then ./disable-resolve_symlinks-94.patch else ./disable-resolve_symlinks.patch) 34 34 ./less-is-more.patch 35 35 ./hardcode-pgxs-path.patch 36 + ./specify_pkglibdir_at_runtime.patch 36 37 ]; 37 38 38 39 installTargets = [ "install-world" ];
+29
pkgs/servers/sql/postgresql/specify_pkglibdir_at_runtime.patch
··· 1 + diff -ur postgresql-9.5.3-orig/src/port/path.c postgresql-9.5.3/src/port/path.c 2 + --- postgresql-9.5.3-orig/src/port/path.c 2016-05-09 22:50:23.000000000 +0200 3 + +++ postgresql-9.5.3/src/port/path.c 2016-08-29 22:44:10.507377613 +0200 4 + @@ -714,7 +714,11 @@ 5 + void 6 + get_lib_path(const char *my_exec_path, char *ret_path) 7 + { 8 + - make_relative_path(ret_path, LIBDIR, PGBINDIR, my_exec_path); 9 + + char const * const nix_pglibdir = getenv("NIX_PGLIBDIR"); 10 + + if(nix_pglibdir == NULL) 11 + + make_relative_path(ret_path, LIBDIR, PGBINDIR, my_exec_path); 12 + + else 13 + + make_relative_path(ret_path, nix_pglibdir, PGBINDIR, my_exec_path); 14 + } 15 + 16 + /* 17 + @@ -723,7 +727,11 @@ 18 + void 19 + get_pkglib_path(const char *my_exec_path, char *ret_path) 20 + { 21 + - make_relative_path(ret_path, PKGLIBDIR, PGBINDIR, my_exec_path); 22 + + char const * const nix_pglibdir = getenv("NIX_PGLIBDIR"); 23 + + if(nix_pglibdir == NULL) 24 + + make_relative_path(ret_path, PKGLIBDIR, PGBINDIR, my_exec_path); 25 + + else 26 + + make_relative_path(ret_path, nix_pglibdir, PGBINDIR, my_exec_path); 27 + } 28 + 29 + /*