Compare commits
2 Commits
0520f722fd
...
matrix
Author | SHA1 | Date | |
---|---|---|---|
5a76f7703f
|
|||
e642de2d19
|
32
flake.lock
generated
32
flake.lock
generated
@@ -66,11 +66,11 @@
|
|||||||
"firefox-gnome-theme": {
|
"firefox-gnome-theme": {
|
||||||
"flake": false,
|
"flake": false,
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1704289846,
|
"lastModified": 1703023593,
|
||||||
"narHash": "sha256-8fzpIE+6EvNUREEp7wP/rlDpwZm7Xig6L+pT2w2tY6Q=",
|
"narHash": "sha256-M+Cw6vh7xCDmIhyVuEPNmaNVUwpmdFQq8zlsXZTKees=",
|
||||||
"owner": "rafaelmardojai",
|
"owner": "rafaelmardojai",
|
||||||
"repo": "firefox-gnome-theme",
|
"repo": "firefox-gnome-theme",
|
||||||
"rev": "ddf8f59d1a12d45c61ed7a3705639f9beea562ab",
|
"rev": "bad853333d9021e7012adb9b8fbfe7a7003f26bc",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -123,11 +123,11 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1704099619,
|
"lastModified": 1703367386,
|
||||||
"narHash": "sha256-QRVMkdxLmv+aKGjcgeEg31xtJEIsYq4i1Kbyw5EPS6g=",
|
"narHash": "sha256-FMbm48UGrBfOWGt8+opuS+uLBLQlRfhiYXhHNcYMS5k=",
|
||||||
"owner": "nix-community",
|
"owner": "nix-community",
|
||||||
"repo": "home-manager",
|
"repo": "home-manager",
|
||||||
"rev": "7e398b3d76bc1503171b1364c9d4a07ac06f3851",
|
"rev": "d5824a76bc6bb93d1dce9ebbbcb09a9b6abcc224",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -139,11 +139,11 @@
|
|||||||
},
|
},
|
||||||
"nixos-hardware": {
|
"nixos-hardware": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1704266875,
|
"lastModified": 1703545041,
|
||||||
"narHash": "sha256-luA5SGmeIRZlgLfSLUuR3eacS63q2bJ0Yywqak5lj3E=",
|
"narHash": "sha256-nvQA+k1rSszrf4kA4eK2i/SGbzoXyoKHzzyzq/Jca1w=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixos-hardware",
|
"repo": "nixos-hardware",
|
||||||
"rev": "8e34f33464d77bea2d5cf7dc1066647b1ad2b324",
|
"rev": "a15b6e525f5737a47b4ce28445c836996fb2ea8c",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -186,11 +186,11 @@
|
|||||||
},
|
},
|
||||||
"nixpkgs_3": {
|
"nixpkgs_3": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1703992652,
|
"lastModified": 1703200384,
|
||||||
"narHash": "sha256-C0o8AUyu8xYgJ36kOxJfXIroy9if/G6aJbNOpA5W0+M=",
|
"narHash": "sha256-q5j06XOsy0qHOarsYPfZYJPWbTbc8sryRxianlEPJN0=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "32f63574c85fbc80e4ba1fbb932cde9619bad25e",
|
"rev": "0b3d618173114c64ab666f557504d6982665d328",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -214,11 +214,11 @@
|
|||||||
"secrets": {
|
"secrets": {
|
||||||
"flake": false,
|
"flake": false,
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1704142752,
|
"lastModified": 1703545643,
|
||||||
"narHash": "sha256-MZMXHsx9no3cu66xHWfBdulHOdR3lb6vsrJ3sFpkifM=",
|
"narHash": "sha256-FS/acsRQ01Gj39P1t5CQ6cKOdwADmenk//vVmpA/EgU=",
|
||||||
"ref": "refs/heads/master",
|
"ref": "refs/heads/master",
|
||||||
"rev": "575a343aafbe2c9783e4ce5dc6677c1471e36d81",
|
"rev": "ef1f91b155f3bdc4efb2824ad0c47b21b8b1bbfa",
|
||||||
"revCount": 10,
|
"revCount": 9,
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "ssh://git@git.vimium.com/jordan/nix-secrets.git"
|
"url": "ssh://git@git.vimium.com/jordan/nix-secrets.git"
|
||||||
},
|
},
|
||||||
|
@@ -1,35 +0,0 @@
|
|||||||
# Hypnos
|
|
||||||
|
|
||||||
## Overview
|
|
||||||
15-inch MacBook Pro 11,3 (Mid 2014).
|
|
||||||
|
|
||||||
## Specs
|
|
||||||
* CPU - Intel Core i7-4870HQ @ 2.50GHz
|
|
||||||
* Memory - 16 GB DDR3
|
|
||||||
* GPU - Intel Iris Pro 5200
|
|
||||||
* GPU - NVIDIA GeForce GT 750M
|
|
||||||
* NIC - Broadcom BCM43xx 802.11ac
|
|
||||||
|
|
||||||
### Disks
|
|
||||||
Device | Partitions _(filesystem, size, usage)_
|
|
||||||
--- | ---
|
|
||||||
Apple SSD SM0512F | `/dev/sda1` (EFI, 256 MiB, NixOS Boot) <br> `/dev/sda2` (ZFS, 500 GiB, NixOS Root)
|
|
||||||
|
|
||||||
#### ZFS pool layout
|
|
||||||
```
|
|
||||||
rpool/
|
|
||||||
├── local
|
|
||||||
│ ├── nix
|
|
||||||
│ └── tmp
|
|
||||||
├── system
|
|
||||||
│ ├── root
|
|
||||||
│ └── var
|
|
||||||
└── user
|
|
||||||
└── home
|
|
||||||
```
|
|
||||||
|
|
||||||
See [Graham Christensen's article](https://grahamc.com/blog/nixos-on-zfs/#datasets) for the motivation behind these datasets.
|
|
||||||
|
|
||||||
### Networks
|
|
||||||
- DHCP on `10.0.1.0/24` subnet.
|
|
||||||
- Tailscale on `100.64.0.0/10` subnet. FQDN: `hypnos.mesh.vimium.net`.
|
|
@@ -1,53 +0,0 @@
|
|||||||
{ config, lib, pkgs, ... }:
|
|
||||||
|
|
||||||
{
|
|
||||||
imports = [
|
|
||||||
./hardware-configuration.nix
|
|
||||||
../desktop.nix
|
|
||||||
];
|
|
||||||
|
|
||||||
boot.loader = {
|
|
||||||
systemd-boot.enable = true;
|
|
||||||
efi.canTouchEfiVariables = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
networking = {
|
|
||||||
hostName = "hypnos";
|
|
||||||
hostId = "cf791898";
|
|
||||||
networkmanager.enable = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
nix = {
|
|
||||||
package = pkgs.nixFlakes;
|
|
||||||
extraOptions = ''
|
|
||||||
experimental-features = nix-command flakes
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
modules = {
|
|
||||||
desktop = {
|
|
||||||
browsers = {
|
|
||||||
firefox.enable = true;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
dev = {
|
|
||||||
node.enable = true;
|
|
||||||
};
|
|
||||||
editors = {
|
|
||||||
neovim.enable = true;
|
|
||||||
};
|
|
||||||
networking = {
|
|
||||||
wireless.enable = true;
|
|
||||||
};
|
|
||||||
security = {
|
|
||||||
gpg.enable = true;
|
|
||||||
pass.enable = true;
|
|
||||||
};
|
|
||||||
shell = {
|
|
||||||
git.enable = true;
|
|
||||||
zsh.enable = true;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
system.stateVersion = "22.11";
|
|
||||||
}
|
|
@@ -1,123 +0,0 @@
|
|||||||
{
|
|
||||||
disko.devices = {
|
|
||||||
disk = {
|
|
||||||
main = {
|
|
||||||
type = "disk";
|
|
||||||
device = "/dev/disk/by-id/ata-APPLE_SSD_SM0512F_S1K5NYBF736152";
|
|
||||||
content = {
|
|
||||||
type = "gpt";
|
|
||||||
partitions = {
|
|
||||||
ESP = {
|
|
||||||
size = "256M";
|
|
||||||
type = "EF00";
|
|
||||||
content = {
|
|
||||||
type = "filesystem";
|
|
||||||
format = "vfat";
|
|
||||||
mountpoint = "/boot";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
zfs = {
|
|
||||||
size = "100%";
|
|
||||||
content = {
|
|
||||||
type = "zfs";
|
|
||||||
pool = "rpool";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
zpool = {
|
|
||||||
rpool = {
|
|
||||||
type = "zpool";
|
|
||||||
options = {
|
|
||||||
ashift = "12";
|
|
||||||
};
|
|
||||||
rootFsOptions = {
|
|
||||||
canmount = "off";
|
|
||||||
mountpoint = "none";
|
|
||||||
dnodesize = "auto";
|
|
||||||
xattr = "sa";
|
|
||||||
};
|
|
||||||
mountpoint = "/";
|
|
||||||
postCreateHook = "zfs snapshot rpool@blank";
|
|
||||||
datasets = {
|
|
||||||
local = {
|
|
||||||
options = {
|
|
||||||
mountpoint = "none";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
"local/nix" = {
|
|
||||||
mountpoint = "/nix";
|
|
||||||
options = {
|
|
||||||
atime = "off";
|
|
||||||
mountpoint = "legacy";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
"local/tmp" = {
|
|
||||||
mountpoint = "/tmp";
|
|
||||||
options = {
|
|
||||||
setuid = "off";
|
|
||||||
devices = "off";
|
|
||||||
mountpoint = "legacy";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
system = {
|
|
||||||
options = {
|
|
||||||
mountpoint = "none";
|
|
||||||
encryption = "aes-256-gcm";
|
|
||||||
keyformat = "passphrase";
|
|
||||||
keylocation = "file:///tmp/secret.key";
|
|
||||||
};
|
|
||||||
# use this to read the key during boot
|
|
||||||
postCreateHook = ''
|
|
||||||
zfs set keylocation="prompt" "rpool/$name";
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
"system/var" = {
|
|
||||||
mountpoint = "/var";
|
|
||||||
options = {
|
|
||||||
mountpoint = "legacy";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
"system/var/tmp" = {
|
|
||||||
mountpoint = "/var/tmp";
|
|
||||||
options = {
|
|
||||||
devices = "off";
|
|
||||||
mountpoint = "legacy";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
"system/var/log" = {
|
|
||||||
mountpoint = "/var/log";
|
|
||||||
options = {
|
|
||||||
compression = "on";
|
|
||||||
acltype = "posix";
|
|
||||||
mountpoint = "legacy";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
user = {
|
|
||||||
options = {
|
|
||||||
mountpoint = "none";
|
|
||||||
encryption = "aes-256-gcm";
|
|
||||||
keyformat = "passphrase";
|
|
||||||
keylocation = "file:///tmp/secret.key";
|
|
||||||
};
|
|
||||||
# use this to read the key during boot
|
|
||||||
postCreateHook = ''
|
|
||||||
zfs set keylocation="prompt" "rpool/$name";
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
"user/home" = {
|
|
||||||
mountpoint = "/home";
|
|
||||||
options = {
|
|
||||||
setuid = "off";
|
|
||||||
devices = "off";
|
|
||||||
mountpoint = "legacy";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
@@ -1,21 +0,0 @@
|
|||||||
{ config, lib, pkgs, modulesPath, ... }:
|
|
||||||
|
|
||||||
{
|
|
||||||
imports = [
|
|
||||||
(modulesPath + "/installer/scan/not-detected.nix")
|
|
||||||
];
|
|
||||||
|
|
||||||
boot = {
|
|
||||||
initrd.availableKernelModules = [ "xhci_pci" "achi" "usbhid" "usb_storage" "sd_mod" ];
|
|
||||||
initrd.kernelModules = [ ];
|
|
||||||
kernelModules = [ "kvm-intel" "wl" ];
|
|
||||||
extraModulePackages = [ config.boot.kernelPackages.broadcom_sta ];
|
|
||||||
};
|
|
||||||
|
|
||||||
networking.useDHCP = lib.mkDefault true;
|
|
||||||
|
|
||||||
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
|
|
||||||
|
|
||||||
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
|
|
||||||
}
|
|
||||||
|
|
@@ -1,11 +1,8 @@
|
|||||||
{ config, lib, pkgs, ... }:
|
{ config, pkgs, ... }:
|
||||||
let
|
let
|
||||||
snd-usb-audio-module = pkgs.callPackage ./snd-usb-audio.nix {
|
snd-usb-audio-module = pkgs.callPackage ./snd-usb-audio.nix {
|
||||||
kernel = config.boot.kernelPackages.kernel;
|
kernel = config.boot.kernelPackages.kernel;
|
||||||
};
|
};
|
||||||
patched = snd-usb-audio-module.overrideAttrs (prev: {
|
|
||||||
patches = [ ./0001-Update-device-ID-for-PreSonus-1824c.patch ];
|
|
||||||
});
|
|
||||||
upmixConfig = ''
|
upmixConfig = ''
|
||||||
stream.properties = {
|
stream.properties = {
|
||||||
channelmix.upmix = true
|
channelmix.upmix = true
|
||||||
@@ -13,9 +10,10 @@ let
|
|||||||
}
|
}
|
||||||
'';
|
'';
|
||||||
in {
|
in {
|
||||||
boot.kernelModules = [ "snd-usb-audio" ];
|
|
||||||
boot.extraModulePackages = [
|
boot.extraModulePackages = [
|
||||||
(patched)
|
(snd-usb-audio-module.overrideAttrs (_: {
|
||||||
|
patches = [ ./0001-Update-device-ID-for-PreSonus-1824c.patch ];
|
||||||
|
}))
|
||||||
];
|
];
|
||||||
|
|
||||||
environment.etc = {
|
environment.etc = {
|
||||||
|
@@ -64,9 +64,5 @@
|
|||||||
|
|
||||||
networking.useDHCP = lib.mkDefault true;
|
networking.useDHCP = lib.mkDefault true;
|
||||||
|
|
||||||
environment.systemPackages = [
|
|
||||||
pkgs.apfs-fuse
|
|
||||||
];
|
|
||||||
|
|
||||||
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
|
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
|
||||||
}
|
}
|
||||||
|
@@ -16,10 +16,3 @@ SD card | `/dev/mmcblk0` (ext4, NixOS Root)
|
|||||||
### Networks
|
### Networks
|
||||||
- DHCP on `10.0.1.0/24` subnet.
|
- DHCP on `10.0.1.0/24` subnet.
|
||||||
- Tailscale on `100.64.0.0/10` subnet. FQDN: `pi.mesh.vimium.net`.
|
- Tailscale on `100.64.0.0/10` subnet. FQDN: `pi.mesh.vimium.net`.
|
||||||
|
|
||||||
## Devices and connections
|
|
||||||
|
|
||||||
- SONOFF Zigbee 3.0 USB Dongle Plus (connected to USB 2.0 port to avoid [interference](https://www.unit3compliance.co.uk/2-4ghz-intra-system-or-self-platform-interference-demonstration/))
|
|
||||||
- HDMI to ONKYO HT-R990
|
|
||||||
- S/PDIF to ONKYO HT-R990
|
|
||||||
- Ethernet to ONKYO HT-R990
|
|
||||||
|
@@ -17,59 +17,8 @@
|
|||||||
};
|
};
|
||||||
deviceTree = {
|
deviceTree = {
|
||||||
enable = true;
|
enable = true;
|
||||||
filter = "*rpi-4-*.dtb";
|
|
||||||
overlays = [
|
overlays = [
|
||||||
{
|
{ name = "hifiberry-digi-pro"; dtboFile = "${pkgs.device-tree_rpi.overlays}/hifiberry-digi-pro.dtbo"; }
|
||||||
# Adapted from: https://github.com/raspberrypi/linux/blob/rpi-6.1.y/arch/arm/boot/dts/overlays/hifiberry-digi-pro-overlay.dts
|
|
||||||
# changes:
|
|
||||||
# - modified top-level "compatible" field from bcm2835 to bcm2711
|
|
||||||
# - s/i2s_clk_consumer/i2s/ (name on bcm2711 platform)
|
|
||||||
name = "hifiberry-digi-pro";
|
|
||||||
dtsText = ''
|
|
||||||
/dts-v1/;
|
|
||||||
/plugin/;
|
|
||||||
|
|
||||||
/ {
|
|
||||||
compatible = "brcm,bcm2711";
|
|
||||||
|
|
||||||
fragment@0 {
|
|
||||||
target = <&i2s>;
|
|
||||||
__overlay__ {
|
|
||||||
status = "okay";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
fragment@1 {
|
|
||||||
target = <&i2c1>;
|
|
||||||
__overlay__ {
|
|
||||||
#address-cells = <1>;
|
|
||||||
#size-cells = <0>;
|
|
||||||
status = "okay";
|
|
||||||
|
|
||||||
wm8804@3b {
|
|
||||||
#sound-dai-cells = <0>;
|
|
||||||
compatible = "wlf,wm8804";
|
|
||||||
reg = <0x3b>;
|
|
||||||
PVDD-supply = <&vdd_3v3_reg>;
|
|
||||||
DVDD-supply = <&vdd_3v3_reg>;
|
|
||||||
status = "okay";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
fragment@2 {
|
|
||||||
target = <&sound>;
|
|
||||||
__overlay__ {
|
|
||||||
compatible = "hifiberry,hifiberry-digi";
|
|
||||||
i2s-controller = <&i2s>;
|
|
||||||
status = "okay";
|
|
||||||
clock44-gpio = <&gpio 5 0>;
|
|
||||||
clock48-gpio = <&gpio 6 0>;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
'';
|
|
||||||
}
|
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
firmware = with pkgs; [
|
firmware = with pkgs; [
|
||||||
@@ -86,6 +35,7 @@
|
|||||||
alsa.enable = true;
|
alsa.enable = true;
|
||||||
alsa.support32Bit = true;
|
alsa.support32Bit = true;
|
||||||
pulse.enable = true;
|
pulse.enable = true;
|
||||||
|
systemWide = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
virtualisation.oci-containers = {
|
virtualisation.oci-containers = {
|
||||||
@@ -135,7 +85,6 @@
|
|||||||
network_key = "!secret.yaml network_key";
|
network_key = "!secret.yaml network_key";
|
||||||
pan_id = 13001;
|
pan_id = 13001;
|
||||||
ext_pan_id = [ 79 1 73 47 250 136 124 222 ];
|
ext_pan_id = [ 79 1 73 47 250 136 124 222 ];
|
||||||
transmit_power = 20;
|
|
||||||
};
|
};
|
||||||
mqtt = {
|
mqtt = {
|
||||||
version = 5;
|
version = 5;
|
||||||
|
@@ -30,6 +30,8 @@
|
|||||||
./security/gpg.nix
|
./security/gpg.nix
|
||||||
./security/pass.nix
|
./security/pass.nix
|
||||||
./services/borgmatic
|
./services/borgmatic
|
||||||
|
./services/coturn
|
||||||
|
./services/matrix
|
||||||
./shell/git
|
./shell/git
|
||||||
./shell/zsh
|
./shell/zsh
|
||||||
];
|
];
|
||||||
|
@@ -131,7 +131,6 @@ in {
|
|||||||
};
|
};
|
||||||
"org/gnome/mutter" = {
|
"org/gnome/mutter" = {
|
||||||
center-new-windows = true;
|
center-new-windows = true;
|
||||||
edge-tiling = true;
|
|
||||||
experimental-features = [ "scale-monitor-framebuffer" ];
|
experimental-features = [ "scale-monitor-framebuffer" ];
|
||||||
};
|
};
|
||||||
"org/gnome/desktop/interface" = {
|
"org/gnome/desktop/interface" = {
|
||||||
|
@@ -26,7 +26,7 @@ in {
|
|||||||
wireless = {
|
wireless = {
|
||||||
enable = true;
|
enable = true;
|
||||||
interfaces = cfg.interfaces;
|
interfaces = cfg.interfaces;
|
||||||
environmentFile = config.age.secrets."passwords/networks".path;
|
environmentFile = config.age.secrets.passwords/networks.path;
|
||||||
networks = {
|
networks = {
|
||||||
"Apollo 600 Mbps".psk = "@PSK_APOLLO@";
|
"Apollo 600 Mbps".psk = "@PSK_APOLLO@";
|
||||||
};
|
};
|
||||||
|
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