nyx/hosts/theia/configuration.nix

305 lines
7 KiB
Nix
Raw Normal View History

2024-11-16 22:07:01 +00:00
{ config, modulesPath, lib, pkgs, ... }: {
2024-10-23 21:03:11 +00:00
system.stateVersion = "24.11";
2024-10-24 09:31:32 +00:00
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
imports = [ (modulesPath + "/profiles/qemu-guest.nix") ];
boot = {
initrd.availableKernelModules = [
"ata_piix"
"uhci_hcd"
"virtio_pci"
"virtio_scsi"
"ahci"
"sd_mod"
"sr_mod"
"virtio_blk"
];
initrd.kernelModules = [ ];
kernelPackages = pkgs.linuxPackages_6_12;
2024-10-24 09:31:32 +00:00
kernelModules = [ "kvm-amd" ];
2024-12-05 14:21:51 +00:00
kernel = {
sysctl = {
"vm.max_map_count" = 2147483642;
"net.ipv4.ip_forward" = 1;
"net.ipv6.conf.all.forwarding" = 1;
};
};
2024-10-24 09:31:32 +00:00
extraModulePackages = [ ];
loader.grub = {
enable = true;
device = "/dev/vda";
};
};
2024-10-23 21:03:11 +00:00
2024-11-03 19:31:25 +00:00
nix = {
package = pkgs.lix;
2024-11-07 22:17:24 +00:00
settings = {
experimental-features = [ "nix-command" "flakes" ];
auto-optimise-store = true;
sandbox = true;
};
2024-11-03 19:31:25 +00:00
};
2024-10-24 09:31:32 +00:00
zramSwap = {
2024-10-23 21:03:11 +00:00
enable = true;
2024-10-24 09:31:32 +00:00
algorithm = "zstd";
memoryPercent = 50;
};
fileSystems."/" = {
device = "/dev/disk/by-uuid/09e65ff9-2195-41d8-b6a4-671c306742c3";
fsType = "ext4";
};
fileSystems."/boot" = {
device = "/dev/disk/by-uuid/FED3-A372";
fsType = "vfat";
options = [ "fmask=0022" "dmask=0022" ];
2024-10-23 21:03:11 +00:00
};
networking = {
2024-10-25 06:29:48 +00:00
enableIPv6 = false; # Had to disable for now due to problems with resolving
firewall = {
allowedTCPPorts = [
80 # HTTP
443 # HTTPS
222 # git over ssh
2024-11-18 11:32:02 +00:00
25565 # minecraft
];
allowedUDPPorts = [
25565 # minecraft
];
};
2024-10-24 09:31:32 +00:00
hostName = "theia";
2024-10-24 14:40:25 +00:00
nameservers = [ "1.1.1.1" "8.8.8.8" "9.9.9.9" ];
domain = "theia.blahai.gay";
2024-10-23 21:03:11 +00:00
useDHCP = lib.mkDefault false;
defaultGateway = {
address = "178.63.247.183";
interface = "ens3";
};
interfaces = {
ens3 = {
ipv4 = {
2024-10-24 09:31:32 +00:00
addresses = [{
address = "178.63.118.252";
prefixLength = 32;
}];
routes = [{
address = "178.63.247.183";
prefixLength = 32;
}];
2024-10-23 21:03:11 +00:00
};
};
};
};
2024-10-24 09:31:32 +00:00
services = {
2024-12-05 14:21:51 +00:00
tailscale = {
enable = true;
useRoutingFeatures = "server";
openFirewall = true;
};
networkd-dispatcher = {
enable = true;
rules."50-tailscale" = {
onState = [ "routable" ];
script = ''
2024-12-09 15:04:45 +00:00
${
lib.getExe pkgs.ethtool
} -K ens3 rx-udp-gro-forwarding on rx-gro-list off
2024-12-05 14:21:51 +00:00
'';
};
};
2024-10-24 14:40:25 +00:00
earlyoom = {
enable = true;
extraArgs = let
avoid = lib.concatStringsSep "|" [
"cryptsetup"
"dbus-.*"
"gpg-agent"
"ssh-agent"
"sshd"
"systemd"
"systemd-.*"
"bash"
"fish"
"n?vim"
];
prefer =
lib.concatStringsSep "|" [ "dotnet" "java.*" "nix" "npm" "node" ];
in [
"-g"
"--avoid '(^|/)(${avoid})'" # things that we want to avoid killing
"--prefer '(^|/)(${prefer})'" # things we want to remove fast
];
};
2024-10-24 14:40:25 +00:00
caddy = {
enable = true;
virtualHosts = {
"git.blahai.gay" = {
extraConfig = ''
reverse_proxy localhost:3000
'';
};
"vault.blahai.gay" = {
extraConfig = ''
reverse_proxy localhost:8222 {
header_up X-Real-IP {remote_host}
}
'';
};
"search.blahai.gay" = {
extraConfig = ''
reverse_proxy localhost:8888
'';
};
2024-10-25 06:29:48 +00:00
2024-11-07 17:18:25 +00:00
"kuma.blahai.gay" = {
2024-10-25 06:29:48 +00:00
extraConfig = ''
reverse_proxy localhost:3001
'';
};
};
};
uptime-kuma = {
enable = true;
settings = { PORT = "3001"; };
2024-10-24 14:40:25 +00:00
};
forgejo = {
2024-10-25 15:55:05 +00:00
package = pkgs.forgejo;
2024-10-24 14:40:25 +00:00
enable = true;
2024-12-09 15:04:45 +00:00
lfs.enable = true;
2024-10-24 14:40:25 +00:00
settings = {
2024-12-09 15:04:45 +00:00
"ui.meta" = {
AUTHOR = "Elissa";
DESCRIPTION = "My own selfhosted git place for random stuff :3";
};
2024-10-24 14:40:25 +00:00
DEFAULT.APP_NAME = "githai";
federation.ENABLED = true;
2024-12-09 15:04:45 +00:00
service.DISABLE_REGISTRATION = true;
actions = {
ENABLED = true;
DEFAULT_ACTIONS_URL = "github";
};
2024-10-24 14:40:25 +00:00
server = {
ROOT_URL = "https://git.blahai.gay";
DOMAIN = "git.blahai.gay";
SSH_PORT = 222;
SSH_LISTEN_PORT = 222;
};
};
};
vaultwarden = {
enable = true;
config = {
DOMAIN = "https://vault.blahai.gay";
ROCKET_PORT = 8222;
};
};
searx = {
enable = true;
redisCreateLocally = true;
2024-10-24 14:40:25 +00:00
settings = {
use_default_settings = true;
server = {
port = 8888;
secret_key =
"7360d3df7c08ce681cf6d5122e3e182de2c5205e962766abd3e6dfc8dec1b683";
2024-10-24 14:40:25 +00:00
};
ui = { infinite_scroll = true; };
2024-10-24 14:40:25 +00:00
general = {
instance_name = "searchai";
debug = false;
};
search = {
safe_search = 0;
2024-10-24 14:40:25 +00:00
autocomplete = "google";
default_lang = "en";
};
};
};
2024-10-24 09:31:32 +00:00
openssh = {
enable = true;
2024-10-24 14:40:25 +00:00
openFirewall = true;
2024-10-24 09:31:32 +00:00
settings = { PasswordAuthentication = false; };
};
fail2ban = {
enable = true;
maxretry = 5;
bantime = "24h"; # Ban IPs for one day on the first ban
bantime-increment = {
enable = true; # Enable increment of bantime after each violation
overalljails = true; # Calculate the bantime based on all the violations
};
};
};
programs = { nix-ld.enable = true; };
2024-10-24 09:31:32 +00:00
users.users.root = {
openssh.authorizedKeys.keys = [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILPbmiNqoyeKXk/VopFm2cFfEnV4cKCFBhbhyYB69Fuu"
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILLqPq70t6RbnI8UejEshYcfBP66I4OrLFjvGLLfIEXD"
];
initialHashedPassword =
"$y$j9T$TzqbL4iMGLjli6EEXfRCZ0$AhFJ4iCFxRlstth5owic3M5nq74Sp1qhtctjSBcgAl8";
2024-10-23 21:03:11 +00:00
};
2024-10-24 09:31:32 +00:00
users.users.pingu = {
isNormalUser = true;
extraGroups = [ "wheel" ];
2024-10-23 21:03:11 +00:00
openssh.authorizedKeys.keys = [
2024-10-24 09:31:32 +00:00
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILPbmiNqoyeKXk/VopFm2cFfEnV4cKCFBhbhyYB69Fuu"
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILLqPq70t6RbnI8UejEshYcfBP66I4OrLFjvGLLfIEXD"
2024-10-23 21:03:11 +00:00
];
2024-10-24 09:31:32 +00:00
initialHashedPassword =
"$y$j9T$cxwKGmzYyC1eLeIysr8r/.$dsxxxV4NvXY.Wpd9LO.RiuMQuy2lYyy2HGrk52BJX08";
2024-10-23 21:03:11 +00:00
};
2024-10-24 09:31:32 +00:00
users.users.minecraft = {
isNormalUser = true;
openssh.authorizedKeys.keys = [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILPbmiNqoyeKXk/VopFm2cFfEnV4cKCFBhbhyYB69Fuu" # nyx
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILLqPq70t6RbnI8UejEshYcfBP66I4OrLFjvGLLfIEXD" # laptop
];
packages = with pkgs; [
openjdk21
openjdk17
screen
];
initialHashedPassword =
"$y$j9T$KpQYYLB6eWfHAUo9.o/uy1$gnj/UlWLrx5XBZDm2GNdjHs2G5D3XxxqqtrCIf5MX43";
};
2024-10-24 09:31:32 +00:00
environment.systemPackages = with pkgs; [
git
curl
bat
neovim
btop
zip
jq
busybox
fish
2024-12-05 14:21:51 +00:00
ethtool
networkd-dispatcher
2024-10-24 09:31:32 +00:00
];
2024-10-23 21:03:11 +00:00
}