diff --git a/modules/gameservers/valheim/default.nix b/modules/gameservers/valheim/default.nix index 4242406..23862bf 100644 --- a/modules/gameservers/valheim/default.nix +++ b/modules/gameservers/valheim/default.nix @@ -16,7 +16,7 @@ in { # set port options port = lib.mkOption { type = lib.types.int; - default = 7704; + default = 2456; description = "set port for ${service} (default: ${toString cfg.port}"; }; url = lib.mkOption { @@ -26,7 +26,7 @@ in { }; data_dir = lib.mkOption { type = lib.types.str; - default = "/var/lib/${service}"; + default = "/var/lib/gameservers/${service}"; description = "set data directory for ${service}"; }; ids = lib.mkOption { @@ -34,15 +34,15 @@ in { default = cfg.port; description = "set uid and pid of ${service} user (matches port by default)"; }; + motd_gs = lib.mkOption { + type = lib.types.nullOr lib.types.str; + default = ["podman-valheim"]; + }; backup = lib.mkOption { type = lib.types.bool; default = false; description = "enable backups for ${service}"; }; - motd_gs = lib.mkOption { - type = lib.types.nullOr lib.types.str; - default = ["craftoria"]; - }; backup_repo = lib.mkOption { type = lib.types.path; default = "/var/backup/gameservers/valheim"; @@ -81,17 +81,24 @@ in { }; virtualisation.oci-containers.containers = { - hass = { - image = "homeassistant/home-assistant:stable"; + ${service} = { + image = "ghcr.io/community-valheim-tools/valheim-server"; autoStart = true; extraOptions = [ - "--pull=newer" - "--network=host" + "--cap-add=sys_nice" + "--stop-timeout=120" + ]; + ports = [ + "2456-2457:2456-2457/udp" ]; volumes = [ - "${cfg.data_dir}:/config" + "${cfg.data_dir}/config:/config" + "${cfg.data_dir}/data:/opt/valheim" ]; environment = { + SERVER_NAME = "recpro"; + SERVER_PASS = "recoil727pro"; + WORLD_NAME = ""; TZ = homelab.tz; PUID = toString config.users.users.${service}.uid; PGID = toString config.users.groups.${service}.gid; @@ -105,35 +112,14 @@ in { }; # open firewall - networking.firewall.allowedTCPPorts = [cfg.port 8123 21063 21064]; - networking.firewall.allowedUDPPorts = [5353]; - - # add to caddy for reverse proxy - services.caddy.virtualHosts."${cfg.url}" = { - serverAliases = ["${service}.${homelab.public_domain}"]; - extraConfig = '' - tls internal - reverse_proxy 127.0.0.1:${toString cfg.port} { - } - ''; - }; + # networking.firewall.allowedTCPPorts = [cfg.port]; + networking.firewall.allowedUDPPorts = [2456 2457]; # backups valhiem with borg! services.borgbackup.jobs.${service} = { archiveBaseName = service; repo = cfg.backup_repo; - paths = lib.flatten ( - lib.attrValues ( - lib.mapAttrs (_: srv: - [srv.data_dir] - ++ ( - if builtins.hasAttr "db_dump" srv - then [srv.db_dump] - else [] - )) - servers - ) - ); + paths = cfg.data_dir; compression = "auto,zstd"; #preHook = "systemctl start mysql-backup.service"; postHook = ''