This repository has been archived on 2024-10-19. You can view files and clone it, but cannot push or open issues or pull requests.
server-nixos-config/configuration.nix

352 lines
8 KiB
Nix
Raw Permalink Normal View History

2024-08-23 00:35:09 -04:00
{ config, pkgs, options, lib, ... }:
let
# Import home manager
homeManager = fetchTarball
"https://github.com/nix-community/home-manager/archive/release-24.05.tar.gz";
# Secrets and passwords
secrets = import ./secrets.nix;
in
{
imports = [
./hardware-configuration.nix
2024-08-27 14:23:50 -04:00
./freecorn.nix
./jimbo.nix
./vaultwarden.nix
2024-10-18 22:30:36 -04:00
"${homeManager}/nixos"
# ./wireguard.nix
# ./neovim.nix
2024-08-23 00:35:09 -04:00
];
2024-08-27 14:31:28 -04:00
# Bootloader
2024-08-27 14:23:50 -04:00
boot.loader.grub = {
enable = true;
device = "/dev/sda";
};
2024-08-23 00:35:09 -04:00
# Enable network manager applet
programs.nm-applet.enable = true;
# Set your time zone.
time.timeZone = secrets.timeZone;
# Select internationalisation properties.
i18n.defaultLocale = "en_CA.UTF-8";
2024-09-27 16:05:28 -04:00
# allow non nix programs to run
programs.nix-ld.enable = true;
programs.nix-ld.libraries = with pkgs; [
# Add any missing dynamic libraries for unpackaged programs
# here, NOT in environment.systemPackages
];
2024-08-23 00:35:09 -04:00
# Enable the X11 windowing system.
2024-09-15 17:57:41 -04:00
# services.xserver = {
# enable = true;
# videoDrivers = [ "radeon" ];
# xkb = {
# layout = "us";
# variant = "";
# };
2024-08-27 14:28:54 -04:00
# Enable the LXQT Desktop Environment.
2024-09-15 17:57:41 -04:00
# displayManager.lightdm.enable = true;
# desktopManager.lxqt.enable = true;
2024-09-22 16:42:26 -04:00
# };
# Enable automatic login for the user.
# services.displayManager.autoLogin = {
# enable = true;
# user = "freecorn";
# };
# Enable sound with pipewire.
# hardware.pulseaudio.enable = false;
# security.rtkit.enable = true;
# services.pipewire = {
# enable = true;
# alsa.enable = true;
# alsa.support32Bit = true;
# pulse.enable = true;
# };
# OpenGL and drivers
# hardware.opengl = {
# enable = true;
# driSupport = true;
# driSupport32Bit = true;
2024-09-15 17:57:41 -04:00
# };
2024-08-23 00:35:09 -04:00
# Printer Stuff (FUCK HP!)
2024-10-09 22:13:22 -04:00
# services = {
# printing = {
# listenAddresses = [ "*:631" ];
# allowFrom = [ "all" ];
# browsing = true;
# defaultShared = true;
# openFirewall = true;
# enable = true;
# drivers = [ pkgs.hplip ];
# webInterface = true;
# };
# avahi = {
# nssmdns4 = true;
# openFirewall = true;
# publish = {
# enable = true;
# userServices = true;
# };
# };
# };
2024-08-23 00:35:09 -04:00
2024-09-22 16:42:26 -04:00
# Install fonts, need this for orbitron!
# fonts.packages = with pkgs; [
# orbitron
# ];
2024-09-29 04:37:29 -04:00
# systemd.services.rtl_tcp = {
# enable = true;
# description = "rtl_tcp";
# unitConfig = {
# Type = "simple";
# # ...
# };
# serviceConfig = {
# ExecStart = "rtl_tcp -a 10.0.0.240";
# # ...
# };
#}
2024-08-23 00:35:09 -04:00
2024-09-22 18:55:25 -04:00
# Define a users and groups
users = {
groups = {
nfsShare = {};
};
users.nextcloud = {
extraGroups = [ "nfsShare" ];
isSystemUser = true;
};
2024-08-27 17:57:17 -04:00
};
2024-08-23 00:35:09 -04:00
# RTL-SDR Support
hardware.rtl-sdr.enable = true;
boot.kernelParams = [ "modprobe.blacklist=dvb_usb_rtl28xxu" ]; # blacklist dunb driver
# Docker :(((
virtualisation.docker.enable = true;
2024-08-23 00:35:09 -04:00
# OpenWebRX
2024-08-27 14:23:50 -04:00
# services.openwebrx.enable = true;
2024-08-23 00:35:09 -04:00
2024-09-14 02:31:05 -04:00
# PufferPannel
services = {
pufferpanel = {
enable = true;
environment = {
PUFFER_WEB_HOST = ":5010";
PUFFER_PANEL_SETTINGS_MASTERURL = "https://ppanel.${secrets.cornDomain}";
PUFFER_PANEL_REGISTRATIONENABLED = "false";
2024-09-14 02:31:05 -04:00
# PUFFER_PANEL_EMAIL_PROVIDER = "smtp";
# PUFFER_PANEL_EMAIL_HOST = "mx.${outputs.secrets.jimDomain}:587";
# PUFFER_PANEL_EMAIL_FROM = "noreply@${outputs.secrets.jimDomain}";
# PUFFER_PANEL_EMAIL_USERNAME = "noreply@${outputs.secrets.jimDomain}";
# PUFFER_PANEL_EMAIL_PASSWORD = outputs.secrets.noreplyPassword;
};
extraPackages = with pkgs; [ bash curl gawk gnutar gzip ];
package = pkgs.buildFHSEnv {
name = "pufferpanel-fhs";
meta.mainProgram = "pufferpanel-fhs";
runScript = lib.getExe pkgs.pufferpanel;
targetPkgs = pkgs': with pkgs'; [ icu openssl zlib ];
};
};
};
2024-08-23 00:35:09 -04:00
# NGINX :3
services.nginx = {
enable = true;
package = (pkgs.nginx.override {
modules = with pkgs.nginxModules; [ rtmp ];
});
recommendedTlsSettings = true;
recommendedOptimisation = true;
recommendedGzipSettings = true;
recommendedProxySettings = true;
# Homepage HTML
2024-08-23 01:05:44 -04:00
virtualHosts = {
"${secrets.cornDomain}" = {
2024-08-23 00:35:09 -04:00
enableACME = true;
addSSL = true;
root = "/var/www/cornweb";
};
# non-free websites
2024-08-23 01:05:44 -04:00
"nonfree.${secrets.cornDomain}" = {
2024-08-23 00:35:09 -04:00
enableACME = true;
forceSSL = true;
root = "/var/www/non-free";
};
# websdr server
2024-09-14 02:34:59 -04:00
"ppanel.${secrets.cornDomain}" = {
2024-08-23 00:35:09 -04:00
enableACME = true;
forceSSL = true;
locations."/" = {
2024-09-14 02:31:05 -04:00
proxyPass = "http://127.0.0.1:5010";
2024-08-23 00:35:09 -04:00
proxyWebsockets = true;
2024-08-23 01:11:57 -04:00
};
2024-08-23 00:35:09 -04:00
};
2024-08-23 01:01:32 -04:00
2024-08-27 17:57:17 -04:00
# Nextcloud Proxy
"cloud.${secrets.cornDomain}" = {
enableACME = true;
addSSL = true;
locations."/" = {
proxyWebsockets = true;
extraConfig = ''
location /.well-known/carddav {
return 301 $scheme://$host/remote.php/dav;
}
location /.well-known/caldav {
return 301 $scheme://$host/remote.php/dav;
}
'';
};
};
2024-08-23 01:05:44 -04:00
};
2024-08-23 00:35:09 -04:00
appendConfig = ''
rtmp {
server {
listen 1935;
chunk_size 4096;
allow publish all;
application stream {
record off;
live on;
allow play all;
}
}
}
'';
};
2024-08-27 17:57:17 -04:00
# Nextcloud server
services.nextcloud = {
enable = true;
package = pkgs.nextcloud29;
hostName = "cloud.${secrets.cornDomain}";
datadir = "/mnt/nextcloud";
https = true;
config = {
adminuser = "freecorn";
adminpassFile = "/mnt/nextcloud/password.txt";
};
settings = {
trusted_proxies = [ "127.0.0.1" ];
trusted_domains = [ "cloud.${secrets.cornDomain}" ];
overwriteprotocol = "https";
};
};
2024-08-23 01:01:32 -04:00
2024-08-23 00:35:09 -04:00
# Get certificates for Coturn
security.acme = {
acceptTerms = true;
defaults.email = secrets.cornEmail;
};
# Allow unfree packages
nixpkgs.config.allowUnfree = true;
# Packages installed in system profile
environment.systemPackages = with pkgs; [
2024-09-22 16:42:26 -04:00
# firefox
2024-08-27 14:23:50 -04:00
wget
x11vnc
fastfetch
ffmpeg
system-config-printer
libcaption
git
rtl-sdr
steam-run
2024-09-14 02:31:05 -04:00
# openwebrx
qbittorrent
2024-10-18 22:30:36 -04:00
vim
2024-08-23 00:35:09 -04:00
];
# Enable the OpenSSH daemon.
services.openssh = {
enable = true;
2024-08-27 14:23:50 -04:00
settings = {
PermitRootLogin = "no";
PrintLastLog = "no";
2024-08-27 14:53:26 -04:00
PasswordAuthentication = false;
2024-08-27 14:23:50 -04:00
};
2024-08-27 17:57:17 -04:00
openFirewall = true;
2024-08-23 00:35:09 -04:00
};
2024-09-22 16:42:26 -04:00
# Hostname and networking
networking = {
hostName = "freecornserver";
networkmanager.enable = true;
firewall = {
allowedTCPPorts = [
1935 # RTMP
2024-09-27 16:05:28 -04:00
# 4455 # VR
2024-09-22 16:42:26 -04:00
80 443 # Nginx
2024-09-27 16:05:28 -04:00
1234 # rtl_tcp
# 25565 # minecraft port
8222
2024-09-22 16:42:26 -04:00
];
allowedUDPPorts = [
2024-09-27 16:05:28 -04:00
# 4455
# 24454 # minecraft vc mod
2024-09-22 16:42:26 -04:00
];
2024-09-22 18:01:25 -04:00
# Add extra input rules using nftables
extraInputRules = ''
2024-09-27 16:05:28 -04:00
ip saddr { 10.0.0.124, ${secrets.jimIP1}, ${secrets.jimIP2}, ${secrets.lunaIP} } tcp dport 2049 accept comment "Accept NFS"
2024-09-22 18:01:25 -04:00
'';
2024-09-22 16:42:26 -04:00
};
2024-09-22 18:01:25 -04:00
nftables = {
enable = true;
tables = {
forwarding = {
family = "ip";
content = ''
chain PREROUTING {
type nat hook prerouting priority dstnat; policy accept;
tcp dport { 9943, 9944 } dnat to 10.0.0.97 comment "ALVR"
}
chain POSTROUTING {
type nat hook postrouting priority 100; policy accept;
oifname "enp2s0" masquerade
}
'';
};
};
};
};
2024-10-18 22:30:36 -04:00
# :3
2024-09-22 18:01:25 -04:00
# NFS server
2024-09-29 04:37:29 -04:00
# services.nfs.server = {
# enable = true;
# exports = ''
# /export/freecornNFS *(rw,no_subtree_check)
# '';
# };
2024-08-23 00:35:09 -04:00
# Copy and link the NixOS configuration file to (/run/current-system/configuration.nix).
system.copySystemConfiguration = true;
# Don't change this
system.stateVersion = "24.05";
}