fork
Configure Feed
Select the types of activity you want to include in your feed.
nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
fork
Configure Feed
Select the types of activity you want to include in your feed.
1{ lib
2, stdenv
3, fetchFromGitHub
4, fetchpatch
5, libgamemode32
6, meson
7, ninja
8, pkg-config
9, dbus
10, inih
11, systemd
12, appstream
13, makeWrapper
14, findutils
15, gawk
16, procps
17}:
18
19stdenv.mkDerivation rec {
20 pname = "gamemode";
21 version = "1.7";
22
23 src = fetchFromGitHub {
24 owner = "FeralInteractive";
25 repo = pname;
26 rev = version;
27 sha256 = "sha256-DIFcmWFkoZOklo1keYcCl6n2GJgzWKC8usHFcJmfarU=";
28 };
29
30 outputs = [ "out" "dev" "lib" "man" "static" ];
31
32 patches = [
33 # Add @libraryPath@ template variable to fix loading the PRELOAD library
34 ./preload-nix-workaround.patch
35 # Do not install systemd sysusers configuration
36 ./no-install-systemd-sysusers.patch
37
38 # fix build with glibc >=2.36 (declaration of pidfd_open)
39 (fetchpatch {
40 url = "https://github.com/FeralInteractive/gamemode/commit/4934191b1928ef695c3e8af21e75781f8591745f.patch";
41 sha256 = "sha256-pWf2NGbd3gEJFwVP/EIJRbTD29V7keTQHy388enktsY=";
42 })
43 ];
44
45 postPatch = ''
46 substituteInPlace data/gamemoderun \
47 --subst-var-by libraryPath ${lib.makeLibraryPath ([
48 (placeholder "lib")
49 ] ++ lib.optionals (stdenv.hostPlatform.system == "x86_64-linux") [
50 # Support wrapping 32bit applications on a 64bit linux system
51 libgamemode32
52 ])}
53 '';
54
55 nativeBuildInputs = [
56 makeWrapper
57 meson
58 ninja
59 pkg-config
60 ];
61
62 buildInputs = [
63 dbus
64 inih
65 systemd
66 ];
67
68 mesonFlags = [
69 # libexec is just a way to package binaries without including them
70 # in PATH. It doesn't make sense to install them to $lib
71 # (the default behaviour in the meson hook).
72 "--libexecdir=${placeholder "out"}/libexec"
73
74 "-Dwith-systemd-user-unit-dir=lib/systemd/user"
75 ];
76
77 doCheck = true;
78 nativeCheckInputs = [
79 appstream
80 ];
81
82 # Move static libraries to $static so $lib only contains dynamic libraries.
83 postInstall = ''
84 moveToOutput lib/*.a "$static"
85 '';
86
87 postFixup = ''
88 # Add $lib/lib to gamemoded & gamemode-simulate-game's rpath since
89 # they use dlopen to load libgamemode. Can't use makeWrapper since
90 # it would break the security wrapper in the NixOS module.
91 for bin in "$out/bin/gamemoded" "$out/bin/gamemode-simulate-game"; do
92 patchelf --set-rpath "$lib/lib:$(patchelf --print-rpath "$bin")" "$bin"
93 done
94
95 wrapProgram "$out/bin/gamemodelist" \
96 --prefix PATH : ${lib.makeBinPath [
97 findutils
98 gawk
99 procps
100 ]}
101 '';
102
103 meta = with lib; {
104 description = "Optimise Linux system performance on demand";
105 homepage = "https://github.com/FeralInteractive/GameMode";
106 license = licenses.bsd3;
107 maintainers = with maintainers; [ kira-bruneau ];
108 platforms = platforms.linux;
109 };
110}