diff --git a/nixos/modules/services/databases/postgresql.nix b/nixos/modules/services/databases/postgresql.nix index 37d44e30fbe..7ff899970cc 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 00000000000..749d7857a13 --- /dev/null +++ b/nixos/tests/initdb.nix @@ -0,0 +1,26 @@ +let + pkgs = import { }; +in +with import { 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