2021-06-06 07:54:09 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, fetchFromGitHub
|
|
|
|
, fetchpatch
|
|
|
|
, libgamemode32
|
|
|
|
, meson
|
|
|
|
, ninja
|
|
|
|
, pkg-config
|
|
|
|
, dbus
|
|
|
|
, inih
|
|
|
|
, systemd
|
|
|
|
, appstream
|
2022-08-12 12:06:08 +00:00
|
|
|
, makeWrapper
|
|
|
|
, findutils
|
|
|
|
, gawk
|
|
|
|
, procps
|
2021-06-06 07:54:09 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "gamemode";
|
2022-08-12 12:06:08 +00:00
|
|
|
version = "1.7";
|
2021-06-06 07:54:09 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "FeralInteractive";
|
|
|
|
repo = pname;
|
|
|
|
rev = version;
|
2022-08-12 12:06:08 +00:00
|
|
|
sha256 = "sha256-DIFcmWFkoZOklo1keYcCl6n2GJgzWKC8usHFcJmfarU=";
|
2021-06-06 07:54:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
outputs = [ "out" "dev" "lib" "man" "static" ];
|
|
|
|
|
|
|
|
patches = [
|
|
|
|
# Add @libraryPath@ template variable to fix loading the PRELOAD library
|
|
|
|
./preload-nix-workaround.patch
|
2022-08-12 12:06:08 +00:00
|
|
|
# Do not install systemd sysusers configuration
|
|
|
|
./no-install-systemd-sysusers.patch
|
2023-04-12 12:48:02 +00:00
|
|
|
|
|
|
|
# fix build with glibc >=2.36 (declaration of pidfd_open)
|
|
|
|
(fetchpatch {
|
|
|
|
url = "https://github.com/FeralInteractive/gamemode/commit/4934191b1928ef695c3e8af21e75781f8591745f.patch";
|
|
|
|
sha256 = "sha256-pWf2NGbd3gEJFwVP/EIJRbTD29V7keTQHy388enktsY=";
|
|
|
|
})
|
2021-06-06 07:54:09 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
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 = [
|
2022-08-12 12:06:08 +00:00
|
|
|
makeWrapper
|
2021-06-06 07:54:09 +00:00
|
|
|
meson
|
|
|
|
ninja
|
|
|
|
pkg-config
|
|
|
|
];
|
|
|
|
|
|
|
|
buildInputs = [
|
|
|
|
dbus
|
|
|
|
inih
|
|
|
|
systemd
|
|
|
|
];
|
|
|
|
|
|
|
|
mesonFlags = [
|
|
|
|
# libexec is just a way to package binaries without including them
|
|
|
|
# in PATH. It doesn't make sense to install them to $lib
|
|
|
|
# (the default behaviour in the meson hook).
|
|
|
|
"--libexecdir=${placeholder "out"}/libexec"
|
|
|
|
|
|
|
|
"-Dwith-systemd-user-unit-dir=lib/systemd/user"
|
|
|
|
];
|
|
|
|
|
|
|
|
doCheck = true;
|
2023-02-02 18:25:31 +00:00
|
|
|
nativeCheckInputs = [
|
2021-06-06 07:54:09 +00:00
|
|
|
appstream
|
|
|
|
];
|
|
|
|
|
|
|
|
# Move static libraries to $static so $lib only contains dynamic libraries.
|
|
|
|
postInstall = ''
|
|
|
|
moveToOutput lib/*.a "$static"
|
|
|
|
'';
|
|
|
|
|
|
|
|
postFixup = ''
|
2022-08-12 12:06:08 +00:00
|
|
|
# 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-06-06 07:54:09 +00:00
|
|
|
for bin in "$out/bin/gamemoded" "$out/bin/gamemode-simulate-game"; do
|
|
|
|
patchelf --set-rpath "$lib/lib:$(patchelf --print-rpath "$bin")" "$bin"
|
|
|
|
done
|
2022-08-12 12:06:08 +00:00
|
|
|
|
|
|
|
wrapProgram "$out/bin/gamemodelist" \
|
|
|
|
--prefix PATH : ${lib.makeBinPath [
|
|
|
|
findutils
|
|
|
|
gawk
|
|
|
|
procps
|
|
|
|
]}
|
2021-06-06 07:54:09 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
description = "Optimise Linux system performance on demand";
|
|
|
|
homepage = "https://github.com/FeralInteractive/GameMode";
|
|
|
|
license = licenses.bsd3;
|
|
|
|
maintainers = with maintainers; [ kira-bruneau ];
|
|
|
|
platforms = platforms.linux;
|
|
|
|
};
|
|
|
|
}
|