nixos/hosts/boron.cx.ts.hillion.co.uk/default.nix

171 lines
4.3 KiB
Nix
Raw Normal View History

2024-04-22 20:49:43 +01:00
{ config, pkgs, lib, ... }:
{
imports = [
./hardware-configuration.nix
];
config = {
system.stateVersion = "23.11";
networking.hostName = "boron";
networking.domain = "cx.ts.hillion.co.uk";
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
boot.kernelParams = [ "ip=dhcp" ];
boot.initrd = {
availableKernelModules = [ "igb" ];
network.enable = true;
clevis = {
enable = true;
useTang = true;
devices = {
"disk0-crypt".secretFile = "/data/disk_encryption.jwe";
"disk1-crypt".secretFile = "/data/disk_encryption.jwe";
2024-04-22 20:49:43 +01:00
};
};
};
custom.defaults = true;
## Kernel
### Explicitly use the latest kernel at time of writing because the LTS
### kernels available in NixOS do not seem to support this server's very
### modern hardware.
2024-07-27 15:16:59 +01:00
boot.kernelPackages = pkgs.linuxPackages_6_10;
2024-08-30 15:45:17 +01:00
### Apply patch to enable sched_ext which isn't yet available upstream.
boot.kernelPatches = [{
name = "sched_ext";
patch = pkgs.fetchpatch {
url = "https://github.com/sched-ext/scx-kernel-releases/releases/download/v6.10.3-scx1/linux-v6.10.3-scx1.patch.zst";
hash = "sha256-c4UlXsVOHGe0gvL69K9qTMWqCR8as25qwhfNVxCXUTs=";
decode = "${pkgs.zstd}/bin/unzstd";
excludes = [ "Makefile" ];
};
extraConfig = ''
BPF y
BPF_EVENTS y
BPF_JIT y
BPF_SYSCALL y
DEBUG_INFO_BTF y
FTRACE y
SCHED_CLASS_EXT y
'';
}];
## Enable btrfs compression
fileSystems."/data".options = [ "compress=zstd" ];
fileSystems."/nix".options = [ "compress=zstd" ];
2024-04-22 20:49:43 +01:00
## Impermanence
custom.impermanence = {
enable = true;
cache.enable = true;
};
boot.initrd.postDeviceCommands = lib.mkAfter ''
btrfs subvolume delete /cache/system
btrfs subvolume snapshot /cache/empty_snapshot /cache/system
'';
2024-04-22 20:49:43 +01:00
## Custom Services
custom = {
locations.autoServe = true;
2024-05-12 11:41:42 +01:00
www.global.enable = true;
2024-05-10 21:15:24 +01:00
services = {
gitea.actions = {
enable = true;
tokenSecret = ../../secrets/gitea/actions/boron.age;
};
};
2024-04-22 20:49:43 +01:00
};
2024-05-10 22:35:29 +01:00
services.nsd.interfaces = [
"138.201.252.214"
"2a01:4f8:173:23d2::2"
];
2024-04-22 20:49:43 +01:00
## Enable ZRAM to help with root on tmpfs
zramSwap = {
enable = true;
memoryPercent = 200;
algorithm = "zstd";
};
## Filesystems
services.btrfs.autoScrub = {
enable = true;
interval = "Tue, 02:00";
# By default both /data and /nix would be scrubbed. They are the same filesystem so this is wasteful.
fileSystems = [ "/data" ];
};
2024-09-06 18:41:28 +01:00
## General usability
### Make podman available for dev tools such as act
virtualisation = {
containers.enable = true;
podman = {
enable = true;
dockerCompat = true;
dockerSocket.enable = true;
};
};
users.users.jake.extraGroups = [ "podman" ];
2024-04-22 20:49:43 +01:00
## Networking
boot.kernel.sysctl = {
"net.ipv4.ip_forward" = true;
"net.ipv6.conf.all.forwarding" = true;
};
networking = {
useDHCP = false;
interfaces = {
enp6s0 = {
name = "eth0";
useDHCP = true;
ipv6.addresses = [{
address = "2a01:4f8:173:23d2::2";
prefixLength = 64;
}];
};
};
defaultGateway6 = {
address = "fe80::1";
interface = "eth0";
};
};
networking.firewall = {
trustedInterfaces = [ "tailscale0" ];
allowedTCPPorts = lib.mkForce [ ];
allowedUDPPorts = lib.mkForce [ ];
interfaces = {
eth0 = {
allowedTCPPorts = lib.mkForce [
2024-05-12 11:33:08 +01:00
22 # SSH
3022 # SSH (Gitea) - redirected to 22
2024-05-10 22:35:29 +01:00
53 # DNS
2024-05-12 11:41:42 +01:00
80 # HTTP 1-2
443 # HTTPS 1-2
2024-05-18 16:41:53 +01:00
8080 # Unifi (inform)
2024-04-22 20:49:43 +01:00
];
allowedUDPPorts = lib.mkForce [
2024-05-10 22:35:29 +01:00
53 # DNS
2024-05-12 11:41:42 +01:00
443 # HTTP 3
2024-05-18 16:41:53 +01:00
3478 # Unifi STUN
2024-04-22 20:49:43 +01:00
];
};
};
};
## Tailscale
age.secrets."tailscale/boron.cx.ts.hillion.co.uk".file = ../../secrets/tailscale/boron.cx.ts.hillion.co.uk.age;
services.tailscale = {
2024-04-22 20:49:43 +01:00
enable = true;
authKeyFile = config.age.secrets."tailscale/boron.cx.ts.hillion.co.uk".path;
2024-04-22 20:49:43 +01:00
};
};
}