2025-01-02 15:46:08 +02:00
|
|
|
{ pkgs, ... }:
|
2024-05-23 13:39:48 +03:00
|
|
|
let
|
2024-12-30 20:27:24 +02:00
|
|
|
# SSID = "ENTER_SSID";
|
|
|
|
# SSIDpassword = "ENTER_PASSWORD";
|
|
|
|
# interface = "wlan0";
|
2024-06-02 05:53:39 +03:00
|
|
|
wg_interface = "end0";
|
|
|
|
hostname = "netflix-huijaus";
|
|
|
|
ddPassFile = "/root/wg-conf/ddPassFile";
|
2024-06-02 16:18:19 +03:00
|
|
|
in
|
|
|
|
{
|
|
|
|
imports = [ ../base.nix ];
|
2024-05-23 13:39:48 +03:00
|
|
|
|
2024-06-02 16:18:19 +03:00
|
|
|
environment.systemPackages = with pkgs; [
|
|
|
|
wireguard-tools
|
|
|
|
qrencode
|
|
|
|
];
|
2024-05-23 13:39:48 +03:00
|
|
|
|
|
|
|
# enable NAT
|
|
|
|
networking.nat.enable = true;
|
|
|
|
networking.nat.externalInterface = wg_interface;
|
|
|
|
networking.nat.internalInterfaces = [ "wg0" ];
|
|
|
|
networking.firewall = {
|
|
|
|
allowedUDPPorts = [ 51821 ];
|
|
|
|
};
|
|
|
|
|
|
|
|
networking.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.100.0.1/24" ];
|
|
|
|
|
|
|
|
# The port that WireGuard listens to. Must be accessible by the client.
|
|
|
|
listenPort = 51821;
|
|
|
|
|
|
|
|
# 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 = ''
|
2024-06-02 16:18:19 +03:00
|
|
|
${pkgs.iptables}/bin/iptables -t nat -A POSTROUTING -s 10.100.0.0/24 -o ${wg_interface} -j MASQUERADE
|
2024-05-23 13:39:48 +03:00
|
|
|
'';
|
|
|
|
|
2024-06-02 05:53:39 +03:00
|
|
|
# This undoes the above command
|
|
|
|
postShutdown = ''
|
2024-06-02 16:18:19 +03:00
|
|
|
${pkgs.iptables}/bin/iptables -t nat -D POSTROUTING -s 10.100.0.0/24 -o ${wg_interface} -j MASQUERADE
|
2024-05-23 13:39:48 +03:00
|
|
|
'';
|
2024-06-02 05:53:39 +03:00
|
|
|
|
2024-05-23 13:39:48 +03:00
|
|
|
# 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 = "/root/wg-conf/private";
|
|
|
|
|
|
|
|
peers = [
|
2024-06-02 16:18:19 +03:00
|
|
|
{
|
|
|
|
# Vili Android
|
2024-05-23 13:39:48 +03:00
|
|
|
publicKey = "niKpC3+Pi4HrYITlzROzqRcxzfzRw1rjpxeJVOr/WAw=";
|
|
|
|
allowedIPs = [ "10.100.0.2/32" ];
|
|
|
|
}
|
2024-06-02 16:18:19 +03:00
|
|
|
{
|
|
|
|
# Miika Puhelin
|
2024-05-23 13:39:48 +03:00
|
|
|
publicKey = "mcOs94W9jqn3SGgc8uWbnmUv0tja/P6tAvaCg3WYKlY=";
|
|
|
|
allowedIPs = [ "10.100.0.3/32" ];
|
|
|
|
}
|
2024-06-02 16:18:19 +03:00
|
|
|
{
|
|
|
|
# Miika Kone
|
2024-05-23 13:39:48 +03:00
|
|
|
publicKey = "7m7wnwNlmxZfUNvUOYNh4mTNbOsig7z2K/svUhDHFDY=";
|
|
|
|
allowedIPs = [ "10.100.0.4/32" ];
|
|
|
|
}
|
2024-06-02 16:18:19 +03:00
|
|
|
{
|
|
|
|
# Silja Puhelin
|
2024-05-23 13:39:48 +03:00
|
|
|
publicKey = "f6wWd6KD63xwnKkre/ZgZxPJv9GfAXK9Zx/EQEq8cik=";
|
|
|
|
allowedIPs = [ "10.100.0.5/32" ];
|
|
|
|
}
|
2024-06-02 16:18:19 +03:00
|
|
|
{
|
|
|
|
# Silja Kone
|
2024-05-23 13:39:48 +03:00
|
|
|
publicKey = "t9cmHc6/+0njdzsTFnnhEGKfhCa2VXFrTH9hF1jOCXw=";
|
|
|
|
allowedIPs = [ "10.100.0.6/32" ];
|
|
|
|
}
|
2024-06-02 16:18:19 +03:00
|
|
|
{
|
|
|
|
# Vili helium
|
2024-05-23 13:39:48 +03:00
|
|
|
publicKey = "iGO375NT9EK5LH+E9vjPRRJp+UM4rZ2d1RMVR3f5R0c=";
|
|
|
|
allowedIPs = [ "10.100.0.7/32" ];
|
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-06-02 05:53:39 +03:00
|
|
|
services.ddclient = {
|
|
|
|
enable = true;
|
2025-01-16 15:59:03 +02:00
|
|
|
usev6 = "";
|
|
|
|
domains = [ "netflix.vsinerva.fi" ];
|
|
|
|
server = "www.ovh.com";
|
|
|
|
username = "vsinerva.fi-dynraspi";
|
2024-06-02 05:53:39 +03:00
|
|
|
passwordFile = ddPassFile;
|
|
|
|
};
|
2024-06-02 16:18:19 +03:00
|
|
|
#################### EVERYTHING BELOW THIS SHOULD NOT NEED TO CHANGE ####################
|
2024-05-23 13:39:48 +03:00
|
|
|
|
2024-07-16 22:25:30 +03:00
|
|
|
nix.settings = {
|
|
|
|
cores = 3;
|
|
|
|
max-jobs = 2;
|
|
|
|
};
|
|
|
|
|
2024-06-02 05:53:39 +03:00
|
|
|
boot = {
|
|
|
|
kernelPackages = pkgs.linuxKernel.packages.linux_rpi4;
|
2024-06-02 16:18:19 +03:00
|
|
|
initrd.availableKernelModules = [
|
|
|
|
"xhci_pci"
|
|
|
|
"usbhid"
|
|
|
|
"usb_storage"
|
|
|
|
];
|
2024-06-02 05:53:39 +03:00
|
|
|
loader = {
|
2025-01-16 16:14:14 +02:00
|
|
|
timeout = 5;
|
|
|
|
systemd-boot.enable = false;
|
2024-06-02 05:53:39 +03:00
|
|
|
grub.enable = false;
|
|
|
|
generic-extlinux-compatible.enable = true;
|
|
|
|
};
|
|
|
|
};
|
2024-05-23 13:39:48 +03:00
|
|
|
|
2024-06-02 05:53:39 +03:00
|
|
|
fileSystems = {
|
|
|
|
"/" = {
|
|
|
|
device = "/dev/disk/by-label/NIXOS_SD";
|
|
|
|
fsType = "ext4";
|
|
|
|
options = [ "noatime" ];
|
|
|
|
};
|
|
|
|
};
|
2024-05-23 13:39:48 +03:00
|
|
|
|
2024-12-30 20:27:24 +02:00
|
|
|
hardware.enableRedistributableFirmware = true;
|
|
|
|
|
2024-06-02 05:53:39 +03:00
|
|
|
networking = {
|
|
|
|
hostName = hostname;
|
|
|
|
wireless = {
|
|
|
|
enable = false;
|
2024-12-30 20:27:24 +02:00
|
|
|
# networks."${SSID}".psk = SSIDpassword;
|
|
|
|
# interfaces = [ interface ];
|
2024-06-02 05:53:39 +03:00
|
|
|
};
|
|
|
|
};
|
2024-05-23 13:39:48 +03:00
|
|
|
}
|