Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
5a76f7703f
|
|||
e642de2d19
|
|||
30e88a3859
|
|||
61bdd78444
|
|||
b6abcf41b0
|
|||
015d9c6532
|
26
flake.lock
generated
26
flake.lock
generated
@ -8,11 +8,11 @@
|
||||
"systems": "systems"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1703371241,
|
||||
"narHash": "sha256-f7ZcabJ5iAH2IRfVuI55xSPZ9TbegFzvFxoKtIPNEn8=",
|
||||
"lastModified": 1703433843,
|
||||
"narHash": "sha256-nmtA4KqFboWxxoOAA6Y1okHbZh+HsXaMPFkYHsoDRDw=",
|
||||
"owner": "ryantm",
|
||||
"repo": "agenix",
|
||||
"rev": "457669db4259ff69d1ac1183aaa6000420940c1f",
|
||||
"rev": "417caa847f9383e111d1397039c9d4337d024bf0",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@ -139,11 +139,11 @@
|
||||
},
|
||||
"nixos-hardware": {
|
||||
"locked": {
|
||||
"lastModified": 1702453208,
|
||||
"narHash": "sha256-0wRi9SposfE2wHqjuKt8WO2izKB/ASDOV91URunIqgo=",
|
||||
"lastModified": 1703545041,
|
||||
"narHash": "sha256-nvQA+k1rSszrf4kA4eK2i/SGbzoXyoKHzzyzq/Jca1w=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixos-hardware",
|
||||
"rev": "7763c6fd1f299cb9361ff2abf755ed9619ef01d6",
|
||||
"rev": "a15b6e525f5737a47b4ce28445c836996fb2ea8c",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@ -186,11 +186,11 @@
|
||||
},
|
||||
"nixpkgs_3": {
|
||||
"locked": {
|
||||
"lastModified": 1703068421,
|
||||
"narHash": "sha256-WSw5Faqlw75McIflnl5v7qVD/B3S2sLh+968bpOGrWA=",
|
||||
"lastModified": 1703200384,
|
||||
"narHash": "sha256-q5j06XOsy0qHOarsYPfZYJPWbTbc8sryRxianlEPJN0=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "d65bceaee0fb1e64363f7871bc43dc1c6ecad99f",
|
||||
"rev": "0b3d618173114c64ab666f557504d6982665d328",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@ -214,11 +214,11 @@
|
||||
"secrets": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1702936962,
|
||||
"narHash": "sha256-uIZ2uPE26JKJ58463ejHMiAOpqBwflyN6tCmZ89vaSQ=",
|
||||
"lastModified": 1703545643,
|
||||
"narHash": "sha256-FS/acsRQ01Gj39P1t5CQ6cKOdwADmenk//vVmpA/EgU=",
|
||||
"ref": "refs/heads/master",
|
||||
"rev": "c6db5c3ba8bff0e618fc3e31c9680863c5e53800",
|
||||
"revCount": 5,
|
||||
"rev": "ef1f91b155f3bdc4efb2824ad0c47b21b8b1bbfa",
|
||||
"revCount": 9,
|
||||
"type": "git",
|
||||
"url": "ssh://git@git.vimium.com/jordan/nix-secrets.git"
|
||||
},
|
||||
|
23
flake.nix
23
flake.nix
@ -68,27 +68,16 @@
|
||||
helios = nixosSystem { system = "x86_64-linux"; name = "helios"; };
|
||||
odyssey = nixosSystem { system = "x86_64-linux"; name = "odyssey"; };
|
||||
pi = nixosSystem { system = "aarch64-linux"; name = "pi"; extraModules = [ nixos-hardware.nixosModules.raspberry-pi-4 ]; };
|
||||
vps1 = nixosSystem { system = "x86_64-linux"; name = "vps1"; };
|
||||
};
|
||||
|
||||
deploy.nodes = {
|
||||
pi = {
|
||||
hostname = "10.0.1.191";
|
||||
sshUser = "jordan";
|
||||
user = "root";
|
||||
deploy.nodes.pi = {
|
||||
hostname = "10.0.1.191";
|
||||
sshUser = "root";
|
||||
|
||||
profiles.system = {
|
||||
user = "root";
|
||||
path = deploy-rs.lib.aarch64-linux.activate.nixos self.nixosConfigurations.pi;
|
||||
};
|
||||
profiles.system = {
|
||||
user = "root";
|
||||
path = deploy-rs.lib.aarch64-linux.activate.nixos self.nixosConfigurations.pi;
|
||||
};
|
||||
vps1 = {
|
||||
magicRollback = true;
|
||||
autoRollback = true;
|
||||
hostname = "vps1.mesh.vimium.net";
|
||||
profiles.system = {
|
||||
user = "root";
|
||||
path = deploy-rs.lib.x86_64-linux.activate.nixos self.nixosConfigurations.vps1;
|
||||
};
|
||||
|
||||
# checks = builtins.mapAttrs (system: deployLib: deployLib.deployChecks self.deploy) deploy-rs.lib;
|
||||
|
@ -1,4 +1,4 @@
|
||||
{ config, lib, pkgs, ... }:
|
||||
{ config, lib, pkgs, inputs, ... }:
|
||||
|
||||
{
|
||||
imports = [
|
||||
@ -6,13 +6,19 @@
|
||||
../desktop.nix
|
||||
];
|
||||
|
||||
boot.loader.grub.enable = true;
|
||||
boot.loader.grub.device = "/dev/sda";
|
||||
boot.loader.grub.zfsSupport = true;
|
||||
boot = {
|
||||
loader.grub = {
|
||||
enable = true;
|
||||
device = "/dev/sda";
|
||||
zfsSupport = true;
|
||||
};
|
||||
};
|
||||
|
||||
networking.hostName = "helios";
|
||||
networking.hostId = "47d23505";
|
||||
networking.networkmanager.enable = true;
|
||||
networking = {
|
||||
hostName = "helios";
|
||||
hostId = "47d23505";
|
||||
networkmanager.enable = true;
|
||||
};
|
||||
|
||||
nix.package = pkgs.nixFlakes;
|
||||
nix.extraOptions = ''
|
||||
@ -40,6 +46,15 @@
|
||||
gpg.enable = true;
|
||||
pass.enable = true;
|
||||
};
|
||||
services = {
|
||||
borgmatic = {
|
||||
enable = true;
|
||||
directories = [
|
||||
"/home/jordan/Documents"
|
||||
];
|
||||
repoPath = "ssh://b9cjl9hq@b9cjl9hq.repo.borgbase.com/./repo";
|
||||
};
|
||||
};
|
||||
shell = {
|
||||
git.enable = true;
|
||||
zsh.enable = true;
|
||||
|
@ -52,34 +52,6 @@
|
||||
};
|
||||
};
|
||||
|
||||
age.secrets."passwords/services/borg/odyssey-passphrase" = {
|
||||
file = "${inputs.secrets}/passwords/services/borg/odyssey-passphrase.age";
|
||||
};
|
||||
|
||||
services.borgmatic = {
|
||||
enable = true;
|
||||
settings = {
|
||||
source_directories = [
|
||||
"/home/jordan/Documents"
|
||||
];
|
||||
repositories = [
|
||||
{ label = "borgbase"; path = "ssh://iqwu22oq@iqwu22oq.repo.borgbase.com/./repo"; }
|
||||
];
|
||||
storage = {
|
||||
encryption_passcommand = "cat ${config.age.secrets."passwords/services/borg/odyssey-passphrase".path}";
|
||||
ssh_command = "ssh -i /etc/ssh/ssh_host_ed25519_key";
|
||||
};
|
||||
retention = {
|
||||
keep_daily = 7;
|
||||
keep_weekly = 4;
|
||||
keep_monthly = 6;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
# Without this override, `cat` is unavailable for `encryption_passcommand`
|
||||
systemd.services.borgmatic.confinement.fullUnit = true;
|
||||
|
||||
modules = {
|
||||
desktop = {
|
||||
apps.qbittorrent.enable = true;
|
||||
@ -111,6 +83,15 @@
|
||||
gpg.enable = true;
|
||||
pass.enable = true;
|
||||
};
|
||||
services = {
|
||||
borgmatic = {
|
||||
enable = true;
|
||||
directories = [
|
||||
"/home/jordan/Documents"
|
||||
];
|
||||
repoPath = "ssh://iqwu22oq@iqwu22oq.repo.borgbase.com/./repo";
|
||||
};
|
||||
};
|
||||
shell = {
|
||||
git.enable = true;
|
||||
zsh.enable = true;
|
||||
|
@ -29,21 +29,6 @@
|
||||
|
||||
sound.enable = true;
|
||||
|
||||
age.secrets."passwords/networks.age" = {
|
||||
file = "${inputs.secrets}/passwords/networks.age";
|
||||
};
|
||||
|
||||
networking = {
|
||||
wireless = {
|
||||
enable = true;
|
||||
interfaces = [ "wlan0" ];
|
||||
environmentFile = config.age.secrets."passwords/networks.age".path;
|
||||
networks = {
|
||||
"Apollo 600 Mbps".psk = "@PSK_APOLLO@";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
security.rtkit.enable = true;
|
||||
services.pipewire = {
|
||||
enable = true;
|
||||
@ -108,35 +93,25 @@
|
||||
};
|
||||
};
|
||||
|
||||
age.secrets."passwords/services/borg/pi-passphrase" = {
|
||||
file = "${inputs.secrets}/passwords/services/borg/pi-passphrase.age";
|
||||
};
|
||||
|
||||
services.borgmatic = {
|
||||
enable = true;
|
||||
settings = {
|
||||
source_directories = [
|
||||
"/var/lib/mosquitto"
|
||||
"/var/lib/zigbee2mqtt"
|
||||
];
|
||||
repositories = [
|
||||
{ label = "borgbase"; path = "ssh://qcw86s11@qcw86s11.repo.borgbase.com/./repo"; }
|
||||
];
|
||||
storage = {
|
||||
encryption_passcommand = "cat ${config.age.secrets."passwords/services/borg/pi-passphrase".path}";
|
||||
ssh_command = "ssh -i /etc/ssh/ssh_host_ed25519_key";
|
||||
modules = {
|
||||
networking = {
|
||||
wireless = {
|
||||
enable = true;
|
||||
interfaces = [ "wlan0" ];
|
||||
};
|
||||
retention = {
|
||||
keep_daily = 7;
|
||||
keep_weekly = 4;
|
||||
keep_monthly = 6;
|
||||
};
|
||||
services = {
|
||||
borgmatic = {
|
||||
enable = true;
|
||||
directories = [
|
||||
"/var/lib/mosquitto"
|
||||
"/var/lib/zigbee2mqtt"
|
||||
];
|
||||
repoPath = "ssh://qcw86s11@qcw86s11.repo.borgbase.com/./repo";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
# Without this override, `cat` is unavailable for `encryption_passcommand`
|
||||
systemd.services.borgmatic.confinement.fullUnit = true;
|
||||
|
||||
environment.systemPackages = with pkgs; [
|
||||
libraspberrypi
|
||||
raspberrypi-eeprom
|
||||
|
@ -1,17 +0,0 @@
|
||||
# vps1
|
||||
|
||||
## Overview
|
||||
VPS hosted in OVH.
|
||||
|
||||
## Specs
|
||||
* CPU - ??
|
||||
* Memory - ??
|
||||
|
||||
### Disks
|
||||
Device | Partitions _(filesystem, usage)_
|
||||
--- | ---
|
||||
NVMe | `/dev/sda1` (ext4, NixOS Root)
|
||||
|
||||
### Networks
|
||||
- DHCP on `10.0.1.0/24` subnet.
|
||||
- Tailscale on `100.64.0.0/10` subnet. FQDN: `vps1.mesh.vimium.net`.
|
@ -1,195 +0,0 @@
|
||||
{ config, lib, pkgs, inputs, ... }:
|
||||
|
||||
{
|
||||
imports = [
|
||||
./hardware-configuration.nix
|
||||
../server.nix
|
||||
];
|
||||
|
||||
networking = {
|
||||
hostId = "???";
|
||||
hostName = "vps1";
|
||||
domain = "mesh.vimium.net";
|
||||
firewall = {
|
||||
enable = true;
|
||||
allowedTCPPorts = [
|
||||
22 # SSH
|
||||
8448 # Matrix federation
|
||||
80 # HTTP
|
||||
443 # HTTPS
|
||||
5349 # STUN TLS
|
||||
5350 # STUN TLS alt
|
||||
];
|
||||
allowedUDPPortRanges = [
|
||||
{ from = 49152; to = 49999; } # TURN relay
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
users.users = {
|
||||
git = {
|
||||
isSystemUser = true;
|
||||
useDefaultShell = true;
|
||||
group = "git";
|
||||
extraGroups = [ "gitea" ];
|
||||
home = config.services.gitea.stateDir;
|
||||
};
|
||||
jellyfin = {
|
||||
isSystemUser = true;
|
||||
group = "jellyfin";
|
||||
shell = "/bin/sh";
|
||||
openssh.authorizedKeys.keys = [
|
||||
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOaaS+KMAEAymZhIJGC4LK8aMhUzhpmloUgvP2cxeBH4 jellyfin"
|
||||
];
|
||||
};
|
||||
root = {
|
||||
openssh.authorizedKeys.keys = [
|
||||
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILVHTjsyMIV4THNw6yz0OxAxGnC+41gX72UrPqTzR+OS jordan@vimium.com"
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
users.groups = {
|
||||
git = { };
|
||||
jellyfin = { };
|
||||
};
|
||||
|
||||
age.secrets."passwords/services/borg/vps1-passphrase" = {
|
||||
file = "${inputs.secrets}/passwords/services/borg/vps1-passphrase.age";
|
||||
};
|
||||
|
||||
services.borgmatic = {
|
||||
enable = true;
|
||||
settings = {
|
||||
source_directories = [
|
||||
"/home"
|
||||
"/var/lib"
|
||||
"/var/www"
|
||||
];
|
||||
repositories = [
|
||||
{ label = "borgbase"; path = "ssh://p91y8oh7@p91y8oh7.repo.borgbase.com/./repo"; }
|
||||
];
|
||||
storage = {
|
||||
encryption_passcommand = "cat ${config.age.secrets."passwords/services/borg/vps1-passphrase".path}";
|
||||
ssh_command = "ssh -i /etc/ssh/ssh_host_ed25519_key";
|
||||
};
|
||||
retention = {
|
||||
keep_daily = 7;
|
||||
keep_weekly = 4;
|
||||
keep_monthly = 6;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
# Without this override, `cat` is unavailable for `encryption_passcommand`
|
||||
systemd.services.borgmatic.confinement.fullUnit = true;
|
||||
|
||||
age.secrets."passwords/services/coturn/shared-secret" = {
|
||||
file = "${inputs.secrets}/passwords/services/coturn/shared-secret.age";
|
||||
};
|
||||
|
||||
services.coturn = {
|
||||
enable = true;
|
||||
lt-cred-mech = true;
|
||||
use-auth-secret = true;
|
||||
static-auth-secret = "???";
|
||||
realm = "turn.vimium.com";
|
||||
relay-ips = [
|
||||
"198.244.190.160"
|
||||
];
|
||||
no-tcp-relay = true;
|
||||
extraConfig = ''
|
||||
cipher-list="HIGH"
|
||||
no-loopback-peers
|
||||
no-multicast-peers
|
||||
'';
|
||||
secure-stun = true;
|
||||
cert = "/var/lib/acme/turn.vimium.com/fullchain.pem";
|
||||
pkey = "/var/lib/acme/turn.vimium.com/key.pem";
|
||||
min-port = 49152;
|
||||
max-port = 49999;
|
||||
};
|
||||
|
||||
services.gitea = rec {
|
||||
package = pkgs.gitea;
|
||||
enable = true;
|
||||
user = "git";
|
||||
appName = "Vimium Git";
|
||||
stateDir = "/var/lib/gitea";
|
||||
repositoryRoot = "${stateDir}/repositories";
|
||||
database = {
|
||||
type = "sqlite3";
|
||||
inherit user;
|
||||
path = "${stateDir}/gitea.db";
|
||||
};
|
||||
lfs = {
|
||||
enable = true;
|
||||
contentDir = "${stateDir}/lfs";
|
||||
};
|
||||
settings = {
|
||||
server = {
|
||||
SSH_USER = "git";
|
||||
SSH_DOMAIN = "git.vimium.com";
|
||||
SSH_PORT = lib.head config.services.openssh.ports;
|
||||
OFFLINE_MODE = true;
|
||||
PROTOCOL = "http+unix";
|
||||
DOMAIN = config.networking.domain;
|
||||
ROOT_URL = "https://git.vimium.com/";
|
||||
};
|
||||
service.DISABLE_REGISTRATION = true;
|
||||
session.COOKIE_SECURE = true;
|
||||
log.ROOT_PATH = "${stateDir}/log";
|
||||
ui = {
|
||||
THEMES = "gitea,arc-green,github-dark,bthree-dark";
|
||||
DEFAULT_THEME = "github-dark";
|
||||
};
|
||||
actions.ENABLED = true;
|
||||
indexer = {
|
||||
REPO_INDEXER_ENABLED = true;
|
||||
};
|
||||
packages.CHUNKED_UPLOAD_PATH = lib.mkForce "${stateDir}/data/tmp/package-upload";
|
||||
};
|
||||
};
|
||||
|
||||
services.headscale = {
|
||||
enable = true;
|
||||
port = 8080;
|
||||
settings = {
|
||||
server_url = "https://headscale.vimium.net";
|
||||
dns_config = {
|
||||
base_domain = "vimium.net";
|
||||
};
|
||||
logtail.enabled = false;
|
||||
};
|
||||
};
|
||||
|
||||
services.matrix-synapse = {
|
||||
enable = true;
|
||||
settings = {
|
||||
database.name = "sqlite3";
|
||||
enable_registration = false;
|
||||
server_name = "vimium.com";
|
||||
turn_shared_secret = "???";
|
||||
turn_uris = [
|
||||
"turn:turn.vimium.com:5349?transport=udp"
|
||||
"turn:turn.vimium.com:5350?transport=udp"
|
||||
"turn:turn.vimium.com:5349?transport=tcp"
|
||||
"turn:turn.vimium.com:5350?transport=tcp"
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
services.tailscale.enable = true;
|
||||
networking.firewall = {
|
||||
checkReversePath = "loose";
|
||||
trustedInterfaces = [ "tailscale0" ];
|
||||
allowedUDPPorts = [ config.services.tailscale.port ];
|
||||
};
|
||||
|
||||
environment.systemPackages = with pkgs; [
|
||||
config.services.headscale.package
|
||||
];
|
||||
|
||||
system.stateVersion = "22.11";
|
||||
}
|
||||
|
@ -1,26 +0,0 @@
|
||||
{ config, lib, pkgs, modulesPath, ... }:
|
||||
|
||||
{
|
||||
imports = [
|
||||
(modulesPath + "/profiles/qemu-guest.nix")
|
||||
];
|
||||
|
||||
boot = {
|
||||
initrd = {
|
||||
availableKernelModules = [ "ata_piix" "uhci_hcd" "xen_blkfront" "vmw_pvscsi" ];
|
||||
kernelModules = [ "nvme" ];
|
||||
};
|
||||
loader.grub.device = "/dev/sda";
|
||||
tmp.cleanOnBoot = true;
|
||||
};
|
||||
|
||||
zramSwap.enable = true;
|
||||
|
||||
fileSystems = {
|
||||
"/" = {
|
||||
device = "/dev/sda1";
|
||||
fsType = "ext4";
|
||||
};
|
||||
};
|
||||
}
|
||||
|
@ -26,8 +26,12 @@
|
||||
./editors/neovim
|
||||
./editors/vscode.nix
|
||||
./networking/tailscale.nix
|
||||
./networking/wireless.nix
|
||||
./security/gpg.nix
|
||||
./security/pass.nix
|
||||
./services/borgmatic
|
||||
./services/coturn
|
||||
./services/matrix
|
||||
./shell/git
|
||||
./shell/zsh
|
||||
];
|
||||
|
36
modules/networking/wireless.nix
Normal file
36
modules/networking/wireless.nix
Normal file
@ -0,0 +1,36 @@
|
||||
{ config, lib, pkgs, inputs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let cfg = config.modules.networking.wireless;
|
||||
in {
|
||||
options.modules.networking.wireless = {
|
||||
enable = mkOption {
|
||||
default = false;
|
||||
example = true;
|
||||
description = mdDoc "Automatically connect to known networks";
|
||||
};
|
||||
interfaces = mkOption {
|
||||
default = [ ]; # All interfaces
|
||||
example = [ "wlan0" ];
|
||||
description = mdDoc "Interfaces for `wpa_supplicant` to bind to";
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
age.secrets."passwords/networks" = {
|
||||
file = "${inputs.secrets}/passwords/networks.age";
|
||||
};
|
||||
|
||||
networking = {
|
||||
wireless = {
|
||||
enable = true;
|
||||
interfaces = cfg.interfaces;
|
||||
environmentFile = config.age.secrets.passwords/networks.path;
|
||||
networks = {
|
||||
"Apollo 600 Mbps".psk = "@PSK_APOLLO@";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
57
modules/services/borgmatic/default.nix
Normal file
57
modules/services/borgmatic/default.nix
Normal file
@ -0,0 +1,57 @@
|
||||
{ config, lib, pkgs, inputs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
cfg = config.modules.services.borgmatic;
|
||||
hostname = config.networking.hostName;
|
||||
in {
|
||||
options.modules.services.borgmatic = {
|
||||
enable = mkOption {
|
||||
default = false;
|
||||
example = true;
|
||||
description = mdDoc "Enable backups on this host with `borgmatic`";
|
||||
};
|
||||
directories = mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = [];
|
||||
example = [
|
||||
"/home/jordan/Documents"
|
||||
];
|
||||
description = mdDoc "List of directories to backup";
|
||||
};
|
||||
repoPath = mkOption {
|
||||
type = types.str;
|
||||
example = "ssh://example@example.repo.borgbase.com/./repo";
|
||||
description = mdDoc "Destination borg repository for backup";
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
age.secrets."passwords/services/borg/${hostname}-passphrase" = {
|
||||
file = "${inputs.secrets}/passwords/services/borg/${hostname}-passphrase.age";
|
||||
};
|
||||
|
||||
services.borgmatic = {
|
||||
enable = true;
|
||||
settings = {
|
||||
source_directories = cfg.directories;
|
||||
repositories = [
|
||||
{ label = "borgbase"; path = cfg.repoPath; }
|
||||
];
|
||||
storage = {
|
||||
encryption_passcommand = "cat ${config.age.secrets."passwords/services/borg/${hostname}-passphrase".path}";
|
||||
ssh_command = "ssh -i /etc/ssh/ssh_host_ed25519_key";
|
||||
};
|
||||
retention = {
|
||||
keep_daily = 7;
|
||||
keep_weekly = 4;
|
||||
keep_monthly = 6;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
# Without this override, `cat` is unavailable for `encryption_passcommand`
|
||||
systemd.services.borgmatic.confinement.fullUnit = true;
|
||||
};
|
||||
}
|
59
modules/services/coturn/default.nix
Normal file
59
modules/services/coturn/default.nix
Normal file
@ -0,0 +1,59 @@
|
||||
{ config, lib, pkgs, inputs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
cfg = config.modules.services.coturn;
|
||||
domain = "vimium.com";
|
||||
in {
|
||||
options.modules.services.coturn = {
|
||||
enable = mkOption {
|
||||
default = false;
|
||||
example = true;
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
age.secrets."passwords/services/coturn/secret" = {
|
||||
file = "${inputs.secrets}/passwords/services/coturn/secret.age";
|
||||
};
|
||||
|
||||
networking.firewall = {
|
||||
allowedTCPPorts = [
|
||||
5349 # STUN TLS
|
||||
5350 # STUN TLS alt
|
||||
];
|
||||
allowedUDPPortRanges = [
|
||||
{ from = 49152; to = 49999; } # TURN relay
|
||||
];
|
||||
};
|
||||
|
||||
services.coturn = {
|
||||
enable = true;
|
||||
lt-cred-mech = true;
|
||||
use-auth-secret = true;
|
||||
static-auth-secret = ""; # TODO: Pass as extraConfig
|
||||
realm = "turn.${domain}";
|
||||
relay-ips = [
|
||||
"198.244.190.160"
|
||||
];
|
||||
no-tcp-relay = true;
|
||||
extraConfig = ''
|
||||
cipher-list="HIGH"
|
||||
no-loopback-peers
|
||||
no-multicast-peers
|
||||
'';
|
||||
secure-stun = true;
|
||||
cert = "/var/lib/acme/turn.${domain}/fullchain.pem";
|
||||
pkey = "/var/lib/acme/turn.${domain}/key.pem";
|
||||
min-port = 49152;
|
||||
max-port = 49999;
|
||||
};
|
||||
|
||||
security.acme.certs = {
|
||||
"turn.${domain}" = {
|
||||
reloadServices = [ "coturn" ];
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
120
modules/services/matrix/default.nix
Normal file
120
modules/services/matrix/default.nix
Normal file
@ -0,0 +1,120 @@
|
||||
{ config, lib, pkgs, inputs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
cfg = config.modules.services.matrix;
|
||||
domain = "vimium.com";
|
||||
clientConfig = {
|
||||
"m.homeserver" = {
|
||||
base_url = "https://matrix.${domain}";
|
||||
server_name = domain;
|
||||
};
|
||||
"m.identity_server" = {};
|
||||
};
|
||||
serverConfig."m.server" = "matrix.${domain}:443";
|
||||
mkWellKnown = data: ''
|
||||
more_set_headers 'Content-Type: application/json';
|
||||
return 200 '${builtins.toJSON data}';
|
||||
'';
|
||||
in {
|
||||
options.modules.services.matrix = {
|
||||
enable = mkOption {
|
||||
default = false;
|
||||
example = true;
|
||||
};
|
||||
coturn = mkOption {
|
||||
default = config.services.coturn.enable;
|
||||
example = true;
|
||||
};
|
||||
elementWeb = mkOption {
|
||||
default = true;
|
||||
example = true;
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
networking.firewall = {
|
||||
allowedTCPPorts = [
|
||||
8448 # Matrix federation
|
||||
];
|
||||
};
|
||||
|
||||
services.nginx = {
|
||||
virtualHosts = {
|
||||
"${domain}" = {
|
||||
# Assume this listener is already setup
|
||||
locations."= /.well-known/matrix/server".extraConfig = (mkWellKnown serverConfig);
|
||||
locations."= /.well-known/matrix/client".extraConfig = (mkWellKnown clientConfig);
|
||||
};
|
||||
"matrix.${domain}" = {
|
||||
forceSSL = true;
|
||||
useACMEHost = "matrix.${domain}";
|
||||
listen = [
|
||||
{ addr = "0.0.0.0"; port = 443; ssl = true; }
|
||||
{ addr = "0.0.0.0"; port = 80; }
|
||||
{ addr = "0.0.0.0"; port = 8448; ssl = true; }
|
||||
{ addr = "[::1]"; port = 443; ssl = true; }
|
||||
{ addr = "[::1]"; port = 80; }
|
||||
{ addr = "[::1]"; port = 8448; ssl = true; }
|
||||
];
|
||||
locations = {
|
||||
"/" = {
|
||||
proxyPass = "http://localhost:8008";
|
||||
extraConfig = ''
|
||||
proxy_set_header X-Forwarded-For $remote_addr;
|
||||
'';
|
||||
};
|
||||
"/_matrix" = {
|
||||
proxyPass = "http://localhost:8008";
|
||||
extraConfig = ''
|
||||
proxy_set_header X-Forwarded-For $remote_addr;
|
||||
client_max_body_size ${services.matrix-synapse.settings.max_upload_size};
|
||||
'';
|
||||
};
|
||||
"/_synapse/client".proxyPass = "http://localhost:8008";
|
||||
};
|
||||
};
|
||||
"chat.${domain}" = mkIf cfg.elementWeb {
|
||||
forceSSL = true;
|
||||
useACMEHost = "matrix.${domain}";
|
||||
root = pkgs.element-web.override {
|
||||
conf = {
|
||||
default_server_config = clientConfig;
|
||||
brand = "Vimium Chat";
|
||||
branding = {
|
||||
auth_header_logo_url = "https://vimium.com/images/logo.svg";
|
||||
auth_footer_links = [
|
||||
{ text = "Vimium.com"; url = "https://www.vimium.com"; }
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
services.matrix-synapse = {
|
||||
enable = true;
|
||||
settings = {
|
||||
database.name = "sqlite3";
|
||||
enable_registration = false;
|
||||
server_name = domain;
|
||||
turn_shared_secret_file = mkIf cfg.coturn config.age.secrets."passwords/services/coturn/secret".path;
|
||||
turn_uris = mkIf cfg.coturn [
|
||||
"turn:${config.services.coturn.realm}:5349?transport=udp"
|
||||
"turn:${config.services.coturn.realm}:5350?transport=udp"
|
||||
"turn:${config.services.coturn.realm}:5349?transport=tcp"
|
||||
"turn:${config.services.coturn.realm}:5350?transport=tcp"
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
security.acme.certs = {
|
||||
"matrix.${domain}" = {
|
||||
extraDomainNames = mkIf cfg.elementWeb [ "chat.${domain}" ];
|
||||
reloadServices = [ "matrix-synapse" ];
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user