nas fixes

This commit is contained in:
mjallen18
2024-10-18 09:32:20 -05:00
parent 180c7abdf7
commit 5ddc18485b
9 changed files with 150 additions and 32 deletions

View File

@@ -175,7 +175,7 @@ in
workspace = [
"name:firefox, monitor:DP-2, default:false, special, firefox"
"name:discord, monitor:DP-2, default:true, special, vesktop, spotify"
"name:steam, monitor:DP-2, default:false, special, steam"
"name:steam, monitor:DP-1, default:false, special, steam"
];
windowrule = [

View File

@@ -19,6 +19,12 @@ in
};
};
kernel.sysctl = {
"net.ipv4.ip_forward" = 1;
"net.ipv6.conf.all.forwarding" = 1;
"vm.swappiness" = 60;
};
# Override kernel to latest
kernelPackages = kernel;

View File

@@ -106,6 +106,7 @@ in
protonmail-bridge
protonvpn-cli
python3
qrencode
rcon
sbctl
speedtest-cli
@@ -185,6 +186,7 @@ in
aha
papirus-icon-theme
firefox
swtpm
];
};
@@ -258,6 +260,9 @@ in
};
libvirtd.enable = true;
# tpm.enable = true;
# useSecureBoot = true;
};
# This option defines the first version of NixOS you have installed on this particular machine,

View File

@@ -1,9 +1,17 @@
{ config, ... }:
{ config, pkgs, ... }:
let
hostname = "jallen-nas";
ipAddress = "10.0.1.18";
ipAddress2 = "10.0.1.19";
gateway = "10.0.1.1";
ports = [
9000 # authentik
2342 # grafana
51820 # wireguard
];
wireguard-private = config.sops.secrets."jallen-nas/wireguard/private".path;
wireguard-public = "r03IJPnTaSNmhVYIdQr+TGasox6NAUrgW8ycm/sac08=";
in
{
# Networking configs
@@ -65,10 +73,10 @@ in
ieee80211w=2
'';
};
"Joey's Jungle 5G" = {
pskRaw = "ext:PSK";
priority = -100;
};
# "Joey's Jungle 5G" = {
# pskRaw = "ext:PSK";
# priority = -100;
# };
};
};
@@ -76,8 +84,56 @@ in
enable = true;
allowPing = true;
allowedTCPPorts = ports;
allowedUDPPorts = ports;
# always allow traffic from your Tailscale network
trustedInterfaces = [ "tailscale0" ];
};
nat = {
enable = true;
externalInterface = "wlp7s0";
internalInterfaces = [ "wg0" ];
};
wireguard.interfaces = {
# "wg0" is the network interface name. You can name the interface arbitrarily.
wg0 = {
# Determines the IP address and subnet of the server's end of the tunnel interface.
ips = [ "10.0.100.1/24" ];
# The port that WireGuard listens to. Must be accessible by the client.
listenPort = 51820;
# This allows the wireguard server to route your traffic to the internet and hence be like a VPN
# For this to work you have to set the dnsserver IP of your router (or dnsserver of choice) in your clients
postSetup = ''
${pkgs.iptables}/bin/iptables -t nat -A POSTROUTING -s 10.0.100.0/24 -o wlp7s0 -j MASQUERADE
'';
# This undoes the above command
postShutdown = ''
${pkgs.iptables}/bin/iptables -t nat -D POSTROUTING -s 10.0.100.0/24 -o wlp7s0 -j MASQUERADE
'';
# Path to the private key file.
#
# Note: The private key can also be included inline via the privateKey option,
# but this makes the private key world-readable; thus, using privateKeyFile is
# recommended.
privateKeyFile = wireguard-private;
peers = [
# List of allowed peers.
{ # Feel free to give a meaning full name
# Public key of the peer (not a file path).
publicKey = wireguard-public;
# List of IPs assigned to this peer within the tunnel subnet. Used to configure routing.
allowedIPs = [ "10.0.100.2/32" ];
}
];
};
};
};
}

View File

@@ -1,4 +1,4 @@
{ pkgs, ... }:
{ config, pkgs, ... }:
let
enableDisplayManager = true;
in
@@ -131,7 +131,11 @@ in
enable = true;
openFirewall = true;
useRoutingFeatures = "client";
extraUpFlags = [ "--advertise-exit-node" ];
extraUpFlags = [
"--advertise-exit-node"
"--accept-dns=false"
"--advertise-routes=10.0.1.0/24"
];
extraSetFlags = [
"--advertise-exit-node"
"--hostname=jallen-nas"
@@ -194,6 +198,59 @@ in
};
};
};
grafana = {
enable = true;
settings.server = {
http_port = 2342;
domain = "10.0.1.18";
serve_from_sub_path = true;
http_addr = "";
};
dataDir = "/media/nas/ssd/nix-app-data/grafana";
};
prometheus = {
enable = true;
port = 8000;
exporters = {
node = {
enable = true;
enabledCollectors = [
"diskstats"
"systemd"
];
port = 8001;
};
smartctl = {
enable = true;
group = "disk";
devices = [
"/dev/mapper/ssd1"
"/dev/mapper/ssd2"
"/dev/mapper/hdd1"
"/dev/mapper/hdd2"
"/dev/mapper/hdd3"
"/dev/mapper/hdd4"
"/dev/mapper/hdd5"
];
};
};
scrapeConfigs = [
{
job_name = "jallen-nas";
static_configs = [
{
targets = [
"127.0.0.1:${toString config.services.prometheus.exporters.node.port}"
"127.0.0.1:${toString config.services.prometheus.exporters.smartctl.port}"
];
}
];
}
];
};
};
systemd.user.services = {

View File

@@ -61,6 +61,18 @@
restartUnits = [ "podman-immich-server.service" ];
};
sops.secrets."jallen-nas/wireguard/private" = {
# restartUnits = [ "podman-immich-server.service" ];
};
sops.secrets."jallen-nas/wireguard/public" = {
# restartUnits = [ "podman-immich-server.service" ];
};
sops.templates."wireguard-public".content = ''
"${config.sops.placeholder."jallen-nas/wireguard/public"}"
'';
# Permission modes are in octal representation (same as chmod),
# the digits represent: user|group|others
# 7 - full (rwx)