Godot, sound and gamepad in a containerized Guix shell
Godot Engine is a tool for developing 2D and 3D games. GNU Guix is a tool for managing software packages and reproducible software environments. This entry shows a way of getting sound and gamepads to work when running a Godot-based game in an isolated software environment created with Guix.
In the following example I use the binary distribution of a game called Radiata, a game of my own, never published, single-screen, simple but complete, with animations, sound and gamepad support. This game is based on Dodge the Creeps!, from Godot's tutorial. The file structure of the exported games looks like this:
radiata/ ├── index.org ← Usage instructions. ├── manifest.scm ← Guix manifest. ├── radiata.sh ← Executable generated by Godot (I ignore it) └── radiata.x86_64 ← Game binary
The Guix manifest declares the software packages that must be available in the environment for the game to run correctly. It contains the following:
#| GNU Guix manifest This file is a GNU Guix manifest. It can be used to create different kinds of software environments that provide the software and artifacts listed below. |# (use-modules (gnu packages)) (define %qol-requirements #| QoL stands for "Quality of Life". These packages provide tools that make it easier to work inside isolated software environments, which don't inherit basic tools from the host environment. |# (list "bash" "coreutils")) (define %godot-requirements (list "alsa-lib" "dbus" "eudev" "fontconfig" "libx11" "libxcursor" "libxkbcommon" "libxext" "libxinerama" "libxrandr" "libxi" "mesa" "pulseaudio")) (specifications->manifest (append %qol-requirements %godot-requirements))
To run the game, issue the following commands in a terminal. The game is launched in a container that emulates an FHS file system:
-
Create an independent directory to save game session data:
$ mkdir /tmp/radiata
-
Change location to the directory of the game:
$ cd path/to/game/directory/radiata
-
Activate an isolated environment for running the game:
$ HOME=/tmp/radiata \ guix shell --container --emulate-fhs \ --manifest=manifest.scm \ --preserve="^DISPLAY$" \ --preserve="^XAUTHORITY$" \ --preserve="^XDG_RUNTIME_DIR$" \ --preserve="^HOME$" \ --expose="$XAUTHORITY" \ --expose=/tmp/.X11-unix/ \ --expose=/dev/dri \ --expose=/dev/input \ --expose=$XDG_RUNTIME_DIR/pulse
-
Start the game:
$ ./radiata.x86_64
At this point, the game window is displayed and you can start interacting normally with it. When you are done playing, you can close the window and finally deactivate the environment using the keyboard shortcut Ctrl+D
or exiting the terminal window.
Related topics: