nixos/applications/games.nix

85 lines
1.4 KiB
Nix
Raw Normal View History

{
config,
pkgs,
lib,
2023-10-01 02:53:53 +00:00
inputs,
...
}:
with lib; let
cfg = config.services.skynet_games;
in {
imports = [
2023-05-24 15:39:02 +00:00
./dns.nix
2023-10-01 02:53:53 +00:00
./nginx.nix
./games/minecraft.nix
];
2023-05-24 15:39:02 +00:00
options.services.skynet_games = {
enable = mkEnableOption "Skynet Games";
2023-05-24 15:39:02 +00:00
host = {
ip = mkOption {
type = types.str;
2023-05-24 15:39:02 +00:00
};
name = mkOption {
type = types.str;
};
};
2023-05-24 15:39:02 +00:00
domain = {
tld = mkOption {
type = types.str;
default = "ie";
};
2023-05-24 15:39:02 +00:00
base = mkOption {
type = types.str;
default = "skynet";
2023-05-24 15:39:02 +00:00
};
sub = mkOption {
type = types.str;
default = "games";
};
};
2023-05-24 15:39:02 +00:00
};
config = mkIf cfg.enable {
skynet_dns.records = [
# need a base domain
{
record = cfg.domain.sub;
r_type = "CNAME";
value = cfg.host.name;
}
];
2023-05-24 15:39:02 +00:00
2023-10-01 02:53:53 +00:00
skynet_acme.domains = [
"${cfg.domain.sub}.skynet.ie"
];
services.nginx.virtualHosts = {
"${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
services.skynet_games_minecraft = {
enable = true;
host = {
ip = cfg.host.ip;
name = cfg.domain.sub;
};
domain = {
sub = "minecraft.${cfg.domain.sub}";
};
};
};
}