Game binary (Dwarf Fortress), no sound on nix-ld

Hello,

I’m trying to play Dwarf Fortress Premium (51.08), distributed as an elf binary from itch.io. Up until last year I used to play this with steam-run, and that worked just fine. But after a few months I didn’t try, with current versions of the game and steam-run (nixOS 25.05beta768633.c80f6a7e10b3 ), I get

./dwarfort: error while loading shared libraries: libSDL2_image-2.0.so.0: cannot open shared object file: No such file or directory

So I tried using nix-ld with:

  programs.nix-ld.enable = true;
  programs.nix-ld.libraries = with pkgs; [
    SDL2
    SDL2_image
  ];

This loads the SDL2 libraries and runs the game.

The game distributes a sound plugin, libfmod.so.13 , loaded dynamically. If I do like

env NIX_LD_LIBRARY_PATH=":.:$NIX_LD_LIBRARY_PATH" nix-ld

…the game manages to load this plugin, according to the logs. However, no sound plays. It doesn’t even show a stream in pavucontrol.

If I deliberately don’t pass “.” to the load path, the game will attempt to use SDL2_mixer as a fallback. If I add SLD2_mixer and SDL2_audio to the nix-ld config, it will load that successfully, and even show a stream in pavucontrol (labelled ld-linux-x86-64.so.2 ). But still, no sound plays.

The stream is not muted and sound works in other applications. Sound in this game worked back when I used to run it with steam-run.

What else can I do in this case? Is there any trick to get apps running under nix-ld to interact normally with the sound system?

Heh. If I do

nix-ld /run/current-system/sw/bin/sh steam-run ./run_df

sound works. presumably nix-ld loads the SDL2_image, and steam-run does something that fixes the sound.

Fellow DF-enjoyer here, although I don’t have the Premium release yet.

You’d probably have the most luck using patchelf.

The easiest path would probably be to make a ‘package’ using autoPatchelfHook and requirefile.

2 Likes

I recently pushed changes that allow us to support each version up to 51.08:

I’ve seen issues with audio too though, ever since v50 came out, and have not located a solution for us in nixpkgs. One suggestion is to LD_PRELOAD fmod, but this doesn’t look like it changed anything.

1 Like

I am pleased to report that audio in Dwarf Fortress is now fixed in nixpkgs!

Turns out, I was attempting to LD_PRELOAD the fmod plugin for Dwarf Fortress, instead of fmod itself. The same problem and solution applies to SDL2_mixer.