Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at devShellTools-shell 117 lines 2.7 kB view raw
1{ 2 lib, 3 stdenv, 4 fetchFromGitHub, 5 libgamemode32, 6 makeWrapper, 7 meson, 8 ninja, 9 pkg-config, 10 dbus, 11 inih, 12 systemd, 13 appstream, 14 findutils, 15 gawk, 16 procps, 17 nix-update-script, 18}: 19 20stdenv.mkDerivation (finalAttrs: { 21 pname = "gamemode"; 22 version = "1.8.2"; 23 24 src = fetchFromGitHub { 25 owner = "FeralInteractive"; 26 repo = "gamemode"; 27 tag = finalAttrs.version; 28 hash = "sha256-V0rewbSVOGFqJqXyCz4jXpuDM0EfjdkpGPl+WdDwI5I="; 29 }; 30 31 outputs = [ 32 "out" 33 "dev" 34 "lib" 35 "man" 36 ]; 37 38 patches = [ 39 # Add @libraryPath@ template variable to fix loading the PRELOAD library 40 ./preload-nix-workaround.patch 41 ]; 42 43 postPatch = '' 44 substituteInPlace data/gamemoderun \ 45 --subst-var-by libraryPath ${ 46 lib.makeLibraryPath ( 47 [ 48 (placeholder "lib") 49 ] 50 ++ lib.optionals (stdenv.hostPlatform.system == "x86_64-linux") [ 51 # Support wrapping 32bit applications on a 64bit linux system 52 libgamemode32 53 ] 54 ) 55 } 56 ''; 57 58 nativeBuildInputs = [ 59 makeWrapper 60 meson 61 ninja 62 pkg-config 63 ]; 64 65 buildInputs = [ 66 dbus 67 inih 68 systemd 69 ]; 70 71 mesonFlags = [ 72 "-Dwith-pam-limits-dir=etc/security/limits.d" 73 "-Dwith-systemd-user-unit-dir=lib/systemd/user" 74 "-Dwith-systemd-group-dir=lib/sysusers.d" 75 76 # The meson builder installs internal executables to $lib/lib by 77 # default, but they should be installed to "$out". It's also more 78 # appropriate to install these executables under a libexec 79 # directory instead of lib. 80 "--libexecdir=libexec" 81 ]; 82 83 doCheck = true; 84 nativeCheckInputs = [ 85 appstream 86 ]; 87 88 postFixup = '' 89 # Add $lib/lib to gamemoded & gamemode-simulate-game's rpath since 90 # they use dlopen to load libgamemode. Can't use makeWrapper since 91 # it would break the security wrapper in the NixOS module. 92 for bin in "$out/bin/gamemoded" "$out/bin/gamemode-simulate-game"; do 93 patchelf --set-rpath "$lib/lib:$(patchelf --print-rpath "$bin")" "$bin" 94 done 95 96 wrapProgram "$out/bin/gamemodelist" \ 97 --prefix PATH : ${ 98 lib.makeBinPath [ 99 findutils 100 gawk 101 procps 102 ] 103 } 104 ''; 105 106 passthru.updateScript = nix-update-script { }; 107 108 meta = with lib; { 109 description = "Optimise Linux system performance on demand"; 110 homepage = "https://feralinteractive.github.io/gamemode"; 111 changelog = "https://github.com/FeralInteractive/gamemode/blob/${finalAttrs.version}/CHANGELOG.md"; 112 license = licenses.bsd3; 113 maintainers = with maintainers; [ kira-bruneau ]; 114 platforms = platforms.linux; 115 mainProgram = "gamemoderun"; # Requires NixOS module to run 116 }; 117})