diff --git a/containers/conduit.nix b/containers/conduit.nix index bca4713..7659f2c 100644 --- a/containers/conduit.nix +++ b/containers/conduit.nix @@ -1,7 +1,7 @@ { nglib, nixpkgs }: nglib.makeSystem { system = "x86_64-linux"; - name = "nixng-gitea"; + name = "synapse"; inherit nixpkgs; config = ({ pkgs, ... }: { diff --git a/containers/heisenbridge.nix b/containers/heisenbridge.nix new file mode 100644 index 0000000..aff2ce7 --- /dev/null +++ b/containers/heisenbridge.nix @@ -0,0 +1,40 @@ +{ nglib, nixpkgs }: +nglib.makeSystem { + system = "x86_64-linux"; + name = "heisenbridge"; + inherit nixpkgs; + config = ({ pkgs, ... }: + { + dumb-init = { + enable = true; + type.services = { }; + }; + + init.services.heisenbridge = { + enabled = true; + shutdownOnExit = true; + script = + let + config = + '' + -l 127.0.0.1 \ + -p 9898 \ + -o @magic_rb:matrix.redalder.org \ + ''; + in + pkgs.writeShellScript "heisenbridge" + '' + REGISTRATION_FILE="/var/lib/registrations/heisenbridge.yaml" + + [ -e "$REGISTRATION_FILE" ] || \ + ${pkgs.heisenbridge}/bin/heisenbridge \ + -c "$REGISTRATION_FILE" \ + ${config} \ + --generate + ${pkgs.heisenbridge}/bin/heisenbridge \ + -c "$REGISTRATION_FILE" \ + ${config} + ''; + }; + }); +} diff --git a/containers/mautrix-facebook.nix b/containers/mautrix-facebook.nix index 4817f95..dff302d 100644 --- a/containers/mautrix-facebook.nix +++ b/containers/mautrix-facebook.nix @@ -1,7 +1,7 @@ { nglib, nixpkgs }: nglib.makeSystem { system = "x86_64-linux"; - name = "nixng-gitea"; + name = "mautrix-facebook"; inherit nixpkgs; config = ({ pkgs, ... }: { diff --git a/flake.nix b/flake.nix index 7b834f7..af994eb 100644 --- a/flake.nix +++ b/flake.nix @@ -48,6 +48,7 @@ baikal = import ./containers/baikal.nix base; conduit = import ./containers/conduit.nix base; mautrix-facebook = import ./containers/mautrix-facebook.nix base; + heisenbridge = import ./containers/heisenbridge.nix base; }; hydraJobs = diff --git a/nomad/regions/homelab-1/job/conduit.hcl b/nomad/regions/homelab-1/job/conduit.hcl index 69da072..e82ca90 100644 --- a/nomad/regions/homelab-1/job/conduit.hcl +++ b/nomad/regions/homelab-1/job/conduit.hcl @@ -95,8 +95,60 @@ EOF } resources { - cpu = 500 - memory = 1024 + cpu = 256 + memory = 256 + } + } + } + + group "heisenbridge" { + count = 1 + + volume "matrix-registrations" { + type = "csi" + source = "matrix-registrations" + read_only = false + + attachment_mode = "file-system" + access_mode = "multi-node-multi-writer" + } + + restart { + attempts = 5 + delay = "5s" + } + + network { + mode = "bridge" + } + + service { + name = "matrix-heisenbridge" + port = "9898" + + connect { + sidecar_service {} + } + } + + task "heisenbridge" { + driver = "containerd-driver" + + volume_mount { + volume = "matrix-registrations" + destination = "/var/lib/registrations" + read_only = false + } + + config { + flake_ref = "${var.flake_ref}#nixngSystems.registrations.config.system.build.toplevel" + flake_sha = var.flake_sha + entrypoint = [ "init" ] + } + + resources { + cpu = 128 + memory = 128 } } } @@ -151,6 +203,11 @@ EOF destination_name = "matrix-mautrix-facebook" local_bind_port = 29319 } + + upstreams { + destination_name = "matrix-heisenbridge" + local_bind_port = 9898 + } } } } @@ -179,7 +236,7 @@ EOF resources { cpu = 2048 - memory = 4096 + memory = 2048 } vault { diff --git a/terraform.tfvars b/terraform.tfvars index cbd1a34..cda2e0a 100644 --- a/terraform.tfvars +++ b/terraform.tfvars @@ -1,6 +1,6 @@ -flake_rev = "e7216e601a70f595893971d8b6f2296f3e867269" +flake_rev = "a27a4c4e78928564383e165b3868aa4f63c451df" flake_ref = "conduit-wip" flake_host = "git+https://git.sr.ht/~magic_rb/cluster" flake_host_alt = "git+https://git.sr.ht/~magic_rb/cluster" -flake_sha = "sha256-RJDAmsZJjBVvbYBG1vP5Se+i3n2IO3E2Y5fWFFmQ7lQ=" +flake_sha = "sha256-7b/9W8mDnqQv0DfH6if0IVbMWR8iEvor7Ktth/WkX9M="