2023-09-17 19:51:08 +00:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
pkgs,
|
|
|
|
lib,
|
2023-10-01 02:53:53 +00:00
|
|
|
inputs,
|
2023-09-17 19:51:08 +00:00
|
|
|
...
|
|
|
|
}:
|
|
|
|
with lib; let
|
2024-05-30 13:59:20 +00:00
|
|
|
name = "games";
|
|
|
|
cfg = config.services.skynet."${name}";
|
2023-09-17 19:51:08 +00:00
|
|
|
in {
|
2023-04-25 23:24:54 +00:00
|
|
|
imports = [
|
2023-05-24 15:39:02 +00:00
|
|
|
./dns.nix
|
2023-10-01 02:53:53 +00:00
|
|
|
./nginx.nix
|
2023-04-25 23:24:54 +00:00
|
|
|
./games/minecraft.nix
|
|
|
|
];
|
2023-05-24 15:39:02 +00:00
|
|
|
|
2024-05-30 13:59:20 +00:00
|
|
|
options.services.skynet."${name}" = {
|
2023-09-17 19:51:08 +00:00
|
|
|
enable = mkEnableOption "Skynet Games";
|
2023-05-24 15:39:02 +00:00
|
|
|
|
2023-09-17 19:51:08 +00:00
|
|
|
host = {
|
|
|
|
ip = mkOption {
|
|
|
|
type = types.str;
|
2023-05-24 15:39:02 +00:00
|
|
|
};
|
|
|
|
|
2023-09-17 19:51:08 +00:00
|
|
|
name = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
};
|
|
|
|
};
|
2023-05-24 15:39:02 +00:00
|
|
|
|
2023-09-17 19:51:08 +00:00
|
|
|
domain = {
|
|
|
|
tld = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "ie";
|
|
|
|
};
|
2023-05-24 15:39:02 +00:00
|
|
|
|
2023-09-17 19:51:08 +00:00
|
|
|
base = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "skynet";
|
2023-05-24 15:39:02 +00:00
|
|
|
};
|
|
|
|
|
2023-09-17 19:51:08 +00:00
|
|
|
sub = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "games";
|
|
|
|
};
|
|
|
|
};
|
2023-05-24 15:39:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
2024-05-30 12:25:52 +00:00
|
|
|
services.skynet.dns.records = [
|
2023-07-16 00:53:21 +00:00
|
|
|
# need a base domain
|
2023-09-17 19:51:08 +00:00
|
|
|
{
|
|
|
|
record = cfg.domain.sub;
|
|
|
|
r_type = "CNAME";
|
|
|
|
value = cfg.host.name;
|
|
|
|
}
|
2023-07-16 00:53:21 +00:00
|
|
|
];
|
2023-05-24 15:39:02 +00:00
|
|
|
|
2024-05-30 12:34:59 +00:00
|
|
|
services.skynet.acme.domains = [
|
2023-10-01 02:53:53 +00:00
|
|
|
"${cfg.domain.sub}.skynet.ie"
|
|
|
|
];
|
|
|
|
|
|
|
|
services.nginx.virtualHosts = {
|
2024-01-31 15:43:18 +00:00
|
|
|
"${cfg.host.ip}" = {
|
|
|
|
forceSSL = true;
|
|
|
|
useACMEHost = "skynet";
|
|
|
|
locations."/".return = "307 https://skynet.ie";
|
|
|
|
};
|
|
|
|
|
2023-10-01 02:53:53 +00:00
|
|
|
"${cfg.domain.sub}.skynet.ie" = {
|
|
|
|
forceSSL = true;
|
|
|
|
useACMEHost = "skynet";
|
|
|
|
root = "${inputs.skynet_website_games.defaultPackage.x86_64-linux}";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2023-05-24 15:39:02 +00:00
|
|
|
# the minecraft servers
|
2024-05-30 13:59:20 +00:00
|
|
|
services.skynet.games_minecraft = {
|
2023-05-24 15:39:02 +00:00
|
|
|
enable = true;
|
|
|
|
|
|
|
|
host = {
|
|
|
|
ip = cfg.host.ip;
|
|
|
|
name = cfg.domain.sub;
|
|
|
|
};
|
|
|
|
|
|
|
|
domain = {
|
|
|
|
sub = "minecraft.${cfg.domain.sub}";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2023-09-17 19:51:08 +00:00
|
|
|
}
|