# adapted from https://nixos.org/manual/nixos/stable/index.html#module-services-matrix { modulesPath, config, lib, pkgs, ... }: let secrets = builtins.fromJSON (builtins.readFile ./secrets.json); in { imports = [ "${toString modulesPath}/virtualisation/digital-ocean-image.nix" ]; nixpkgs.config = { packageOverrides = pkgs: { pantalaimon = pkgs.pantalaimon.override { enableDbusUi = false; }; }; }; environment.systemPackages = [ pkgs.jq pkgs.pantalaimon pkgs.olm ]; services.openssh.enable = true; networking.firewall.allowedTCPPorts = [ 22 80 443 ]; users.users.root.openssh.authorizedKeys.keys = [ (builtins.readFile "/home/mike/.ssh/id_mops.pub") ]; ### app specific config users.users.matterbridge = { createHome = true; isNormalUser = false; isSystemUser = true; }; users.users.pantalaimon = { createHome = true; isNormalUser = true; }; systemd.services.pantalaimon = let pantalaimon-config-file = pkgs.writeText "pantalaimon.conf" '' [Default] LogLevel = Debug [local-matrix] Homeserver = https://matrix.waffle.farm ListenAddress = localhost ListenPort = 8009 Notifications = off UseKeyring = no IgnoreVerification = True SSL=false ''; in { enable = true; description = "pantalaimon daemon"; wantedBy = [ "multi-user.target" ]; serviceConfig = { Type = "simple"; ExecStart = "${pkgs.pantalaimon}/bin/pantalaimon -c ${pantalaimon-config-file} --data-path /home/pantalaimon "; User = "pantalaimon"; Restart = "always"; }; }; nixpkgs.overlays = [ (final: prev: { matterbridge = prev.matterbridge.overrideAttrs (oldAttrs: rec { version = "1.26.0"; src = prev.fetchFromGitHub { owner = "42wim"; repo = "matterbridge"; rev = "v${version}"; sha256 = "sha256-APlnJUu/ttK/S2AxO+SadU2ttmEnU+js/3GUf3x0aSQ="; }; }); }) ]; services.matterbridge = let channels = [ "a-rusty-venture" "anime" "bossin_around" "bot-test" "bridge-test" "cryptic-bunker" "cryptic-chat" "cryptic-net-public" "dumbathon" "europe" "generic-gaming" "get-rich-fast" "gnv" "golang" "jerbs" "main_linux" "minecraft" "moooooooovies_shows" "nyc" "omg-berks" "sf" "smersh" "to-the-moon-and-back" "travel" "tunes" ]; gateways = lib.strings.concatMapStrings (channel: '' [[gateway]] name="${channel}-gateway" enable=true [[gateway.inout]] account="matrix.wafflefarm" channel="#${channel}:waffle.farm" [[gateway.inout]] account="slack.cryptic" channel="${channel}" [[gateway.inout]] account="discord.cryptic" channel="${channel}" '') channels; config-file = pkgs.writeText "matterbridge.toml" '' [discord.cryptic] Token="${secrets.matterbridge.discord.token}" Server="${secrets.matterbridge.discord.server}" RemoteNickFormat="{NICK} [{PROTOCOL}]: " AutoWebhooks=true PreserveThreading=true [slack.cryptic] Token="${secrets.matterbridge.slack.token}" RemoteNickFormat="{NICK} [{PROTOCOL}]: " PreserveThreading=true [matrix.wafflefarm] Server="http://localhost:8009" Login="${secrets.matterbridge.matrix.username}" Password="${secrets.matterbridge.matrix.password}" RemoteNickFormat="{NICK} [{PROTOCOL}]: " SpoofUsername=true PreserveThreading=true KeepQuotedReply=false ${gateways} ''; in { enable = true; configPath = "${config-file}"; }; }