feat: properly modularised games
This commit is contained in:
parent
920f6ab86e
commit
95cdbf2b4e
3 changed files with 188 additions and 77 deletions
|
@ -1,5 +1,70 @@
|
|||
{ ... }: {
|
||||
{ config, pkgs, lib, ... }:
|
||||
with lib;
|
||||
let
|
||||
cfg = config.services.skynet_games;
|
||||
in {
|
||||
imports = [
|
||||
./dns.nix
|
||||
|
||||
./games/minecraft.nix
|
||||
];
|
||||
|
||||
|
||||
options.services.skynet_games = {
|
||||
enable = mkEnableOption "Skynet Games";
|
||||
|
||||
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 = "games";
|
||||
};
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
skynet_dns.records = {
|
||||
cname = [
|
||||
# need a base domain
|
||||
"${cfg.domain.sub} CNAME ${cfg.host.name}"
|
||||
];
|
||||
};
|
||||
|
||||
# the minecraft servers
|
||||
services.skynet_games_minecraft = {
|
||||
enable = true;
|
||||
|
||||
host = {
|
||||
ip = cfg.host.ip;
|
||||
name = cfg.domain.sub;
|
||||
};
|
||||
|
||||
domain = {
|
||||
sub = "minecraft.${cfg.domain.sub}";
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
};
|
||||
}
|
|
@ -1,18 +1,63 @@
|
|||
{
|
||||
{ config, pkgs, lib, ... }:
|
||||
with lib;
|
||||
let
|
||||
cfg = config.services.skynet_games_minecraft;
|
||||
in {
|
||||
|
||||
imports = [
|
||||
../firewall.nix
|
||||
../dns.nix
|
||||
|
||||
../acme.nix
|
||||
../nginx.nix
|
||||
];
|
||||
|
||||
options.services.skynet_games_minecraft = {
|
||||
enable = mkEnableOption "Skynet Games Minecraft";
|
||||
|
||||
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 = "minecraft.games";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
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 25565 counter packets 0 bytes 0 accept"
|
||||
];
|
||||
|
||||
skynet_dns.records = {
|
||||
external = [];
|
||||
cname = [
|
||||
# create a sub-subdomain for each game
|
||||
"compsoc_classic.minecraft.games CNAME games"
|
||||
"compsoc.minecraft.games CNAME games"
|
||||
"compsoc_classic.${cfg.domain.sub} CNAME ${cfg.host.name}"
|
||||
"compsoc.${cfg.domain.sub} CNAME ${cfg.host.name}"
|
||||
|
||||
"map.compsoc_classic.minecraft.games CNAME games"
|
||||
"map.compsoc_classic.${cfg.domain.sub} CNAME ${cfg.host.name}"
|
||||
#"compsoc.minecraft.games CNAME games"
|
||||
];
|
||||
};
|
||||
|
@ -27,7 +72,7 @@
|
|||
20001
|
||||
];
|
||||
|
||||
services.nginx.virtualHosts."compsoc_classic.minecraft.games.skynet.ie" = {
|
||||
services.nginx.virtualHosts."compsoc_classic.${cfg.domain.sub}.${cfg.domain.base}.${cfg.domain.tld}" = {
|
||||
forceSSL = true;
|
||||
useACMEHost = "skynet";
|
||||
locations."/map/".alias = "/etc/games/minecraft/compsoc/classic/config/plugins/dynmap/web/";
|
||||
|
@ -83,4 +128,5 @@
|
|||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
|
@ -21,7 +21,6 @@ let
|
|||
in {
|
||||
imports = [
|
||||
# applications for this particular server
|
||||
../applications/firewall.nix
|
||||
../applications/dns.nix
|
||||
../applications/games.nix
|
||||
|
||||
|
@ -38,27 +37,28 @@ in {
|
|||
targetUser = "root";
|
||||
};
|
||||
|
||||
# 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 25565 counter packets 0 bytes 0 accept"
|
||||
];
|
||||
|
||||
skynet_dns.records = {
|
||||
external = [
|
||||
"${name} A ${ip_pub}"
|
||||
];
|
||||
cname = [
|
||||
# the games are each going to have a subdomain on this
|
||||
"games CNAME ${name}"
|
||||
];
|
||||
reverse = [
|
||||
"${builtins.substring 9 3 ip_pub} IN PTR ${name}"
|
||||
];
|
||||
};
|
||||
|
||||
services.skynet_games = {
|
||||
enable = true;
|
||||
|
||||
host = {
|
||||
# pass in teh ip (used for firewall)
|
||||
ip = ip_pub;
|
||||
|
||||
# the name is used for dns
|
||||
name = name;
|
||||
};
|
||||
};
|
||||
|
||||
# we use this to pass in teh relevent infomation to the
|
||||
services.skynet_ldap = {
|
||||
enable = true;
|
||||
|
|
Loading…
Reference in a new issue