feat: turned ulfm into a proper module
This commit is contained in:
parent
91a3eb6a1a
commit
34de735720
2 changed files with 97 additions and 45 deletions
|
@ -1,12 +1,69 @@
|
||||||
{ config, lib, pkgs, ... }:{
|
{ config, lib, pkgs, ... }:
|
||||||
|
with lib;
|
||||||
|
let
|
||||||
|
cfg = config.services.skynet_ulfm;
|
||||||
|
in {
|
||||||
|
|
||||||
|
imports = [
|
||||||
|
./firewall.nix
|
||||||
|
./dns.nix
|
||||||
|
|
||||||
|
./acme.nix
|
||||||
|
./nginx.nix
|
||||||
|
];
|
||||||
|
|
||||||
|
options.services.skynet_ulfm = {
|
||||||
|
enable = mkEnableOption "ULFM service";
|
||||||
|
|
||||||
|
host = {
|
||||||
|
ip = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
};
|
||||||
|
|
||||||
|
name = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
domain = {
|
||||||
|
tld = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = "ie";
|
||||||
|
};
|
||||||
|
|
||||||
|
base = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = "skynet";
|
||||||
|
};
|
||||||
|
|
||||||
|
sub = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = "ulfm";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = mkIf cfg.enable {
|
||||||
# shove the entire config file into secrets
|
# shove the entire config file into secrets
|
||||||
age.secrets.ulfm.file = ../secrets/stream_ulfm.age;
|
age.secrets.ulfm.file = ../secrets/stream_ulfm.age;
|
||||||
|
|
||||||
###### implementation
|
networking.firewall.allowedTCPPorts = [
|
||||||
networking.firewall.allowedTCPPorts = [ 8000 ];
|
80
|
||||||
|
443
|
||||||
|
8000
|
||||||
|
];
|
||||||
|
|
||||||
users.groups."icecast" = { };
|
skynet_dns.records.cname = [
|
||||||
|
"${cfg.domain.sub} CNAME ${cfg.host.name}"
|
||||||
|
];
|
||||||
|
|
||||||
|
skynet_firewall.forward = [
|
||||||
|
"ip daddr ${cfg.host.ip} tcp dport 80 counter packets 0 bytes 0 accept"
|
||||||
|
"ip daddr ${cfg.host.ip} tcp dport 443 counter packets 0 bytes 0 accept"
|
||||||
|
"ip daddr ${cfg.host.ip} tcp dport 8000 counter packets 0 bytes 0 accept"
|
||||||
|
];
|
||||||
|
|
||||||
|
users.groups."icecast" = {};
|
||||||
|
|
||||||
users.users."icecast2" = {
|
users.users."icecast2" = {
|
||||||
createHome = true;
|
createHome = true;
|
||||||
|
@ -28,10 +85,12 @@
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
services.nginx.virtualHosts."ulfm.skynet.ie" = {
|
services.nginx.virtualHosts."${cfg.domain.sub}.${cfg.domain.base}.${cfg.domain.tld}" = {
|
||||||
forceSSL = true;
|
forceSSL = true;
|
||||||
useACMEHost = "skynet";
|
useACMEHost = "skynet";
|
||||||
locations."/".proxyPass = "http://localhost:8000";
|
locations."/".proxyPass = "http://localhost:8000";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
|
@ -17,17 +17,10 @@ let
|
||||||
ip_pub = "193.1.99.111";
|
ip_pub = "193.1.99.111";
|
||||||
ip_priv = "172.20.20.6";
|
ip_priv = "172.20.20.6";
|
||||||
hostname = "${name}.skynet.ie";
|
hostname = "${name}.skynet.ie";
|
||||||
|
|
||||||
# dosent seem to be any otehr way to have it like read from a file
|
|
||||||
feck = "d9J4jDsJPuMPUMAAE4J4tH37HsmxEDze";
|
|
||||||
in {
|
in {
|
||||||
imports = [
|
imports = [
|
||||||
# general stuff for config
|
# general stuff for config
|
||||||
../applications/firewall.nix
|
|
||||||
../applications/dns.nix
|
../applications/dns.nix
|
||||||
# web stuff
|
|
||||||
../applications/nginx.nix
|
|
||||||
../applications/acme.nix
|
|
||||||
|
|
||||||
# specific to tis server
|
# specific to tis server
|
||||||
../applications/ulfm.nix
|
../applications/ulfm.nix
|
||||||
|
@ -41,25 +34,25 @@ in {
|
||||||
tags = [ "active" ];
|
tags = [ "active" ];
|
||||||
};
|
};
|
||||||
|
|
||||||
# these two are to be able to add the rules for firewall and dns
|
|
||||||
# open the firewall for this
|
|
||||||
skynet_firewall.forward = [
|
|
||||||
"ip daddr ${ip_pub} tcp dport 80 counter packets 0 bytes 0 accept"
|
|
||||||
"ip daddr ${ip_pub} tcp dport 443 counter packets 0 bytes 0 accept"
|
|
||||||
"ip daddr ${ip_pub} tcp dport 8000 counter packets 0 bytes 0 accept"
|
|
||||||
];
|
|
||||||
|
|
||||||
skynet_dns.records = {
|
skynet_dns.records = {
|
||||||
external = [
|
external = [
|
||||||
"${name} A ${ip_pub}"
|
"${name} A ${ip_pub}"
|
||||||
];
|
];
|
||||||
cname = [
|
|
||||||
# this is also the stream server
|
|
||||||
#"stream CNAME ${name}"
|
|
||||||
"ulfm CNAME ${name}"
|
|
||||||
];
|
|
||||||
reverse = [
|
reverse = [
|
||||||
"${builtins.substring 9 3 ip_pub} IN PTR ${name}"
|
"${builtins.substring 9 3 ip_pub} IN PTR ${name}"
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
services.skynet_ulfm = {
|
||||||
|
enable = true;
|
||||||
|
|
||||||
|
host = {
|
||||||
|
# pass in teh ip (used for firewall)
|
||||||
|
ip = ip_pub;
|
||||||
|
|
||||||
|
# the name is used for dns
|
||||||
|
name = name;
|
||||||
|
};
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue