2023-09-17 19:51:08 +00:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
pkgs,
|
|
|
|
...
|
|
|
|
}:
|
|
|
|
with lib; let
|
2024-05-30 13:59:20 +00:00
|
|
|
name = "ulfm";
|
|
|
|
cfg = config.services.skynet."${name}";
|
2023-09-17 19:51:08 +00:00
|
|
|
in {
|
2023-05-24 14:59:22 +00:00
|
|
|
imports = [
|
|
|
|
];
|
2023-04-21 00:44:11 +00:00
|
|
|
|
2024-05-30 13:59:20 +00:00
|
|
|
options.services.skynet."${name}" = {
|
2023-09-17 19:51:08 +00:00
|
|
|
enable = mkEnableOption "ULFM service";
|
|
|
|
|
|
|
|
domain = {
|
|
|
|
tld = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "ie";
|
|
|
|
};
|
|
|
|
|
|
|
|
base = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "skynet";
|
|
|
|
};
|
|
|
|
|
|
|
|
sub = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "ulfm";
|
|
|
|
};
|
|
|
|
};
|
2023-04-21 00:44:11 +00:00
|
|
|
};
|
|
|
|
|
2023-05-24 14:59:22 +00:00
|
|
|
config = mkIf cfg.enable {
|
2023-11-20 16:52:24 +00:00
|
|
|
# TODO: extract this out into its own config
|
2023-05-24 14:59:22 +00:00
|
|
|
age.secrets.ulfm.file = ../secrets/stream_ulfm.age;
|
|
|
|
|
|
|
|
networking.firewall.allowedTCPPorts = [
|
|
|
|
8000
|
|
|
|
];
|
|
|
|
|
2024-05-30 12:34:59 +00:00
|
|
|
services.skynet.acme.domains = [
|
2023-08-06 19:09:15 +00:00
|
|
|
"${cfg.domain.sub}.${cfg.domain.base}.${cfg.domain.tld}"
|
|
|
|
];
|
|
|
|
|
2024-05-30 12:25:52 +00:00
|
|
|
services.skynet.dns.records = [
|
2023-09-17 19:51:08 +00:00
|
|
|
{
|
|
|
|
record = cfg.domain.sub;
|
|
|
|
r_type = "CNAME";
|
2024-05-30 16:55:29 +00:00
|
|
|
value = config.services.skynet.host.name;
|
2023-09-17 19:51:08 +00:00
|
|
|
}
|
2023-05-24 14:59:22 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
skynet_firewall.forward = [
|
2024-05-30 16:55:29 +00:00
|
|
|
"ip daddr ${config.services.skynet.host.ip} tcp dport 80 counter packets 0 bytes 0 accept"
|
|
|
|
"ip daddr ${config.services.skynet.host.ip} tcp dport 443 counter packets 0 bytes 0 accept"
|
|
|
|
"ip daddr ${config.services.skynet.host.ip} tcp dport 8000 counter packets 0 bytes 0 accept"
|
2023-05-24 14:59:22 +00:00
|
|
|
];
|
2023-04-21 00:44:11 +00:00
|
|
|
|
2023-05-24 14:59:22 +00:00
|
|
|
users.groups."icecast" = {};
|
|
|
|
|
|
|
|
users.users."icecast2" = {
|
|
|
|
createHome = true;
|
|
|
|
isSystemUser = true;
|
|
|
|
home = "/etc/icecast2";
|
|
|
|
group = "icecast";
|
|
|
|
};
|
|
|
|
|
|
|
|
systemd.services.icecast = {
|
2023-09-17 19:51:08 +00:00
|
|
|
after = ["network.target"];
|
2023-05-24 14:59:22 +00:00
|
|
|
description = "Icecast Network Audio Streaming Server";
|
2023-09-17 19:51:08 +00:00
|
|
|
wantedBy = ["multi-user.target"];
|
2023-05-24 14:59:22 +00:00
|
|
|
|
|
|
|
preStart = "mkdir -p /var/log/icecast && chown nobody:nogroup /var/log/icecast";
|
|
|
|
serviceConfig = {
|
|
|
|
Type = "simple";
|
|
|
|
ExecStart = "${pkgs.icecast}/bin/icecast -c /run/agenix/ulfm";
|
|
|
|
ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-01-31 15:43:18 +00:00
|
|
|
services.nginx = {
|
|
|
|
virtualHosts = {
|
|
|
|
"${cfg.domain.sub}.${cfg.domain.base}.${cfg.domain.tld}" = {
|
|
|
|
forceSSL = true;
|
|
|
|
useACMEHost = "skynet";
|
|
|
|
locations."/".proxyPass = "http://localhost:8000";
|
|
|
|
};
|
|
|
|
};
|
2023-04-21 00:44:11 +00:00
|
|
|
};
|
|
|
|
};
|
2023-09-17 19:51:08 +00:00
|
|
|
}
|