update matrix data dir and minor update to registration config

This commit is contained in:
Mike Cugini 2021-01-10 21:10:33 -05:00
parent 7acda11428
commit 50cf829d0e
2 changed files with 14 additions and 12 deletions

View File

@ -1,12 +1,12 @@
# adapted from https://nixos.org/manual/nixos/stable/index.html#module-services-matrix # adapted from https://nixos.org/manual/nixos/stable/index.html#module-services-matrix
{ modulesPath, config, lib, pkgs, ... }: { modulesPath, config, lib, pkgs, ... }:
let let
matrix-registration = import ../../matrix-registration/default.nix; matrix-registration = import ../../matrix-registration/default.nix;
storage-device = "/dev/disk/by-id/scsi-0DO_Volume_matrix-storage"; storage-device = "/dev/disk/by-id/scsi-0DO_Volume_matrix-storage";
storage-dir = "/opt/matrix-data"; storage-dir = "/srv/matrix-data";
matrix-reg-dir = "${storage-dir}/matrix-registration"; matrix-reg-dir = "${storage-dir}/matrix-registration";
matrix-reg-key = (builtins.readFile ./matrix_reg_key); matrix-reg-key = (builtins.readFile ./matrix_reg_key);
fqdn = fqdn =
let let
join = hostName: domain: hostName + lib.optionalString (domain != null) ".${domain}"; join = hostName: domain: hostName + lib.optionalString (domain != null) ".${domain}";
in join config.networking.hostName config.networking.domain; in join config.networking.hostName config.networking.domain;
@ -23,7 +23,7 @@ in {
(builtins.readFile "/home/mike/.ssh/id_mops.pub") (builtins.readFile "/home/mike/.ssh/id_mops.pub")
]; ];
### app specific config ### app specific config
# mount DigitalOcean volume for use by postgres # mount DigitalOcean volume for use by postgres
fileSystems."${storage-dir}" = { fileSystems."${storage-dir}" = {
@ -35,7 +35,7 @@ in {
domain = "waffle.farm"; domain = "waffle.farm";
}; };
services.postgresql = { services.postgresql = {
enable = true; enable = true;
dataDir = "${storage-dir}/db"; dataDir = "${storage-dir}/db";
@ -128,6 +128,7 @@ in {
server_name = config.networking.domain; server_name = config.networking.domain;
registration_shared_secret = matrix-reg-key; registration_shared_secret = matrix-reg-key;
extraConfig = '' extraConfig = ''
allow_public_rooms_over_federation: true
auto_join_rooms: auto_join_rooms:
- "#cryptic-chat:waffle.farm" - "#cryptic-chat:waffle.farm"
''; '';
@ -162,6 +163,7 @@ in {
systemd.services.matrix-registration = let systemd.services.matrix-registration = let
configFile = pkgs.writeText "matrix-reg-config.yaml" '' configFile = pkgs.writeText "matrix-reg-config.yaml" ''
server_location: 'https://matrix.waffle.farm:443' server_location: 'https://matrix.waffle.farm:443'
base_url: 'waffle.farm'
server_name: 'waffle.farm' server_name: 'waffle.farm'
shared_secret: '${matrix-reg-key}' shared_secret: '${matrix-reg-key}'
riot_instance: 'chat.waffle.farm' riot_instance: 'chat.waffle.farm'

View File

@ -2,13 +2,6 @@ data "digitalocean_image" "nixos_base" {
name = "nixos-base" name = "nixos-base"
} }
resource "digitalocean_volume" "matrix" {
region = "nyc3"
name = "matrix-storage"
size = 10
initial_filesystem_type = "ext4"
}
resource "digitalocean_droplet" "matrix-0" { resource "digitalocean_droplet" "matrix-0" {
name = "matrix-0" name = "matrix-0"
@ -19,6 +12,13 @@ resource "digitalocean_droplet" "matrix-0" {
ssh_keys = [data.digitalocean_ssh_key.mops.id] ssh_keys = [data.digitalocean_ssh_key.mops.id]
} }
resource "digitalocean_volume" "matrix" {
region = "nyc3"
name = "matrix-storage"
size = 10
initial_filesystem_type = "ext4"
}
resource "digitalocean_volume_attachment" "matrix" { resource "digitalocean_volume_attachment" "matrix" {
droplet_id = digitalocean_droplet.matrix-0.id droplet_id = digitalocean_droplet.matrix-0.id
volume_id = digitalocean_volume.matrix.id volume_id = digitalocean_volume.matrix.id