From 99101f270f20f38667b9cf568d84cd86cba23da4 Mon Sep 17 00:00:00 2001 From: aszlig Date: Tue, 15 Mar 2016 04:29:04 +0100 Subject: games/starbound: Properly handle -bootconfig arg First of all, we need to create another wrapper around the command line arguments, because Starbound will bail out whenever there is more than one -bootconfig argument. In addition, we are now putting in build time information into $out/etc/sbboot.config so we can easily re-use them, for example for a NixOS service module. Also, the hasBootconfigArg is now used for all flavors, because even the stable version supports that argument already. Signed-off-by: aszlig --- pkgs/games/steam/starbound.nix | 89 ++++++++++++++++++++++++++++++------------ 1 file changed, 64 insertions(+), 25 deletions(-) (limited to 'pkgs/games/steam') diff --git a/pkgs/games/steam/starbound.nix b/pkgs/games/steam/starbound.nix index 631bd8ef..25272169 100644 --- a/pkgs/games/steam/starbound.nix +++ b/pkgs/games/steam/starbound.nix @@ -20,7 +20,9 @@ let binaryDeps = mkOsBinaryDeps { starbound.deps = [ SDL mesa ]; + starbound.hasBootconfigArg = true; starbound_server.name = "starbound-server"; + starbound_server.hasBootconfigArg = true; asset_packer.name = "starbound-asset-packer"; asset_unpacker.name = "starbound-asset-unpacker"; dump_versioned_json.name = "starbound-dump-versioned-json"; @@ -35,6 +37,9 @@ let else if stdenv.system == "x86_64-cygwin" then "win64" else throw "Unsupported system ${stdenv.system} for Starbound"; + throwUnsupported = throw "Unsupported flavor `${flavor}', use either " + + "`stable' or `unstable'."; + upstreamInfo = if flavor == "stable" then { name = "starbound"; version = "20151216"; @@ -49,7 +54,7 @@ let depotId = 367541; manifestId = 6970641909803280413; sha256 = "0qppfn56c778wsg38hi6sxgi3rl9nv72h9rmmxybi1vzpf3p49py"; - } else throw "Unsupported flavor, use either `stable' or `unstable'."; + } else throwUnsupported; upstream = fetchSteam { inherit (upstreamInfo) name appId depotId manifestId sha256; @@ -60,25 +65,33 @@ let ]; }; - bootOverrides = { - storageDirectory = "$XDG_DATA_HOME/starbound"; - modSource = "$XDG_DATA_HOME/starbound/mods"; + staticBootOverrides = writeText "bootconfig.overrides" (builtins.toJSON { assetSources = [ "${upstream}/assets/packed.pak" "${upstream}/assets/user" ]; + }); + + bootOverrides = { + storageDirectory = "$XDG_DATA_HOME/${settingsDir}/"; + modSource = "$XDG_DATA_HOME/${settingsDir}/mods/"; }; + settingsDir = + if flavor == "stable" then "starbound" + else if flavor == "unstable" then "starbound-unstable" + else throwUnsupported; + mkProg = bin: attrs: let basename = builtins.baseNameOf bin; hasBootconfigArg = attrs.hasBootconfigArg or false; bootconfigArgs = with stdenv.lib; let - bootconfig = "$XDG_DATA_HOME/starbound/sbboot.config"; - logfile = "$XDG_DATA_HOME/starbound/starbound.log"; - args = " -bootconfig \"${bootconfig}\" -logfile \"${logfile}\""; - in optionalString hasBootconfigArg args; + mkArg = opt: val: "-${opt} \"${val}\""; + in " " + (concatStringsSep " " (mapAttrsToList mkArg { + bootconfig = "$XDG_DATA_HOME/${settingsDir}/sbboot.config"; + })); wrapper = writeText "starbound-wrapper.sh" '' #!${stdenv.shell} -e @@ -87,17 +100,37 @@ let mkdir -p "${bootOverrides.storageDirectory}" \ "${bootOverrides.modSource}" - "${jq}/bin/jq" -s '.[0] * .[1]' \ - <(sed -e 's,//.*,,' "${upstream}/${binpath}/sbboot.config") \ - - > "$XDG_DATA_HOME/starbound/sbboot.config" \ + "${jq}/bin/jq" -s '.[0] * .[1]' "@out@/etc/sbboot.config" - \ + > "$XDG_DATA_HOME/${settingsDir}/sbboot.config" \ < "$out/etc/sbboot.config" ${stdenv.lib.concatStrings (stdenv.lib.mapAttrsToList mkProg binaryDeps)} install -m 0644 -vD "${desktopItem}/share/applications/starbound.desktop" \ "$out/share/applications/starbound.desktop" -- cgit 1.4.1