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.
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:
-
Install Home-Manager: https://github.com/nix-community/home-manager#installation.
-
After following the installation guide, add the following packages on your home.nix:
home.packages = [ pkg-config gcc_multi cmake ccache SDL2 SDL2_image 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 ]
-
Rebuild with the command
home-manager switch
-
Add the following packages to configuration.nix:
environment.systemPackages = [ pkg-config gcc_multi cmake ccache SDL2 SDL2_image 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 ];
After you git clone https://github.com/dosbox-staging/dosbox-staging.git
and
finish setting it up, run the following command from the terminal, with or without
the dependencies installed:
nix-shell -p $(cat packages/NixOS.txt) --run 'meson setup build'
Once it's finished setting up the build, run:
nix-shell -p $(cat packages/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.
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:
nixGL ./build/dosbox
nixGLNvidia ./build/dosbox
nixGLNvidiaBumblebee ./build/dosbox
nixGLIntel ./build/dosbox