1
0
Fork 0
mirror of https://github.com/dosbox-staging/dosbox-staging synced 2025-12-04 16:27:29 -05:00
3 Building on NixOS
John Novak edited this page 2025-05-27 13:20:00 +10:00

Building on NixOS

Warning

This is user-contributed content. NixOS is not directly supported by the DOSBox Staging team. If something doesn't work, please don't contact the core team and don't raise an issue ticket but get in touch with fellow NixOS users and update this wiki page if needed.

Compiling code on Nix requires slightly different inputs from other Linux distros, since the appropriate environment variables for pkg-config are only avaliable under the nix-shell command.

Note

CMake support is currently an experimental internal-only, work-in-progress feature; it's not ready for public consumption yet. Please ignore the CMakeLists.txt files in the source tree.

Installing the dependencies under Nix

Nix has a unique toolset where you are not required to install the dependencies to run them. However, if you still want to, we recommend you to do the following:

  1. Install Home-Manager: https://github.com/nix-community/home-manager#installation.

  2. After following the installation guide, add the following packages on your home.nix:

    home.packages = [ pkg-config gcc_multi cmake ccache SDL2 SDL2_net
            fluidsynth glib gtest libGL libGLU libjack2 libmt32emu libogg
            libpng libpulseaudio libslirp libsndfile meson ninja opusfile
            libselinux speexdsp stdenv alsa-lib xorg.libXi irr1 ]
    
  3. Rebuild with the command home-manager switch

Install dependencies in a standard Nix configuration

  1. Add the following packages to configuration.nix:

    environment.systemPackages = [
            pkg-config gcc_multi cmake ccache SDL2 SDL2_net
            fluidsynth glib gtest libGL libGLU libjack2 libmt32emu libogg
            libpng libpulseaudio libslirp libsndfile meson ninja opusfile
            libselinux speexdsp stdenv alsa-lib xorg.libXi irr1 ];
    

Build

After you git clone https://github.com/dosbox-staging/dosbox-staging.git and finish setting it up, create a NixOS.txt (text at the end of this wiki page) and then run the following command from the terminal, with or without the dependencies installed:

nix-shell -p $(cat NixOS.txt) --run 'meson setup build'

Once it's finished setting up the build, run:

nix-shell -p $(cat NixOS.txt) --run 'meson compile -C build'

After that, you should be all set! Your binary will be located in build/dosbox! See more build options in BUILD.md.

OpenGL on non-NixOS

If you are either running in a nixpkgs setup or with NixOS installed inside of another system (using the Chroot method), you may have issues getting OpenGL working with DOSBox Staging. This is caused by how Nix handles OpenGL, and can be fixed with wrappers developed by the community.

Currently, we recommend installing the nixGL wrapper, as it works flawlessly with DOSBox Staging. After installing the wrapper appropriate to your hardware, run the following command in the terminal to launch your binary:

Launching with nixGLDefault (tries to auto-detect your setup)

nixGL ./build/dosbox

Launching with nixGLNvidia (uses Nvidia drivers)

nixGLNvidia ./build/dosbox

Launching with nixGLNvidiaBumblebee (uses Nvidia drivers on hybrid hardware)

nixGLNvidiaBumblebee ./build/dosbox

Launching with nixGLIntel (uses Mesa drivers for AMD, Intel, Nouveau, etc.)

nixGLIntel ./build/dosbox

NixOS.txt Contents

meson ninja gcc_multi cmake ccache SDL2 SDL2_net gtest \
  fluidsynth glib libGL libGLU libjack2 libmt32emu libogg libpng libpulseaudio \
  libslirp libsndfile opusfile libselinux speexdsp stdenv alsa-lib xorg.libXi \
  iir1 pkg-config ffmpeg