diff --git a/flake.nix b/flake.nix index 43a0586..2d1b5bb 100644 --- a/flake.nix +++ b/flake.nix @@ -19,6 +19,9 @@ outputs = inputs@{ self, nixpkgs, ... }: { + nixosModules = { + openarena = import ./nixos-modules/openarena.nix { }; + }; nixosConfigurations = { "games-night" = nixpkgs.lib.nixosSystem { system = "x86_64-linux"; diff --git a/hosts/server/configuration.nix b/hosts/server/configuration.nix index e9ba518..c5ffffd 100644 --- a/hosts/server/configuration.nix +++ b/hosts/server/configuration.nix @@ -104,6 +104,7 @@ in environment.systemPackages = with pkgs; [ vim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default. wget + podman-compose ]; # Some programs need SUID wrappers, can be configured further or are diff --git a/modules/minecraft.nix b/modules/minecraft.nix index 2873c42..3a2ec1d 100644 --- a/modules/minecraft.nix +++ b/modules/minecraft.nix @@ -15,7 +15,7 @@ openFirewall = true; servers.vanilla = { enable = true; - jvmOpts = "-Xmx4G -Xms2G"; + jvmOpts = "-Xmx16G -Xms2G"; }; }; } diff --git a/modules/openarena-instance.nix b/modules/openarena-instance.nix index 4ae4394..6a2dee5 100644 --- a/modules/openarena-instance.nix +++ b/modules/openarena-instance.nix @@ -1,34 +1,6 @@ +{ ... }: { - config, - lib, - pkgs, - ... -}: - -let - cfg = config.services.openarena-instance; - - openarenatbz2 = pkgs.fetchurl { - url = "https://johannes.dynip.online/files/cwace-openarena-server.tbz2"; - sha256 = "f47c4cc5aaa7f59aa9d6ad4d76e9f4255cc8a88d9cfc2ba884bd8ab7ebf3ce00"; - }; - -in -{ - options.services.openarena-instance = { - # ... existing options ... - }; - - config = { - systemd.services."openarena@${cfg.name}" = { - # ... existing service config ... - - preStart = '' - mkdir -p /var/lib/openarena-${cfg.name} - tar -xf ${openarenatbz2} -C /var/lib/openarena-${cfg.name} --strip-components=1 - ''; - }; - - # ... existing firewall config ... - }; + imports = [ + ../nixos-modules/openarena.nix + ]; } diff --git a/nixos-modules/openarena.nix b/nixos-modules/openarena.nix new file mode 100644 index 0000000..1d29e0e --- /dev/null +++ b/nixos-modules/openarena.nix @@ -0,0 +1,42 @@ +{ lib, ...}: +let + {inherit lib;} mkEnableOption mkOption; +in { + options = { + services.openarena = { + enable = mkEnableOption "OpenArena game servers"; + + instances = mkOption { + type = types.listOf (types.submodule { + options = { + name = mkOption { + type = types.str; + description = "Unique name for this server instance"; + }; + port = mkOption { + type = types.int; + default = 27960; + description = "UDP port for the server"; + }; + gameMode = mkOption { + type = types.str; + default = "oa_dm1"; + description = "Default map or game mode to start"; + }; + extraFlags = mkOption { + type = types.listOf types.str; + default = [ ]; + description = "Extra flags to pass to oa_ded"; + }; + openPorts = mkOption { + type = types.bool; + default = false; + description = "Whether to open firewall ports for this instance"; + }; + }; + })); + }; + }; +}; + +}