Gaming related stuff for Nix and NixOS.
Package | Description |
---|---|
osu-lazer-bin |
osu! lazer, extracted from the official AppImage |
osu-stable |
osu! stable version |
rocket-league |
Rocket League from Epic Games |
technic-launcher |
Technic Launcher |
wine-discord-ipc-bridge |
Wine-Discord RPC Bridge |
wine-osu |
Wine optimized for low latency |
wine-tkg |
Wine optimized for games |
winestreamproxy |
Wine-Discord RPC (broken) |
-
osu-lazer-bin
is an osu!lazer build that is extracted from official binary AppImage releases in order to preserve multiplayer functions. -
osu-stable
provides a script that installs/runs osu! automatically, in addition to a desktop entry. Installation will take a bit of time. It will download and install about 400MB of files. In any case, do not stop the command! If anything goes wrong and for some reason osu! won't start, delete the~/.osu
directory and re-runosu-stable
. -
rocket-league
relies onlegendary-gl
, which expects you to log in. It's best to do that before running RL, by addinglegendary-gl
in a nix shell and runninglegendary auth
. -
technic-launcher
will guide you through the install process, just like it normally would. Some modpacks will complain about libraries, and that is expected. In such cases you may want to enable thewithSteamRun = true;
override flag. This will runtechnic-launcher
withsteam-run
and prevent those errors. -
wine-discord-ipc-bridge
provides bridging between games under Wine and Discord running on Linux. -
wine-osu
is wine-staging, with patches applied to make it low-latency. The patches can be found here. -
wine-tkg
is a special wine version, tailored for the best gaming experience. It consists of a wine tree generated with the tkg patches. -
winestreamproxy
provides bridging between games under Wine and Discord running on Linux. (currently broken, help with building would be appreciated)
It's recommended to set up Cachix so you don't have to build packages.
# configuration.nix
{
nix.settings = {
substituters = [ "https://nix-gaming.cachix.org" ];
trusted-public-keys = [ "nix-gaming.cachix.org-1:nbjlureqMbRAxR1gJ/f3hxemL9svXaZF/Ees8vCUUs4=" ];
};
}
Now, rebuild your configuration and continue reading for install instructions.
If you're not using flakes, skip to here.
Add these packages to your home.packages
or environment.systemPackages
by
adding nix-gaming
as an input:
# flake.nix
{
inputs.nix-gaming.url = github:fufexan/nix-gaming;
}
Also, add inputs
or nix-gaming
to specialArgs
when building your system
config, or to extraSpecialArgs
when building your Home Manager configuration.
Then, add the package(s):
{ pkgs, config, inputs, ... }:
{
environment.systemPackages = [ # or home.packages
inputs.nix-gaming.packages.x86_64-linux.<package> # installs a package
];
}
If you want to install packages to your profile instead, do it like this
nix profile install github:fufexan/nix-gaming#<package>
NOTE: the above snippet won't work if you use Home-Manager. You can use the
old nix-env
syntax.
Everything is available as an overlay if you prefer that, though your results may greatly differ from the packages.
The following instructions assume you have this repo cloned somewhere.
To install packages with nix-env
, run
cd directory/of/nix-gaming
nix-env -if . -A packages.x86_64-linux.<package>
To install packages to environment.systemPackages
, add this in
configuration.nix
:
let
nix-gaming = import (builtins.fetchTarball "https://github.com/fufexan/nix-gaming/archive/master.tar.gz");
in
{
# import the low latency module
imports = [
...
"nix-gaming/modules/pipewireLowLatency.nix"
];
# install packages
environment.systemPackages = [ # home.packages
nix-gaming.packages.x86_64-linux.<package>
];
# enable module (see below)
services.pipewire = ...;
}
PipeWire is a new audio backend that replaces ALSA, PulseAudio and Jack. It achieves lower latency than possible previously with Pulse, for lower CPU overhead.
This module extends the PipeWire module from nixpkgs and makes it easy to enable the low latency settings from a single line (or more).
Add it as a module to your configuration and enable it along with PipeWire:
{
services.pipewire = {
enable = true;
# alsa is optional
alsa.enable = true;
alsa.support32Bit = true;
# needed for osu
pulse.enable = true;
# the star of the show
lowLatency.enable = true;
# defaults (no need to be set unless modified)
lowLatency = {
quantum = 64;
rate = 48000;
};
};
# make pipewire realtime-capable
security.rtkit.enable = true;
}
If you get no sound, you may want to increase quantum
, usually to an even
number or the prefix of the rate
(48/48000
is exactly 1ms).
The game derivations were written with versatility in mind. There are args that can be modified in order to get the result one wants.
{
wine ? wine-tkg # controls the wine package used to run wine games
wineFlags ? null # which flags to run wine with
pname ? "game-name" # name of the script and package
location ? "$HOME/${pname}" # where to install the game/wine prefix
tricks ? null # which wine tricks to install
}
The osu!install.exe
is periodically updated upstream, but it's not versioned.
Due to this, we have to update its hash constantly.
When there's a hash mismatch between your system and upstream, the fix is to signal the new version (either in an issue, PR or messaging me on Discord @ fufexan#1006). After the flake has been updated, the steps to fix the mismatch on your system are as follows:
- update your inputs, remove osu from your config and rebuild
- reboot
- do a store garbage collect (
nix-collect-garbage -d
specifically) - re-add osu in your config and rebuild
This should fix it, even though it's quite troublesome. I'll think of a better strategy in the meantime.
In order to get the most performance out of your machine, you could use the following tweaks:
- custom/gaming kernel:
linux_xanmod
is the recommended one for games, since it provides many patches that aid wine and other games. NOTE: Xanmod is not preferred on laptops and other power-constrained devices, as the tick scheduler draws a lot of power (at least 3W alone). - gamemode: lets you achieve lower
nice values and higher realtime privileges at game start. It can either detect
games or be told to start with
gamemode-run
. pw-jack
: can force games such asosu-lazer
to a lower quant value which provides lower latencies than using thepulse
backend.
Thank you