server-configuration/services/sonarr.nix
2025-03-04 16:51:18 +01:00

81 lines
1.7 KiB
Nix

{lib, ...}: let
host = "127.0.0.1";
port = 8989;
vm-index = 1;
vm-mac = "00:00:00:00:00:01";
in {
config.microvm.autostart = ["sonarr"];
config.system.activationScripts.makeSonarrDir = lib.stringAfter ["var"] ''
mkdir -p /var/lib/sonarr
chmod -R microvm /var/lib/sonarr
'';
config.microvm.vms."sonarr" = {
config = {
system.stateVersion = "24.11";
# Storage share configuration
microvm.shares = [
{
tag = "ro-store";
source = "/nix/store";
mountPoint = "/nix/.ro-store";
}
{
tag = "data-dir";
source = "/var/lib/sonarr";
mountPoint = "/var/lib/sonarr";
proto = "virtiofs";
}
];
# VM Networking
microvm.interfaces = [
{
id = "vm${toString vm-index}";
type = "tap";
mac = vm-mac;
}
];
networking.useNetworkd = true;
systemd.network.networks."10-eth" = {
matchConfig.MACAddress = vm-mac;
address = [
"10.0.0.${toString vm-index}/32"
];
routes = [
# Host Route
{
Destination = "10.0.0.0/32";
GatewayOnLink = true;
}
# Default route
{
Destination = "0.0.0.0/0";
Gateway = "10.0.0.0";
GatewayOnLink = true;
}
];
networkConfig = {
DNS = [
"9.9.9.9"
"8.8.8.8"
"8.8.4.4"
];
};
};
# Service
services.sonarr = {
enable = true;
openFirewall = true;
};
# Debug user
users.users."root" = {
password = "1234";
};
};
};
}