Skip to content

Instantly share code, notes, and snippets.

@corngood
Created January 23, 2017 00:02
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save corngood/3705a0a3eeaf4ce5f4ed5107fa1f120a to your computer and use it in GitHub Desktop.
Save corngood/3705a0a3eeaf4ce5f4ed5107fa1f120a to your computer and use it in GitHub Desktop.
NixOS matrix server using nginx
{ config, pkgs, ... }:
{
imports =
[
/etc/nixos/hardware-configuration.nix
];
nix.buildCores = 0;
boot.loader.grub = {
enable = true;
version = 2;
device = "/dev/vda";
};
networking.hostName = "server.example.com";
i18n = {
consoleFont = "Lat2-Terminus16";
consoleKeyMap = "us";
defaultLocale = "en_GB.UTF-8";
};
time.timeZone = "America/Halifax";
environment.systemPackages = with pkgs; [
zsh
vim
tmux
];
networking.firewall.allowedTCPPorts = [ 80 443 8448 ];
services = {
nginx = {
enable = true;
recommendedTlsSettings = true;
recommendedOptimisation = true;
recommendedGzipSettings = true;
recommendedProxySettings = true;
virtualHosts."example.com" = {
enableACME = true;
forceSSL = true;
};
virtualHosts."matrix.example.com" = {
enableACME = true;
forceSSL = true;
locations."/" = {
proxyPass = "http://localhost:8008";
};
};
};
openssh = {
enable = true;
permitRootLogin = "no";
};
matrix-synapse = {
enable = true;
server_name = "example.com";
registration_shared_secret = ***;
listeners = [{
port = 8448;
bind_address = "";
type = "http";
tls = true;
x_forwarded = false;
resources = [
{ names = ["federation"]; compress = false; }
];
} {
port = 8008;
bind_address = "127.0.0.1";
type = "http";
tls = false;
x_forwarded = true;
resources = [
{ names = ["client" "webclient"]; compress = true; }
];
}];
};
};
# users.defaultUserShell = "/run/current-system/sw/bin/zsh";
users.extraUsers.example = {
isNormalUser = true;
uid = 1000;
extraGroups = [ "wheel" ];
};
system.stateVersion = "16.09";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment