feat(matrix): add conduit as default matrix server

This commit is contained in:
Felix Schröter 2023-07-29 18:00:49 +02:00
parent c73c212cd6
commit 1b7b6596a8
Signed by: felschr
GPG key ID: 671E39E6744C807D
6 changed files with 202 additions and 9 deletions

View file

@ -22,6 +22,58 @@
"type": "github" "type": "github"
} }
}, },
"conduit": {
"inputs": {
"crane": "crane",
"fenix": "fenix",
"flake-utils": [
"flake-utils"
],
"nixpkgs": [
"nixpkgs-unstable"
]
},
"locked": {
"lastModified": 1690642842,
"narHash": "sha256-Oy6bCEHHfZNrv8LX9UQ0iO57xAYSWUK/cA71QarK5os=",
"owner": "famedly",
"repo": "conduit",
"rev": "2b4a6c96eee95c5efe43803d247469fd6d67075f",
"type": "gitlab"
},
"original": {
"owner": "famedly",
"repo": "conduit",
"type": "gitlab"
}
},
"crane": {
"inputs": {
"flake-compat": "flake-compat",
"flake-utils": [
"conduit",
"flake-utils"
],
"nixpkgs": [
"conduit",
"nixpkgs"
],
"rust-overlay": "rust-overlay"
},
"locked": {
"lastModified": 1688772518,
"narHash": "sha256-ol7gZxwvgLnxNSZwFTDJJ49xVY5teaSvF7lzlo3YQfM=",
"owner": "ipetkov",
"repo": "crane",
"rev": "8b08e96c9af8c6e3a2b69af5a7fa168750fcf88e",
"type": "github"
},
"original": {
"owner": "ipetkov",
"repo": "crane",
"type": "github"
}
},
"darwin": { "darwin": {
"inputs": { "inputs": {
"nixpkgs": [ "nixpkgs": [
@ -46,7 +98,7 @@
}, },
"deploy-rs": { "deploy-rs": {
"inputs": { "inputs": {
"flake-compat": "flake-compat", "flake-compat": "flake-compat_2",
"nixpkgs": [ "nixpkgs": [
"nixpkgs" "nixpkgs"
], ],
@ -68,14 +120,36 @@
"type": "github" "type": "github"
} }
}, },
"fenix": {
"inputs": {
"nixpkgs": [
"conduit",
"nixpkgs"
],
"rust-analyzer-src": "rust-analyzer-src"
},
"locked": {
"lastModified": 1689488573,
"narHash": "sha256-diVASflKCCryTYv0djvMnP2444mFsIG0ge5pa7ahauQ=",
"owner": "nix-community",
"repo": "fenix",
"rev": "39096fe3f379036ff4a5fa198950b8e79defe939",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "fenix",
"type": "github"
}
},
"flake-compat": { "flake-compat": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1668681692, "lastModified": 1673956053,
"narHash": "sha256-Ht91NGdewz8IQLtWZ9LCeNXMSXHUss+9COoqu6JLmXU=", "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=",
"owner": "edolstra", "owner": "edolstra",
"repo": "flake-compat", "repo": "flake-compat",
"rev": "009399224d5e398d03b22badca40a37ac85412a1", "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -100,6 +174,22 @@
"type": "github" "type": "github"
} }
}, },
"flake-compat_3": {
"flake": false,
"locked": {
"lastModified": 1673956053,
"narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-parts": { "flake-parts": {
"inputs": { "inputs": {
"nixpkgs-lib": [ "nixpkgs-lib": [
@ -283,7 +373,7 @@
}, },
"pre-commit-hooks": { "pre-commit-hooks": {
"inputs": { "inputs": {
"flake-compat": "flake-compat_2", "flake-compat": "flake-compat_3",
"flake-utils": [ "flake-utils": [
"flake-utils" "flake-utils"
], ],
@ -312,6 +402,7 @@
"root": { "root": {
"inputs": { "inputs": {
"agenix": "agenix", "agenix": "agenix",
"conduit": "conduit",
"deploy-rs": "deploy-rs", "deploy-rs": "deploy-rs",
"flake-parts": "flake-parts", "flake-parts": "flake-parts",
"flake-utils": "flake-utils", "flake-utils": "flake-utils",
@ -324,6 +415,50 @@
"pre-commit-hooks": "pre-commit-hooks" "pre-commit-hooks": "pre-commit-hooks"
} }
}, },
"rust-analyzer-src": {
"flake": false,
"locked": {
"lastModified": 1689441253,
"narHash": "sha256-4MSDZaFI4DOfsLIZYPMBl0snzWhX1/OqR/QHir382CY=",
"owner": "rust-lang",
"repo": "rust-analyzer",
"rev": "996e054f1eb1dbfc8455ecabff0f6ff22ba7f7c8",
"type": "github"
},
"original": {
"owner": "rust-lang",
"ref": "nightly",
"repo": "rust-analyzer",
"type": "github"
}
},
"rust-overlay": {
"inputs": {
"flake-utils": [
"conduit",
"crane",
"flake-utils"
],
"nixpkgs": [
"conduit",
"crane",
"nixpkgs"
]
},
"locked": {
"lastModified": 1688351637,
"narHash": "sha256-CLTufJ29VxNOIZ8UTg0lepsn3X03AmopmaLTTeHDCL4=",
"owner": "oxalica",
"repo": "rust-overlay",
"rev": "f9b92316727af9e6c7fee4a761242f7f46880329",
"type": "github"
},
"original": {
"owner": "oxalica",
"repo": "rust-overlay",
"type": "github"
}
},
"systems": { "systems": {
"locked": { "locked": {
"lastModified": 1681028828, "lastModified": 1681028828,

View file

@ -38,6 +38,12 @@
inputs.flake-utils.follows = "flake-utils"; inputs.flake-utils.follows = "flake-utils";
}; };
conduit = {
url = "gitlab:famedly/conduit";
inputs.nixpkgs.follows = "nixpkgs-unstable";
inputs.flake-utils.follows = "flake-utils";
};
nvim-kitty-navigator = { nvim-kitty-navigator = {
url = "github:hermitmaster/nvim-kitty-navigator"; url = "github:hermitmaster/nvim-kitty-navigator";
flake = false; flake = false;
@ -46,7 +52,7 @@
outputs = { self, nixpkgs, nixpkgs-unstable, nixos-hardware, flake-parts outputs = { self, nixpkgs, nixpkgs-unstable, nixos-hardware, flake-parts
, flake-utils, home-manager, nur, agenix, deploy-rs, pre-commit-hooks , flake-utils, home-manager, nur, agenix, deploy-rs, pre-commit-hooks
, nvim-kitty-navigator }@inputs: , nvim-kitty-navigator, ... }@inputs:
inputs.flake-parts.lib.mkFlake { inherit inputs; } { inputs.flake-parts.lib.mkFlake { inherit inputs; } {
systems = [ "x86_64-linux" "aarch64-linux" ]; systems = [ "x86_64-linux" "aarch64-linux" ];
imports = [ ]; imports = [ ];

View file

@ -0,0 +1,52 @@
{ inputs, config, pkgs, ... }:
let
server_name = "felschr.com";
domain = "matrix.${server_name}";
in {
services.matrix-conduit = {
enable = true;
package = inputs.conduit.packages.${pkgs.system}.default;
settings.global = {
inherit server_name;
database_backend = "rocksdb";
trusted_servers = [ "matrix.org" "libera.chat" "nixos.org" ];
};
};
services.nginx.virtualHosts.${domain} = {
enableACME = true;
forceSSL = true;
locations."/_matrix/" = {
proxyPass = "http://[::1]:${
toString config.services.matrix-conduit.settings.global.port
}";
proxyWebsockets = true;
extraConfig = ''
proxy_buffering off;
'';
};
};
services.nginx.virtualHosts.${server_name} = {
enableACME = true;
forceSSL = true;
locations = let
server = { "m.server" = "${domain}:443"; };
client = {
"m.homeserver"."base_url" = "https://${domain}";
"m.identity_server"."base_url" = "https://vector.im";
};
in {
"= /.well-known/matrix/server".extraConfig = ''
add_header Content-Type application/json;
return 200 '${builtins.toJSON server}';
'';
"= /.well-known/matrix/client".extraConfig = ''
add_header Content-Type application/json;
add_header Access-Control-Allow-Origin *;
return 200 '${builtins.toJSON client}';
'';
};
};
}

View file

@ -1,5 +1,5 @@
{ ... }: { ... }:
{ {
imports = [ ./dendrite.nix ./element.nix ]; imports = [ ./conduit.nix ./element.nix ];
} }

View file

@ -1,7 +1,6 @@
{ config, pkgs, ... }: { config, pkgs, ... }:
let let
inherit (config.services) dendrite;
server_name = "felschr.com"; server_name = "felschr.com";
domain = "matrix.${server_name}"; domain = "matrix.${server_name}";
database = { database = {
@ -87,6 +86,7 @@ in {
server = { "m.server" = "${domain}:443"; }; server = { "m.server" = "${domain}:443"; };
client = { client = {
"m.homeserver"."base_url" = "https://${domain}"; "m.homeserver"."base_url" = "https://${domain}";
"org.matrix.msc3575.proxy"."url" = "https://${domain}";
"m.identity_server"."base_url" = "https://vector.im"; "m.identity_server"."base_url" = "https://vector.im";
}; };
in { in {

View file

@ -1,7 +1,7 @@
{ config, pkgs, ... }: { config, pkgs, ... }:
let let
inherit (config.services.dendrite.settings.global) server_name; inherit (config.services.matrix-conduit.settings.global) server_name;
matrix_host = "matrix.${server_name}"; matrix_host = "matrix.${server_name}";
in { in {
services.nginx.virtualHosts."element.felschr.com" = { services.nginx.virtualHosts."element.felschr.com" = {