nixpkgs/pkgs/tools/games/gamemode/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

105 lines
2.5 KiB
Nix
Raw Normal View History

2021-05-18 01:31:05 +01:00
{ lib
, stdenv
, fetchFromGitHub
, libgamemode32
, makeWrapper
2021-05-18 01:31:05 +01:00
, meson
, ninja
, pkg-config
, dbus
, inih
, systemd
, appstream
, findutils
, gawk
, procps
2023-08-31 19:25:02 +01:00
, nix-update-script
2021-05-18 01:31:05 +01:00
}:
2023-12-07 13:52:39 +00:00
stdenv.mkDerivation (finalAttrs: {
2021-05-18 01:31:05 +01:00
pname = "gamemode";
version = "1.8.1";
2021-05-18 01:31:05 +01:00
src = fetchFromGitHub {
owner = "FeralInteractive";
2023-12-07 13:54:12 +00:00
repo = "gamemode";
rev = "refs/tags/${finalAttrs.version}";
hash = "sha256-kusb58nGxYA3U9GbZdW3hLjA3NmHc+af0VT4iGRewBw=";
2021-05-18 01:31:05 +01:00
};
outputs = [ "out" "dev" "lib" "man" ];
2021-05-18 01:31:05 +01:00
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
2021-05-18 01:31:05 +01:00
meson
ninja
pkg-config
];
buildInputs = [
dbus
inih
systemd
];
mesonFlags = [
"-Dwith-pam-limits-dir=etc/security/limits.d"
2021-05-18 01:31:05 +01:00
"-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"
2021-05-18 01:31:05 +01:00
];
doCheck = true;
nativeCheckInputs = [
2021-05-18 01:31:05 +01:00
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.
2021-05-18 01:31:05 +01:00
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
]}
2021-05-18 01:31:05 +01:00
'';
2023-08-31 19:25:02 +01:00
passthru.updateScript = nix-update-script { };
2021-05-18 01:31:05 +01:00
meta = with lib; {
description = "Optimise Linux system performance on demand";
2023-12-08 16:03:20 +00:00
homepage = "https://github.com/FeralInteractive/gamemode";
changelog = "https://github.com/FeralInteractive/gamemode/blob/${finalAttrs.version}/CHANGELOG.md";
2021-05-18 01:31:05 +01:00
license = licenses.bsd3;
maintainers = with maintainers; [ kira-bruneau ];
platforms = platforms.linux;
2023-12-07 13:53:52 +00:00
mainProgram = "gamemoderun"; # Requires NixOS module to run
2021-05-18 01:31:05 +01:00
};
2023-12-07 13:52:39 +00:00
})