Factor out postgresql
This commit is contained in:
parent
2826bb8ad0
commit
9c1331075a
|
@ -45,6 +45,7 @@
|
|||
passwordFile = config.sops.secrets."borg-password".path;
|
||||
sshKey = config.sops.secrets."borg-ssh-key".path;
|
||||
};
|
||||
postgresql.backup = true;
|
||||
};
|
||||
config = {
|
||||
setupGrub = false;
|
||||
|
@ -117,15 +118,6 @@
|
|||
extraConfigFiles = [ config.sops.secrets."matrix-secrets.yaml".path ];
|
||||
};
|
||||
|
||||
# Backup postgres
|
||||
services.postgresqlBackup = {
|
||||
enable = true;
|
||||
compression = "none";
|
||||
backupAll = true;
|
||||
# Every monring at 4 AM
|
||||
startAt = "*-*-* 4:00:00";
|
||||
};
|
||||
|
||||
# Install our utilties
|
||||
environment.systemPackages = with pkgs; [ matrix-synapse-tools.synadm ];
|
||||
|
||||
|
|
|
@ -55,6 +55,7 @@
|
|||
passwordFile = config.sops.secrets."borg-password".path;
|
||||
sshKey = config.sops.secrets."borg-ssh-key".path;
|
||||
};
|
||||
postgresql.backup = true;
|
||||
};
|
||||
config = {
|
||||
setupGrub = false;
|
||||
|
@ -97,14 +98,6 @@
|
|||
root = "/var/www/pack.forward-progress.net";
|
||||
};
|
||||
|
||||
# Backup postgres, as used by matrix
|
||||
services.postgresqlBackup = {
|
||||
enable = true;
|
||||
compression = "none";
|
||||
backupAll = true;
|
||||
startAt = "OnCalendar=00/2:00";
|
||||
};
|
||||
|
||||
# Setup the gitlab runners
|
||||
services.gitlab-runner = let
|
||||
nix-shared = with lib; {
|
||||
|
|
|
@ -25,6 +25,7 @@ in {
|
|||
./services/matrix.nix
|
||||
./services/ipfs.nix
|
||||
./services/resolved.nix
|
||||
./services/postgresql.nix
|
||||
];
|
||||
|
||||
options = with lib;
|
||||
|
@ -86,6 +87,10 @@ in {
|
|||
enable = mkEnableOption "nginx";
|
||||
acme = mkEnableOption "ACME Integration";
|
||||
};
|
||||
postgresql = {
|
||||
enable = mkEnableOption "postgresql";
|
||||
backup = mkEnableOption "postgresqlbackup";
|
||||
};
|
||||
# Matrix
|
||||
matrix = {
|
||||
enable = mkEnableOption "matrix";
|
||||
|
|
|
@ -1,14 +1,15 @@
|
|||
{ config, lib, pkgs, inputs, ... }:
|
||||
{ config, lib, pkgs, inputs, ... }@orig:
|
||||
let nathan = config.nathan;
|
||||
in with lib; {
|
||||
config = mkMerge [
|
||||
(mkIf nathan.services.matrix.enable {
|
||||
# Enable nginx
|
||||
nathan.services.nginx.enable = true;
|
||||
# Enable postresql
|
||||
nathan.services.postgresql = { enable = true; };
|
||||
services = {
|
||||
# Setup postgres
|
||||
postgresql = {
|
||||
enable = true;
|
||||
initialScript = pkgs.writeText "synapse-init.sql" ''
|
||||
CREATE ROLE "matrix-synapse" WITH LOGIN PASSWORD 'matrix-synapse';
|
||||
CREATE DATABASE "synapse" WITH OWNER "synapse"
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
let nathan = config.nathan;
|
||||
in with lib; {
|
||||
config = mkMerge [
|
||||
(mkIf nathan.services.postgresql.enable {
|
||||
services.postgresql = { enable = true; };
|
||||
})
|
||||
(mkIf
|
||||
(nathan.services.postgresql.enable && nathan.services.postgresql.backup) {
|
||||
# Backup postgres
|
||||
services.postgresqlBackup = {
|
||||
enable = true;
|
||||
compression = "zstd";
|
||||
compressionLevel = 6;
|
||||
backupAll = true;
|
||||
# Every morning at 4 AM
|
||||
startAt = "*-*-* 4:00:00";
|
||||
};
|
||||
})
|
||||
];
|
||||
}
|
Loading…
Reference in New Issue