Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Darkest Dungeon (GoG) derivation #118

Draft
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

SrEstegosaurio
Copy link

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.

This is a first draft. The game works perfectly but some things
might still be missing (ex. gamemode support) but those should
be trivial to implement later on. I hope.
According to the docs it gets automatically executed after
execution.
pkgs/darkest-dungeon/default.nix Outdated Show resolved Hide resolved
pkgs/darkest-dungeon/default.nix Outdated Show resolved Hide resolved
pkgs/darkest-dungeon/default.nix Outdated Show resolved Hide resolved
pkgs/darkest-dungeon/default.nix Outdated Show resolved Hide resolved
@SrEstegosaurio
Copy link
Author

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.

@fufexan
Copy link
Owner

fufexan commented Oct 9, 2023

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
'';

@SrEstegosaurio
Copy link
Author

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
    '';

@fufexan
Copy link
Owner

fufexan commented Oct 10, 2023

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

@SrEstegosaurio
Copy link
Author

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.

@fufexan
Copy link
Owner

fufexan commented Oct 16, 2023

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.

@SrEstegosaurio
Copy link
Author

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.

@fufexan
Copy link
Owner

fufexan commented Dec 18, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants