From 66a502b1dde8461964100801ccd097b0224db243 Mon Sep 17 00:00:00 2001 From: yukkop Date: Sat, 12 Sep 2026 21:56:31 +0000 Subject: [PATCH] fix: project zomboid module --- .../module/hectic/service/project-zomboid.nix | 33 +++++++++- nixos/system/hectic-lab/hectic-lab.nix | 61 ++++++++++++++++++- 2 files changed, 91 insertions(+), 3 deletions(-) diff --git a/nixos/module/hectic/service/project-zomboid.nix b/nixos/module/hectic/service/project-zomboid.nix index 957b8e81..1deb7449 100644 --- a/nixos/module/hectic/service/project-zomboid.nix +++ b/nixos/module/hectic/service/project-zomboid.nix @@ -16,6 +16,16 @@ name: value: "${name}=${if builtins.isBool value then lib.boolToString value else toString value}" ) serverProperties; + luaValue = value: + if builtins.isBool value then + lib.boolToString value + else if builtins.isInt value then + toString value + else + "\"${lib.replaceStrings [ "\\" "\"" "\n" "\r" ] [ "\\\\" "\\\"" "\\n" "\\r" ] value}\""; + sandboxConfigLines = lib.mapAttrsToList ( + name: value: "${name} = ${luaValue value}," + ) cfg.sandboxProperties; adminPasswordFile = "${cfg.dataDir}/admin-password"; startScript = pkgs.writeShellScript "project-zomboid-start" '' admin_password=$(${pkgs.coreutils}/bin/cat ${lib.escapeShellArg adminPasswordFile}) @@ -100,6 +110,18 @@ in { description = "Runtime file with additional INI values, suitable for secrets."; }; + sandboxProperties = lib.mkOption { + type = lib.types.attrsOf ( + lib.types.oneOf [ + lib.types.bool + lib.types.int + lib.types.str + ] + ); + default = { }; + description = "Values for the Project Zomboid SandboxVars.lua file."; + }; + openFirewall = lib.mkOption { type = lib.types.bool; default = true; @@ -151,6 +173,15 @@ in { ${lib.optionalString (cfg.serverPropertiesFile != null) "${pkgs.coreutils}/bin/cat ${lib.escapeShellArg cfg.serverPropertiesFile};"} } > ${lib.escapeShellArg "${cfg.dataDir}/Server/${cfg.serverName}.ini"} + ${lib.optionalString (cfg.sandboxProperties != { }) '' + { + ${pkgs.coreutils}/bin/printf '%s\n' 'SandboxVars = {'; + ${lib.concatMapStringsSep "\n " (line: + "${pkgs.coreutils}/bin/printf '%s\\n' ${lib.escapeShellArg line};" + ) sandboxConfigLines} + ${pkgs.coreutils}/bin/printf '%s\n' '};'; + } > ${lib.escapeShellArg "${cfg.dataDir}/Server/${cfg.serverName}_SandboxVars.lua"} + ''} ''; serviceConfig = { @@ -159,7 +190,7 @@ in { WorkingDirectory = cfg.dataDir; Environment = [ "HOME=${cfg.dataDir}" - "SteamAppId=380870" + "SteamAppId=108600" ]; ExecStart = startScript; Restart = "on-failure"; diff --git a/nixos/system/hectic-lab/hectic-lab.nix b/nixos/system/hectic-lab/hectic-lab.nix index 526a5ab0..d778538a 100644 --- a/nixos/system/hectic-lab/hectic-lab.nix +++ b/nixos/system/hectic-lab/hectic-lab.nix @@ -95,8 +95,65 @@ in { enable = true; memory = "3g"; serverName = "servertest"; - workshopItems = [ ]; - mods = [ ]; + serverProperties = { + Map = "map_distanciado;Muldraugh, KY"; + DoLuaChecksum = false; + Public = true; + }; + sandboxProperties = { + StartMonth = 12; + StartDay = 1; + }; + workshopItems = [ + "2210760610" # Cryogenic Winter +Easy/Hard Modes + "3676456221" # Lua Digital Watch Framework + "3600401184" # Realistic Temperature Mod + "3387824513" # Material Weight Reducer + "3543229299" # Project RV Interior + "3387539308" # Auto Mechanics + "3402491515" # Tsar's Common Library B42 + "3403490889" # Standardized Vehicle Upgrades 3 - Core + "3520758551" # More Car Features + Spawn Zones Expansion + "3110911330" # '87 Ford B700/F700 Trucks + "3413150945" # More Damaged Objects + "3554424111" # U.S. M998 Humvee + "2705406713" # Military Tool Kit + "3512708849" # Shotgun Trajectory + "3401576145" # Firearm Models: Redux + "3401134276" # Vanilla Gear Expanded + "3394044313" # Buttstroke / Gun Stock Attack + "2956146279" # Rain Cleans Blood + "3693258802" # Tactical Hold + "3394588830" # Simple Flashlight on Belt + "2684285534" # Spongie's Clothing + "2812326159" # Spongie's Open Jackets + ]; + mods = [ + "\\PROJECTRVInterior42" + "\\Military_Tool_Kit" + "\\CryogenicWinter2NormalMode" + "\\LuaDigitalWatchUI" + "\\RC_RealisticColdMod" + "\\Material Weight Reducer" + "\\Ammunition Weight Reducer" + "\\AutoMechanics" + "\\tsarslib" + "\\StandardizedVehicleUpgrades3Core" + "\\WayMoreCars" + "\\87fordB700" + "\\MoreDamagedObjects" + "\\U.S. M998 Humvee by Papa_Chad" + "\\ShotgunTrajectory" + "\\FMR" + "\\VanillaGearExpanded" + "\\Buttstroke" + "\\RainCleansBlood" + "\\TacHold Complete" + "\\LightOnBelt" + "\\SpnCloth" + "\\SpnOpenClothBase" + "\\SpnOpenCloth" + ]; }; services.p4d = { enable = true;