nix-gaming icon indicating copy to clipboard operation
nix-gaming copied to clipboard

Added Darkest Dungeon (GoG) derivation

Open SrEstegosaurio opened this issue 1 year ago • 8 comments

Adds a Darkest Dungeon derivation. (Link to the game website).

This is related to the issue #110. While this is just a single game and not a builder I think it still has value because:

  1. Immediately provides another game to possible end users.
  2. It serves as an starting point and I would very much appreciate constructive criticism. I'm a bit noob with nix. 😅

WIP

  • I still need to iron out some things like gamemode support, a proper icon and maybe clean up some bits here and there.
  • Documentation is also missing since I feel that a disclaimer stating that this is not piracy and the end user need to provide the original installer.

SrEstegosaurio avatar Oct 07 '23 00:10 SrEstegosaurio

The unpackPhase is now fixed. Only a few things remain to be done at this point:

  • Gamemoderun support.
  • DLCs.
  • Mods.

I mostly ignore the feasibility of the last two. I'll start working on those a soon as possible.

SrEstegosaurio avatar Oct 08 '23 13:10 SrEstegosaurio

Gamemode support can be achieved the same as here. For DLCs/Mods, I think we can have a list/attrset of them and unpack them in the specific directories. Shouldn't be too hard. Could look like this, given something like dlcs.dlc1 = requireFile {...};

dlcs ? {},
mods ? {},
# ...
}: let
  unpackDlc = name: zip: ''
    mkdir -p $out/dlcs/${name}
    cd $out/dlcs/${name}
    unzip ${zip}
    # return to base dir
  '';
in {
# ...
buildPhase = ''
  # ...
  concatStringsSep "\n" mapAttrs unpackDlc dlcs;
  # same for mods
'';

fufexan avatar Oct 09 '23 16:10 fufexan

Regarding gamemoderun: I've tried doing something akin to what you linked and got no result. Someone over the matrix room even told me write another derivation...

Here is my current best attempt:

    installPhase = let 
      script = writeShellScriptBin pname ''
        export LD_LIBRARY_PATH=${lib.makeLibraryPath commonDeps}

        ${lib.optionalString gamemodeIntegration "${gamemode}/bin/gamemoderun"} $out/share/${pname}/darkest.bin.x86_64
      '';


    in ''
      mkdir -p $out/share/${pname}
      mkdir -p $out/share/icons/hicolor
      mkdir -p $out/bin

      # Only copies this folder since the rest is useless.
      mv data/noarch/game/* $out/share/${pname}

      # Installs the icon.
      mv data/noarch/support/icon.png $out/share/icons/hicolor/${pname}.png

      cp ${script}/bin/${pname} $out/bin/darkest
    '';

SrEstegosaurio avatar Oct 10 '23 16:10 SrEstegosaurio

Looks good, what doesn't work? Does the resulting script have the gamemode invocation as expected?

fufexan avatar Oct 10 '23 18:10 fufexan

The wrapper errors out trying to execute the original binary because it's not found.

The exact error message:

$ nix run .\#darkest-dungeon
env: ‘/share/darkest-dungeon/darkest.bin.x86_64’: No such file or directory

I don't know why does it treat /share/darkest-[...] as an absolute path. The original binary it's included in the derivation, under result/share/darkest-dungeon/darkest.bin.x86_64.

SrEstegosaurio avatar Oct 13 '23 10:10 SrEstegosaurio

Oh, I know what's going on. The $out in writeShellScriptBin refers to the script's outPath, not the entire derivation's. So you'll have to echo the command to $out/bin/darkest instead of copying it. Let me know if it works.

fufexan avatar Oct 16 '23 10:10 fufexan

Hi and sorry for not answering for a long time. I did wrote a response but apparently GitHub decided to not send it...

I've been pretty busy lately with school stuff but here I am.

I got stuck with both the gamemoderun integration and adding the DLCs.

I'm trying to add DLCs right now.

SrEstegosaurio avatar Nov 01 '23 00:11 SrEstegosaurio

It would be better to do rebases instead of merges, as merges make the history non-linear.

fufexan avatar Dec 18 '23 11:12 fufexan