Building devilutionx as beginner - cmake doesn't find libsodium


I’m trying to add devilutionx (reverse-engineered Diablo game) to my nixpgks : GitHub - diasurgical/devilutionX: Diablo build for modern operating systems

So far I’ve come up with this derivation:

{ stdenv, fetchgit, cmake, gcc, SDL2, SDL2_mixer, SDL2_ttf, libsodium}:
stdenv.mkDerivation rec {
  name = "devilutionx-${version}-${rev}";
  version = "0.4.0";
  rev = "1f20338";
  src = fetchgit {
    url = "";
    inherit rev;
    sha256 = "12lkx4jqj1vinp9plka3xx4hxxbrszhjpvgv0m4x44p0vqzqrdir";

  nativeBuildInputs = [ cmake gcc ];
  buildInputs = [ SDL2 SDL2_mixer SDL2_ttf libsodium sodium];

  meta = with stdenv.lib; {
    homepage =;
    description = "DIABLO";
    license = licenses.gpl3Plus;
    maintainers = [ maintainers.astsmtl ];
    platforms = platforms.linux;

Unfortunately when running nix-build -A devilutionx, I get this error message:

these derivations will be built:
building '/nix/store/cxzwhklc3dhg1lzg9dd01kk65xi39vbn-devilutionx-0.4.0-1f20338.drv'...
unpacking sources
unpacking source archive /nix/store/frnvjjks0p54giqlf7j3pkadd3z11gy5-devilutionX-1f20338
source root is devilutionX-1f20338
patching sources
fixing cmake files...
cmake flags: -DCMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY=ON -DCMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY=ON -DCMAKE_EXPORT_NO_PACKAGE_REGISTRY=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_SKIP_BUILD_RPATH=ON -DBUILD_TESTING=OFF -DCMAKE_INSTALL_INCLUDEDIR=/nix/store/mcg265d3x6kzbb01k8cpcpa5697ih9g0-devilutionx-0.4.0-1f20338/include -DCMAKE_INSTALL_LIBDIR=/nix/store/mcg265d3x6kzbb01k8cpcpa5697ih9g0-devilutionx-0.4.0-1f20338/lib -DCMAKE_INSTALL_NAME_DIR=/nix/store/mcg265d3x6kzbb01k8cpcpa5697ih9g0-devilutionx-0.4.0-1f20338/lib -DCMAKE_POLICY_DEFAULT_CMP0025=NEW -DCMAKE_OSX_DEPLOYMENT_TARGET= -DCMAKE_OSX_SYSROOT= -DCMAKE_FIND_FRAMEWORK=last -DCMAKE_STRIP=/nix/store/zizh5qzhcn4wzm06z99297ckalwrrpfk-binutils-2.31.1/bin/strip -DCMAKE_RANLIB=/nix/store/zizh5qzhcn4wzm06z99297ckalwrrpfk-binutils-2.31.1/bin/ranlib -DCMAKE_AR=/nix/store/zizh5qzhcn4wzm06z99297ckalwrrpfk-binutils-2.31.1/bin/ar -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DCMAKE_INSTALL_PREFIX=/nix/store/mcg265d3x6kzbb01k8cpcpa5697ih9g0-devilutionx-0.4.0-1f20338
-- The C compiler identification is GNU 7.4.0
-- The CXX compiler identification is GNU 7.4.0
-- Check for working C compiler: /nix/store/7nvy9l5jcp1c6z6n96l1a5x1bwbvamqn-gcc-wrapper-7.4.0/bin/gcc
-- Check for working C compiler: /nix/store/7nvy9l5jcp1c6z6n96l1a5x1bwbvamqn-gcc-wrapper-7.4.0/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /nix/store/7nvy9l5jcp1c6z6n96l1a5x1bwbvamqn-gcc-wrapper-7.4.0/bin/g++
-- Check for working CXX compiler: /nix/store/7nvy9l5jcp1c6z6n96l1a5x1bwbvamqn-gcc-wrapper-7.4.0/bin/g++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Warning at CMakeLists.txt:63 (message):
  sizeof(void*) == 8.

CMake Warning at CMakeLists.txt:64 (message):
  Not 32-bit, highly experimental!

-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Check if compiler accepts -pthread
-- Check if compiler accepts -pthread - yes
-- Found Threads: TRUE
-- Found SDL2: /nix/store/1dmh4k7vn6g4sd1vn25isc4svykxjkwj-SDL2-2.0.9/lib/
-- Found SDL2_ttf: /nix/store/26lcmkgfc684fa4jvypgg9dsnf2hxxmx-SDL2_ttf-2.0.15/lib/
-- Found SDL2_mixer: /nix/store/9w1f9ffr076g90d5vymiq24d193bibhq-SDL2_mixer-2.0.4/lib/
CMake Error at /nix/store/m8asgav7lgbivj21pkpfjv7p6712kw9l-cmake-3.13.4/share/cmake-3.13/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
  Could NOT find sodium (missing: sodium_LIBRARY_RELEASE
Call Stack (most recent call first):
  /nix/store/m8asgav7lgbivj21pkpfjv7p6712kw9l-cmake-3.13.4/share/cmake-3.13/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE)
  CMake/Findsodium.cmake:227 (find_package_handle_standard_args)
  CMakeLists.txt:71 (find_package)

-- Configuring incomplete, errors occurred!
See also "/build/devilutionX-1f20338/build/CMakeFiles/CMakeOutput.log".
See also "/build/devilutionX-1f20338/build/CMakeFiles/CMakeError.log".
builder for '/nix/store/cxzwhklc3dhg1lzg9dd01kk65xi39vbn-devilutionx-0.4.0-1f20338.drv' failed with exit code 1
error: build of '/nix/store/cxzwhklc3dhg1lzg9dd01kk65xi39vbn-devilutionx-0.4.0-1f20338.drv' failed

I’m a bit lost why sodium is not found by cmake, though it is added in buildInput.

For what it helps the project’s cmakelist.txt requires it here:

Maybe libsodium should be renamed to sodium to make cmake find it?

Any help appreciated.

If it makes it easier, here it is on a branch :

devilutionx tries to find libsodium using pkg-config and fails silently if pkg-config is not available, hence you need to provide it:

nativeBuildInputs = [ pkg-config ];

Just some hints:

  • We’re probably going to deprecate unquoted URL syntax with RFC 45 (your meta.homepage attribute)
  • Please make the description a bit longer, e.g. “Diablo build for modern operating systems”
  • Upstream says it’s unplayable in 64 bit so you should probably try to cross build it for 32 bit
  • The license is not GPLv3+, see here

Thanks you @JohnAZoidberg, adding pkg-config solved the problem :slight_smile: I had some other issues, but I’ve managed to fix those and it builds and runs now.

One question though: I find it hard to understand how the cross-build works. I’ve read the manual but it’s still not clear. If I’m on 64 bit Linux, can I build it for 32 bit? How to do so?

It runs? Is it playable?

To crossbuild you could do

nix build -f . devilutionx --arg crossSystem '{ config = "i686-unknown-linux-gnu";  }'

See: Beginner’s guide to cross compilation in Nixpkgs

Yup, I’ve played it for a couple of minutes, everything seems to work, including saving and loading a game. They seem to have improved the 64 bit support a lot lately, so I’m pretty happy with it.

One caveat: the graphics are cropped in fullscreen, but smooth and playable. There are some config options to play with, maybe it can be improved, I’ll try it later.

It’s still an early version of the project, but it’s actively being developed. I’m sure the experience will get better with time. I’m just happy to be able to play native Diablo on Linux :smiley:

Here’s the PR:

I’ve briefly looked into the SDL2_ttf missing include directory and am a bit baffled. Anyone want to look into why pkgconfig isn’t properly pulling in the SDL2_ttf include (but it is pulling in both SDL2 and SDL2_mixer)?