nix-gaming
nix-gaming copied to clipboard
Added Darkest Dungeon (GoG) derivation
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:
- Immediately provides another game to possible end users.
- 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.
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.
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
'';
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
'';
Looks good, what doesn't work? Does the resulting script have the gamemode invocation as expected?
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
.
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.
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.
It would be better to do rebases instead of merges, as merges make the history non-linear.