mirror of
https://gitlab.com/upRootNutrition/dotfiles.git
synced 2025-12-06 21:17:14 -06:00
149 lines
3.6 KiB
Nix
Executable file
149 lines
3.6 KiB
Nix
Executable file
{
|
|
config,
|
|
flake,
|
|
...
|
|
}:
|
|
let
|
|
inherit (flake.config.people) user0;
|
|
inherit (flake.config.services) instances;
|
|
serviceCfg = instances.jellyfin;
|
|
hostCfg = instances.web;
|
|
dns0 = instances.web.dns.provider0;
|
|
host = serviceCfg.domains.url0;
|
|
dns0Path = "dns/${dns0}";
|
|
in
|
|
{
|
|
microvm.vms.jellyin = {
|
|
autostart = true;
|
|
restartIfChanged = true;
|
|
config = {
|
|
system.stateVersion = "24.05";
|
|
time.timeZone = "America/Winnipeg";
|
|
users.users.root.openssh.authorizedKeys.keys = flake.config.people.users.${user0}.sshKeys;
|
|
services = {
|
|
jellyfin = {
|
|
enable = true;
|
|
openFirewall = true;
|
|
};
|
|
|
|
openssh = {
|
|
enable = true;
|
|
settings = {
|
|
PasswordAuthentication = false;
|
|
PermitRootLogin = "prohibit-password";
|
|
};
|
|
};
|
|
};
|
|
|
|
networking.firewall.allowedTCPPorts = [
|
|
22
|
|
serviceCfg.ports.port0
|
|
serviceCfg.ports.port1
|
|
serviceCfg.ports.port2
|
|
];
|
|
|
|
systemd.network = {
|
|
enable = true;
|
|
networks."20-lan" = {
|
|
matchConfig.Name = "enp0s5";
|
|
addresses = [
|
|
{ Address = "${serviceCfg.interface.ip}/24"; }
|
|
];
|
|
routes = [
|
|
{
|
|
Destination = "${hostCfg.localhost.address1}/0";
|
|
Gateway = serviceCfg.interface.gate;
|
|
}
|
|
];
|
|
dns = [
|
|
"1.1.1.1"
|
|
"8.8.8.8"
|
|
];
|
|
};
|
|
};
|
|
|
|
systemd.services.systemd-networkd.wantedBy = [ "multi-user.target" ];
|
|
|
|
microvm = {
|
|
vcpu = 4;
|
|
mem = 4096;
|
|
hypervisor = "qemu";
|
|
interfaces = [
|
|
{
|
|
type = "tap";
|
|
id = serviceCfg.interface.id;
|
|
mac = serviceCfg.interface.mac;
|
|
}
|
|
{
|
|
type = "user";
|
|
id = serviceCfg.interface.idUser;
|
|
mac = serviceCfg.interface.macUser;
|
|
}
|
|
];
|
|
|
|
forwardPorts = [
|
|
{
|
|
from = "host";
|
|
host.port = serviceCfg.interface.ssh;
|
|
guest.port = 22;
|
|
}
|
|
];
|
|
|
|
shares = [
|
|
{
|
|
mountPoint = "/nix/.ro-store";
|
|
proto = "virtiofs";
|
|
source = "/nix/store";
|
|
tag = "read_only_nix_store";
|
|
}
|
|
{
|
|
mountPoint = serviceCfg.varPaths.path0;
|
|
proto = "virtiofs";
|
|
source = serviceCfg.mntPaths.path0;
|
|
tag = "${serviceCfg.name}_data";
|
|
}
|
|
{
|
|
mountPoint = serviceCfg.varPaths.path1;
|
|
proto = "virtiofs";
|
|
source = "${serviceCfg.mntPaths.path0}/cache";
|
|
tag = "${serviceCfg.name}_cache";
|
|
}
|
|
];
|
|
};
|
|
};
|
|
};
|
|
|
|
security.acme.certs."${host}" = {
|
|
dnsProvider = dns0;
|
|
environmentFile = config.sops.secrets.${dns0Path}.path;
|
|
group = "caddy";
|
|
};
|
|
|
|
services = {
|
|
caddy = {
|
|
virtualHosts = {
|
|
"${host}" = {
|
|
extraConfig = ''
|
|
reverse_proxy ${serviceCfg.interface.ip}:${toString serviceCfg.ports.port0} {
|
|
header_up X-Real-IP {remote_host}
|
|
}
|
|
|
|
redir /.well-known/carddav /remote.php/dav/ 301
|
|
redir /.well-known/caldav /remote.php/dav/ 301
|
|
|
|
tls ${serviceCfg.ssl.cert} ${serviceCfg.ssl.key}
|
|
encode zstd gzip
|
|
'';
|
|
};
|
|
};
|
|
};
|
|
};
|
|
|
|
users.users.caddy.extraGroups = [ "acme" ];
|
|
|
|
systemd.tmpfiles.rules = [
|
|
"d ${serviceCfg.mntPaths.path0} 0755 root root -"
|
|
"d ${serviceCfg.mntPaths.path0}/cache 0755 root root -"
|
|
];
|
|
|
|
}
|