Hi there!
I’m quite happy as recently I’ve finished my first (software) package for nix. It being the GoG, Linux native, version of the game Darkest Dungeon, which, btw I totally recommend.
As I was encountering issues with Lutris, minigalaxy, etc… I’ve decided to package it myself.
Contrary to what’s advised here I’ve choose not to use steam-run
or steam-run-native
and just patch the binary using the libs from nixpkgs.
As this is my first time doing anything like that I would like to receive some feedback. I want to stick to best practices whenever possible. I should also state that the following code is NOT YET FINISHED.
TODO:
There are a few things which I need to fix (I do have an important exam this week so it will happen afterwards) like:
- It does not work with the installation shellscript provided by GoG, this was due to testing purposes and would be changed soon.
- There’s duplicated code.
- I have to add a formatter.
- It might be possible to delete some unused files in order to reduce the closure size.
Code
That being said, the code of the flake:
{
description = "Darkest Dungeon (GoG) Flake";
inputs = {
nixpkgs.url = github:NixOS/nixpkgs/nixos-unstable;
flake-utils.url = github:numtide/flake-utils;
};
outputs = { self, nixpkgs, flake-utils }:
with flake-utils.lib; eachDefaultSystem (system:
let
inherit (self) outputs;
pkgs = nixpkgs.legacyPackages.${system};
in rec {
packages = {
darkest-dungeon = pkgs.stdenvNoCC.mkDerivation rec {
name = "darkest-dungeon";
# TODO: Change this to the official installer instead.
src = pkgs.requireFile {
name = "darkest-dungeon.tar";
url = "https://www.gog.com/game/darkest_dungeon & some whichcraft";
sha256 = "b3001d41c28279b39a9b5fdee08930f51479d3472f1f049781cebcd6bf62c81d";
};
nativeBuildInputs = with pkgs; [
autoPatchelfHook
makeBinaryWrapper
SDL2
libcxx
libGL
fmodex
libmx
fmodex
xorg.libX11
xorg.libXext
xorg.libxcb
xorg.libXau
xorg.libXdmcp
];
runtimeDependenciesPath = with pkgs; pkgs.lib.makeLibraryPath [
SDL2
libcxx
libGL
fmodex
libmx
fmodex
xorg.libX11
xorg.libXext
xorg.libxcb
xorg.libXau
xorg.libXdmcp
];
phases = [ "unpackPhase" "installPhase" "fixupPhase" ];
installPhase = ''
mkdir -p $out/share/${name}
cp -r . $out/share/${name}
makeBinaryWrapper $out/share/${name}/darkest.bin.x86_64 $out/bin/darkest \
--prefix LD_LIBRARY_PATH : "$runtimeDependenciesPath"
'';
};
};
defaultPackage = packages.darkest-dungeon;
});
}
Help
And now a list of things in which I need some help:
- What is this missing, if any, to be a “correct package”?
- How can I use
flake-utils
to avoid having to define a formatter for each system? - How can I specify the license, maintainer, supported systems and etc?
- How would you add feral
gamemoderun
support only if already installed? - If I wanted to delete useless files from the
tar
, in which phase should it be done? - Am I ussing
nativeBuildInputs
right?
Conclusion
Once everything mentioned in this post has been solved I would like upload this flake to my personal Codeberg and add it to the gaming section in the NixOS wiki, (which I might even end up improving).
Thanks for your attention and time everyone.