nixpkgs/pkgs/tools/games/gamemode/default.nix
Silvan Mosberger 4f0dadbf38 treewide: format all inactive Nix files
After final improvements to the official formatter implementation,
this commit now performs the first treewide reformat of Nix files using it.
This is part of the implementation of RFC 166.

Only "inactive" files are reformatted, meaning only files that
aren't being touched by any PR with activity in the past 2 months.
This is to avoid conflicts for PRs that might soon be merged.
Later we can do a full treewide reformat to get the rest,
which should not cause as many conflicts.

A CI check has already been running for some time to ensure that new and
already-formatted files are formatted, so the files being reformatted here
should also stay formatted.

This commit was automatically created and can be verified using

    nix-build a08b3a4d19.tar.gz \
      --argstr baseRev b32a094368
    result/bin/apply-formatting $NIXPKGS_PATH
2024-12-10 20:26:33 +01:00

118 lines
2.7 KiB
Nix

{
lib,
stdenv,
fetchFromGitHub,
libgamemode32,
makeWrapper,
meson,
ninja,
pkg-config,
dbus,
inih,
systemd,
appstream,
findutils,
gawk,
procps,
nix-update-script,
}:
stdenv.mkDerivation (finalAttrs: {
pname = "gamemode";
version = "1.8.2";
src = fetchFromGitHub {
owner = "FeralInteractive";
repo = "gamemode";
rev = "refs/tags/${finalAttrs.version}";
hash = "sha256-JkDFhFLUHlgD6RKxlxMjrSF2zQ4AWmRUQMLbWYwIZmg=";
};
outputs = [
"out"
"dev"
"lib"
"man"
];
patches = [
# Add @libraryPath@ template variable to fix loading the PRELOAD library
./preload-nix-workaround.patch
];
postPatch = ''
substituteInPlace data/gamemoderun \
--subst-var-by libraryPath ${
lib.makeLibraryPath (
[
(placeholder "lib")
]
++ lib.optionals (stdenv.hostPlatform.system == "x86_64-linux") [
# Support wrapping 32bit applications on a 64bit linux system
libgamemode32
]
)
}
'';
nativeBuildInputs = [
makeWrapper
meson
ninja
pkg-config
];
buildInputs = [
dbus
inih
systemd
];
mesonFlags = [
"-Dwith-pam-limits-dir=etc/security/limits.d"
"-Dwith-systemd-user-unit-dir=lib/systemd/user"
"-Dwith-systemd-group-dir=lib/sysusers.d"
# The meson builder installs internal executables to $lib/lib by
# default, but they should be installed to "$out". It's also more
# appropriate to install these executables under a libexec
# directory instead of lib.
"--libexecdir=libexec"
];
doCheck = true;
nativeCheckInputs = [
appstream
];
postFixup = ''
# Add $lib/lib to gamemoded & gamemode-simulate-game's rpath since
# they use dlopen to load libgamemode. Can't use makeWrapper since
# it would break the security wrapper in the NixOS module.
for bin in "$out/bin/gamemoded" "$out/bin/gamemode-simulate-game"; do
patchelf --set-rpath "$lib/lib:$(patchelf --print-rpath "$bin")" "$bin"
done
wrapProgram "$out/bin/gamemodelist" \
--prefix PATH : ${
lib.makeBinPath [
findutils
gawk
procps
]
}
'';
passthru.updateScript = nix-update-script { };
meta = with lib; {
description = "Optimise Linux system performance on demand";
homepage = "https://feralinteractive.github.io/gamemode";
changelog = "https://github.com/FeralInteractive/gamemode/blob/${finalAttrs.version}/CHANGELOG.md";
license = licenses.bsd3;
maintainers = with maintainers; [ kira-bruneau ];
platforms = platforms.linux;
mainProgram = "gamemoderun"; # Requires NixOS module to run
};
})