about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--nixos/modules/services/databases/postgresql.nix4
-rw-r--r--nixos/tests/initdb.nix26
2 files changed, 30 insertions, 0 deletions
diff --git a/nixos/modules/services/databases/postgresql.nix b/nixos/modules/services/databases/postgresql.nix
index 37d44e30fbeb..7ff899970ccd 100644
--- a/nixos/modules/services/databases/postgresql.nix
+++ b/nixos/modules/services/databases/postgresql.nix
@@ -251,6 +251,10 @@ in
 
     environment.systemPackages = [ postgresql ];
 
+    environment.pathsToLink = [
+     "/share/postgresql"
+    ];
+
     systemd.services.postgresql =
       { description = "PostgreSQL Server";
 
diff --git a/nixos/tests/initdb.nix b/nixos/tests/initdb.nix
new file mode 100644
index 000000000000..749d7857a134
--- /dev/null
+++ b/nixos/tests/initdb.nix
@@ -0,0 +1,26 @@
+let
+  pkgs = import <nixpkgs> { };
+in
+with import <nixpkgs/nixos/lib/testing.nix> { inherit pkgs; system = builtins.currentSystem; };
+with pkgs.lib;
+
+makeTest {
+    name = "pg-initdb";
+
+    machine = {...}:
+      {
+        documentation.enable = false;
+        services.postgresql.enable = true;
+        services.postgresql.package = pkgs.postgresql_9_6;
+        environment.pathsToLink = [
+          "/share/postgresql"
+        ];
+      };
+
+    testScript = ''
+      $machine->start;
+      $machine->succeed("sudo -u postgres initdb -D /tmp/testpostgres2");
+      $machine->shutdown;
+    '';
+
+  }
\ No newline at end of file