modules: services: add postgresql
Enable the service itself in other modules when needed, but pin the package in a single place.
This commit is contained in:
parent
eba977b582
commit
99c33cd7ad
|
@ -20,6 +20,7 @@
|
||||||
./pirate.nix
|
./pirate.nix
|
||||||
./podgrab.nix
|
./podgrab.nix
|
||||||
./postgresql-backup.nix
|
./postgresql-backup.nix
|
||||||
|
./postgresql.nix
|
||||||
./quassel.nix
|
./quassel.nix
|
||||||
./rss-bridge.nix
|
./rss-bridge.nix
|
||||||
./sabnzbd.nix
|
./sabnzbd.nix
|
||||||
|
|
|
@ -81,6 +81,7 @@ in
|
||||||
users.groups.drone = { };
|
users.groups.drone = { };
|
||||||
|
|
||||||
services.postgresql = {
|
services.postgresql = {
|
||||||
|
enable = true;
|
||||||
ensureDatabases = [ "drone" ];
|
ensureDatabases = [ "drone" ];
|
||||||
ensureUsers = [{
|
ensureUsers = [{
|
||||||
name = "drone";
|
name = "drone";
|
||||||
|
|
|
@ -63,7 +63,6 @@ in
|
||||||
config = lib.mkIf cfg.enable {
|
config = lib.mkIf cfg.enable {
|
||||||
services.postgresql = {
|
services.postgresql = {
|
||||||
enable = true;
|
enable = true;
|
||||||
package = pkgs.postgresql_12;
|
|
||||||
initialScript = pkgs.writeText "synapse-init.sql" ''
|
initialScript = pkgs.writeText "synapse-init.sql" ''
|
||||||
CREATE ROLE "matrix-synapse" WITH LOGIN PASSWORD 'synapse';
|
CREATE ROLE "matrix-synapse" WITH LOGIN PASSWORD 'synapse';
|
||||||
CREATE DATABASE "matrix-synapse" WITH OWNER "matrix-synapse"
|
CREATE DATABASE "matrix-synapse" WITH OWNER "matrix-synapse"
|
||||||
|
|
18
modules/services/postgresql.nix
Normal file
18
modules/services/postgresql.nix
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
{ config, lib, pkgs, ... }:
|
||||||
|
let
|
||||||
|
cfg = config.my.services.postgresql;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
options.my.services.postgresql = with lib; {
|
||||||
|
enable = my.mkDisableOption "postgres configuration";
|
||||||
|
};
|
||||||
|
|
||||||
|
config = lib.mkMerge [
|
||||||
|
# Let other services enable postgres when they need it
|
||||||
|
(lib.mkIf cfg.enable {
|
||||||
|
services.postgresql = {
|
||||||
|
package = pkgs.postgresql_12;
|
||||||
|
};
|
||||||
|
})
|
||||||
|
];
|
||||||
|
}
|
Loading…
Reference in a new issue