2024-01-08 15:58:04 +01:00
|
|
|
{
|
2024-01-11 23:51:46 +01:00
|
|
|
lib,
|
2024-01-08 15:58:04 +01:00
|
|
|
pkgs,
|
2024-12-04 00:58:44 +01:00
|
|
|
inputs,
|
|
|
|
outputs,
|
2024-12-04 17:56:37 +01:00
|
|
|
config,
|
2024-12-04 00:58:44 +01:00
|
|
|
modulesPath,
|
2024-01-08 15:58:04 +01:00
|
|
|
...
|
2024-12-05 14:16:40 +01:00
|
|
|
}: {
|
2024-01-08 16:24:38 +01:00
|
|
|
imports = [
|
2024-12-04 15:58:23 +01:00
|
|
|
# inputs.nixos-hardware.nixosModules.raspberry-pi-4
|
2024-12-04 00:58:44 +01:00
|
|
|
(modulesPath + "/installer/sd-card/sd-image-aarch64.nix")
|
2024-01-11 14:51:11 +01:00
|
|
|
|
2024-12-04 16:00:43 +01:00
|
|
|
./hardware-configuration.nix
|
2024-12-04 15:58:23 +01:00
|
|
|
|
2024-12-04 00:58:44 +01:00
|
|
|
# Import shared settings
|
|
|
|
../../shared
|
2024-01-08 15:58:04 +01:00
|
|
|
];
|
|
|
|
|
2024-12-04 00:58:44 +01:00
|
|
|
nixpkgs.overlays = [
|
|
|
|
(final: super: {
|
|
|
|
makeModulesClosure = x:
|
|
|
|
super.makeModulesClosure (x // {allowMissing = true;});
|
|
|
|
})
|
2024-01-11 14:51:11 +01:00
|
|
|
];
|
|
|
|
|
2024-12-07 01:21:59 +01:00
|
|
|
# Allow executing of anything on the system with a , eg: , python executes python from the nix store even if not in $PATH currently
|
|
|
|
programs.command-not-found.enable = lib.mkForce false;
|
|
|
|
programs.nix-index.enable = true;
|
|
|
|
programs.nix-index-database.comma.enable = true;
|
|
|
|
|
2024-12-05 15:05:34 +01:00
|
|
|
services.automatic-timezoned.enable = true;
|
|
|
|
|
2024-12-04 00:58:44 +01:00
|
|
|
#Set up sops config, and configure where the keyfile is, then set the mode for the unencrypted keys
|
|
|
|
sops.defaultSopsFile = ./secrets/sops.yaml;
|
2024-01-08 15:58:04 +01:00
|
|
|
|
2024-12-04 15:58:23 +01:00
|
|
|
boot.kernelPackages = lib.mkForce pkgs.linuxPackages_latest;
|
|
|
|
|
|
|
|
boot.initrd.kernelModules = ["vc4" "bcm2835_dma" "i2c_bcm2835" "cma=256M" "console=tty0"];
|
2024-01-08 15:58:04 +01:00
|
|
|
|
2024-12-04 00:58:44 +01:00
|
|
|
sdImage.compressImage = false;
|
2024-01-08 15:58:04 +01:00
|
|
|
|
|
|
|
home-manager = {
|
|
|
|
extraSpecialArgs = {inherit inputs outputs;};
|
|
|
|
users = {
|
|
|
|
# Import your home-manager configuration
|
2024-02-07 13:52:23 +01:00
|
|
|
lillian = import ../../../home-manager/hosts/wheatley;
|
2024-01-08 15:58:04 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-12-04 00:58:44 +01:00
|
|
|
networking.hostName = "wheatley";
|
2024-01-11 14:51:11 +01:00
|
|
|
|
2024-12-04 00:58:44 +01:00
|
|
|
services.openssh = {
|
|
|
|
enable = true;
|
|
|
|
# require public key authentication for better security
|
|
|
|
settings.PasswordAuthentication = false;
|
|
|
|
settings.KbdInteractiveAuthentication = false;
|
|
|
|
settings.PermitRootLogin = "no";
|
|
|
|
};
|
2024-01-11 14:51:11 +01:00
|
|
|
|
2024-12-07 18:23:56 +01:00
|
|
|
# users.users = {
|
|
|
|
# ombi.extraGroups = ["radarr" "sonarr" "aria2"];
|
|
|
|
# };
|
|
|
|
# services.ombi = {
|
|
|
|
# enable = true;
|
|
|
|
# port = 2368;
|
|
|
|
# };
|
|
|
|
|
|
|
|
# users.users = {
|
|
|
|
# radarr.extraGroups = ["aria2"];
|
|
|
|
# sonarr.extraGroups = ["aria2"];
|
|
|
|
# };
|
|
|
|
|
|
|
|
# services = {
|
|
|
|
# #uses port 7878
|
|
|
|
# radarr.enable = true;
|
|
|
|
# #uses port 8989
|
|
|
|
# sonarr.enable = true;
|
|
|
|
# prowlarr.enable = true;
|
|
|
|
# };
|
2024-12-04 22:44:35 +01:00
|
|
|
|
2024-12-06 17:48:38 +01:00
|
|
|
sops.secrets."webdav-secret" = {
|
2024-12-05 14:16:40 +01:00
|
|
|
mode = "0600";
|
2024-12-06 17:44:58 +01:00
|
|
|
path = "/etc/davfs2/secrets";
|
2024-12-04 23:45:48 +01:00
|
|
|
};
|
|
|
|
|
2024-12-05 14:46:52 +01:00
|
|
|
services.davfs2.enable = true;
|
2024-12-05 14:16:40 +01:00
|
|
|
systemd.mounts = [
|
|
|
|
{
|
|
|
|
enable = true;
|
|
|
|
description = "Webdav mount point";
|
|
|
|
after = ["network-online.target"];
|
|
|
|
wants = ["network-online.target"];
|
|
|
|
|
2024-12-06 17:44:58 +01:00
|
|
|
what = "https://nextcloud.gladtherescake.eu/remote.php/dav/files/GLaDTheresCake";
|
2024-12-05 14:16:40 +01:00
|
|
|
where = "/home/jellyfinmediaplayer/nextcloud";
|
2024-12-06 15:59:13 +01:00
|
|
|
options = "uid=1003,gid=100,file_mode=0664,dir_mode=2775";
|
2024-12-05 14:16:40 +01:00
|
|
|
type = "davfs";
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
2024-12-07 22:06:14 +01:00
|
|
|
# #uses port 8096
|
|
|
|
# services.jellyfin.enable = true;
|
|
|
|
# users.groups.jellyfinmediaplayer = {};
|
|
|
|
# users.users.jellyfinmediaplayer.group = "jellyfinmediaplayer";
|
|
|
|
# users.users.jellyfin.extraGroups = ["jellyfinmediaplayer"];
|
|
|
|
|
|
|
|
# # Add stremio kiosk on wayland :)
|
|
|
|
# users.extraUsers.jellyfinmediaplayer.isNormalUser = true;
|
|
|
|
# services.cage.user = "jellyfinmediaplayer";
|
|
|
|
# services.cage.program = "${pkgs.jellyfin-media-player}/bin/jellyfinmediaplayer";
|
|
|
|
# services.cage.enable = true;
|
|
|
|
# services.cage.extraArguments = ["-f"];
|
2024-12-04 16:58:55 +01:00
|
|
|
|
2024-12-04 22:44:35 +01:00
|
|
|
users.users.aria2.group = "aria2";
|
|
|
|
users.groups.aria2 = {};
|
|
|
|
users.users.aria2.isSystemUser = true;
|
|
|
|
|
|
|
|
sops.secrets."rpcSecret".mode = "0440";
|
|
|
|
sops.secrets."rpcSecret".owner = config.users.users.aria2.name;
|
|
|
|
|
|
|
|
services.aria2 = {
|
|
|
|
enable = true;
|
2024-12-04 22:48:28 +01:00
|
|
|
settings = {
|
|
|
|
dir = "/var/lib/media";
|
2024-12-07 01:46:00 +01:00
|
|
|
rpc-listen-port = 6969;
|
2024-12-04 22:48:28 +01:00
|
|
|
};
|
2024-12-04 22:44:35 +01:00
|
|
|
rpcSecretFile = config.sops.secrets."rpcSecret".path;
|
|
|
|
};
|
|
|
|
|
2024-12-04 20:26:40 +01:00
|
|
|
environment.systemPackages = [
|
2024-12-04 22:44:35 +01:00
|
|
|
# (pkgs.kodi.withPackages (kodiPkgs:
|
|
|
|
# with kodiPkgs; [
|
|
|
|
# steam-controller
|
|
|
|
# invidious
|
|
|
|
# netflix
|
|
|
|
# upnext
|
|
|
|
# sponsorblock
|
|
|
|
# sendtokodi
|
|
|
|
# jellyfin
|
|
|
|
# ]))
|
2024-12-07 01:09:57 +01:00
|
|
|
pkgs.iptables
|
2024-12-04 20:26:40 +01:00
|
|
|
];
|
|
|
|
|
2024-12-04 17:56:37 +01:00
|
|
|
sops.secrets."protonvpn-priv-key".mode = "0440";
|
2024-12-04 18:05:50 +01:00
|
|
|
sops.secrets."protonvpn-priv-key".owner = config.users.users.root.name;
|
2024-12-06 19:16:11 +01:00
|
|
|
sops.secrets."wg-private-key".mode = "0440";
|
|
|
|
sops.secrets."wg-private-key".owner = config.users.users.root.name;
|
2024-12-04 17:56:37 +01:00
|
|
|
|
2024-12-06 18:15:47 +01:00
|
|
|
networking.wireguard.enable = true;
|
|
|
|
|
|
|
|
networking.wg-quick.interfaces = {
|
2024-12-07 02:14:25 +01:00
|
|
|
# # "wg0" is the network interface name. You can name the interface arbitrarily.
|
|
|
|
# wg0 = {
|
|
|
|
# autostart = true;
|
|
|
|
# # Determines the IP address and subnet of the server's end of the tunnel interface.
|
|
|
|
# address = ["10.2.0.2/32"];
|
|
|
|
|
|
|
|
# # The port that WireGuard listens to. Must be accessible by the client.
|
|
|
|
# listenPort = 51820;
|
|
|
|
|
|
|
|
# dns = ["10.2.0.1"];
|
|
|
|
# # 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 = config.sops.secrets."protonvpn-priv-key".path;
|
|
|
|
|
|
|
|
# peers = [
|
|
|
|
# # List of allowed peers.
|
|
|
|
# {
|
|
|
|
# # Feel free to give a meaning full name
|
|
|
|
# # Public key of the peer (not a file path).
|
|
|
|
# publicKey = "/i7jCNpcqVBUkY07gVlILN4nFdvZHmxvreAOgLGoZGg=";
|
|
|
|
# # List of IPs assigned to this peer within the tunnel subnet. Used to configure routing.
|
|
|
|
# allowedIPs = ["0.0.0.0/0"];
|
|
|
|
# endpoint = "146.70.86.114:51820";
|
|
|
|
# }
|
|
|
|
# ];
|
|
|
|
# };
|
2024-12-07 02:07:36 +01:00
|
|
|
|
|
|
|
# wg public key for host: A02sO7uLdgflhPIRd0cbJONIaPP4z8HTxDkmX4NegFg=
|
2024-12-06 19:16:11 +01:00
|
|
|
wg1 = {
|
2024-12-06 22:40:12 +01:00
|
|
|
# Determines the IP address and subnet of the server's end of the tunnel interface.
|
|
|
|
address = ["10.0.0.1/24" "fdc9:281f:04d7:9ee9::1/64"];
|
|
|
|
|
|
|
|
# The port that WireGuard listens to. Must be accessible by the client.
|
2024-12-06 19:21:21 +01:00
|
|
|
listenPort = 51821;
|
2024-12-06 22:40:12 +01:00
|
|
|
|
|
|
|
# This allows the wireguard server to route your traffic to the internet and hence be like a VPN
|
|
|
|
postUp = ''
|
|
|
|
${pkgs.iptables}/bin/iptables -A FORWARD -i wg0 -j ACCEPT
|
|
|
|
${pkgs.iptables}/bin/iptables -t nat -A POSTROUTING -s 10.0.0.1/24 -o eth0 -j MASQUERADE
|
|
|
|
${pkgs.iptables}/bin/ip6tables -A FORWARD -i wg0 -j ACCEPT
|
|
|
|
${pkgs.iptables}/bin/ip6tables -t nat -A POSTROUTING -s fdc9:281f:04d7:9ee9::1/64 -o eth0 -j MASQUERADE
|
|
|
|
'';
|
|
|
|
|
|
|
|
# Undo the above
|
|
|
|
preDown = ''
|
|
|
|
${pkgs.iptables}/bin/iptables -D FORWARD -i wg0 -j ACCEPT
|
|
|
|
${pkgs.iptables}/bin/iptables -t nat -D POSTROUTING -s 10.0.0.1/24 -o eth0 -j MASQUERADE
|
|
|
|
${pkgs.iptables}/bin/ip6tables -D FORWARD -i wg0 -j ACCEPT
|
|
|
|
${pkgs.iptables}/bin/ip6tables -t nat -D POSTROUTING -s fdc9:281f:04d7:9ee9::1/64 -o eth0 -j MASQUERADE
|
|
|
|
'';
|
|
|
|
|
2024-12-06 19:16:11 +01:00
|
|
|
privateKeyFile = config.sops.secrets."wg-private-key".path;
|
|
|
|
|
|
|
|
peers = [
|
|
|
|
{
|
|
|
|
#GLaDOS public key
|
|
|
|
publicKey = "yieF2yQptaE3jStoaGytUnN+HLxyVhFBZIUOGUNAV38=";
|
2024-12-06 22:40:12 +01:00
|
|
|
allowedIPs = ["10.0.0.2/32" "fdc9:281f:04d7:9ee9::2/128"];
|
2024-12-06 19:16:11 +01:00
|
|
|
}
|
|
|
|
{
|
|
|
|
#EDI public key
|
|
|
|
publicKey = "i4nDZbU+a2k5C20tFJRNPVE1vhYKJwhoqGHEdeC4704=";
|
2024-12-06 22:40:12 +01:00
|
|
|
allowedIPs = ["10.0.0.3/32" "fdc9:281f:04d7:9ee9::3/128"];
|
2024-12-06 19:16:11 +01:00
|
|
|
}
|
|
|
|
{
|
|
|
|
#Shodan public key
|
|
|
|
publicKey = "Zah2nZDaHF8jpP5AtMA5bhE7t38fMB2UHzbXAc96/jw=";
|
2024-12-08 17:07:11 +01:00
|
|
|
allowedIPs = ["10.0.0.4/32" "fdc9:281f:04d7:9ee9::4/128"];
|
2024-12-06 19:16:11 +01:00
|
|
|
}
|
|
|
|
{
|
|
|
|
#ADA public key
|
|
|
|
publicKey = "SHu7xxRVWuqp4U4uipMoITKrFPWZATGsJevUeqBSzWo=";
|
2024-12-08 17:07:11 +01:00
|
|
|
allowedIPs = ["10.0.0.5/32" "fdc9:281f:04d7:9ee9::5/128"];
|
2024-12-06 19:16:11 +01:00
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
2024-12-06 18:15:47 +01:00
|
|
|
};
|
2024-12-04 17:56:37 +01:00
|
|
|
|
2024-12-06 22:40:12 +01:00
|
|
|
services.dnsmasq = {
|
|
|
|
enable = true;
|
|
|
|
settings = {
|
|
|
|
interface = "wg1";
|
|
|
|
};
|
|
|
|
};
|
2024-12-06 19:52:22 +01:00
|
|
|
|
2024-12-07 01:30:03 +01:00
|
|
|
boot.kernel.sysctl = {
|
|
|
|
"net.ipv4.ip_forward" = 1;
|
|
|
|
"net.ipv6.conf.all.forwarding" = 1;
|
|
|
|
};
|
|
|
|
|
2024-12-06 22:40:12 +01:00
|
|
|
# enable NAT
|
|
|
|
networking.nat.enable = true;
|
|
|
|
networking.nat.externalInterface = "end0";
|
|
|
|
networking.nat.internalInterfaces = ["wg1"];
|
2024-12-04 00:58:44 +01:00
|
|
|
networking.firewall = {
|
|
|
|
enable = true;
|
|
|
|
allowPing = false;
|
|
|
|
allowedTCPPorts = [
|
|
|
|
22 # SSH
|
|
|
|
5349 # STUN tls
|
|
|
|
5350 # STUN tls alt
|
|
|
|
80 # http
|
|
|
|
443 # https
|
2024-12-06 22:40:12 +01:00
|
|
|
51821 # wg
|
2024-12-06 20:19:41 +01:00
|
|
|
7878
|
2024-12-06 22:40:12 +01:00
|
|
|
53 # dnsmasq
|
|
|
|
];
|
|
|
|
allowedUDPPorts = [
|
|
|
|
53 #dnsmasq
|
2024-12-04 00:58:44 +01:00
|
|
|
];
|
|
|
|
allowedUDPPortRanges = [
|
2024-12-06 19:58:32 +01:00
|
|
|
{
|
|
|
|
from = 51820;
|
2024-12-06 22:40:12 +01:00
|
|
|
to = 51822; # wg
|
2024-12-06 19:58:32 +01:00
|
|
|
}
|
2024-12-04 00:58:44 +01:00
|
|
|
{
|
|
|
|
from = 49152;
|
|
|
|
to = 49999;
|
|
|
|
} # TURN relay
|
|
|
|
];
|
|
|
|
};
|
2024-01-08 15:58:04 +01:00
|
|
|
|
2024-12-04 00:58:44 +01:00
|
|
|
system.stateVersion = "25.05";
|
|
|
|
nixpkgs.hostPlatform = lib.mkForce "aarch64-linux";
|
2024-01-08 15:58:04 +01:00
|
|
|
}
|