PostgreSQL: Difference between revisions

imported>Malteneuss
(Add simplified getting started section)
imported>Malteneuss
m (Fix indentations)
Line 13: Line 13:
     authentication = pkgs.lib.mkOverride 10 ''
     authentication = pkgs.lib.mkOverride 10 ''
       #type database  DBuser  auth-method
       #type database  DBuser  auth-method
       local all             all           trust
       local all       all     trust
     '';
     '';
   };
   };
Line 19: Line 19:
</syntaxhighlight>
</syntaxhighlight>


This will setup Postgresql with a database "mydatabase" and let every local Linux user have access to it without a password through a "local" Unix socket "/var/lib/postgresql" (TCP/IP is disabled by default because it's less performant and less secure).
This will setup Postgresql with a default DB superuser/admin "postgres", a database "mydatabase" and let every DB user have access to it without a password through a "local" Unix socket "/var/lib/postgresql" (TCP/IP is disabled by default because it's less performant and less secure).


* [https://search.nixos.org/options?query=services.postgresql Available NixOS Postgresql service options]
* [https://search.nixos.org/options?query=services.postgresql Available NixOS Postgresql service options]
Line 35: Line 35:
   authentication = pkgs.lib.mkOverride 10 ''
   authentication = pkgs.lib.mkOverride 10 ''
     #...
     #...
     #type database DBuser origin-address auth-method
     #type database DBuser origin-address auth-method
     # ipv4
     # ipv4
     host   all             all         127.0.0.1/32   trust
     host all     all     127.0.0.1/32   trust
     # ipv4
     # ipv6
     host   all             all           ::1/128           trust
     host all       all     ::1/128       trust
   '';
   '';
   initialScript = pkgs.writeText "backend-initScript" ''
   initialScript = pkgs.writeText "backend-initScript" ''