Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feral Gamemode #84682

Closed
TheEvilSkeleton opened this issue Apr 8, 2020 · 6 comments
Closed

Feral Gamemode #84682

TheEvilSkeleton opened this issue Apr 8, 2020 · 6 comments
Labels
0.kind: packaging request Request for a new package to be added

Comments

@TheEvilSkeleton
Copy link

Project description

GameMode is a daemon/lib combo for Linux that allows games to request a set of optimisations be temporarily applied to the host OS and/or a game process.

Metadata

@TheEvilSkeleton TheEvilSkeleton added the 0.kind: packaging request Request for a new package to be added label Apr 8, 2020
@FrauH0lle
Copy link
Contributor

I will just give a bit of input as I tried to package gamemode just recently.

inih was necessary as a new depenency

{ stdenv, lib, fetchFromGitHub
, meson
, ninja
, cmake
, pkg-config
}:

stdenv.mkDerivation rec {

  pname = "inih";
  version = "r48";

  src = fetchFromGitHub {
    owner = "benhoyt";
    repo = "inih";
    rev = "${version}";
    sha256 = "0517kxhvh6q39iyk1dj1dyp5anawdynlzv6zxx736x4mgf6i2f3k";
  };

  nativeBuildInputs = [ cmake meson ninja pkg-config ];

  configurePhase = "meson build --prefix=$out";
  buildPhase = "ninja -C build";
  installPhase = ''
    ninja -C build install
    '';

  meta = with lib; {
    description = "Simple .INI file parser in C, good for embedded systems.";
    platforms = platforms.linux;
  };
}

Then I followed the AUR packages and the nix wine packages:

packages.nix

{ stdenv_32bit, lib, pkgs, pkgsi686Linux, callPackage
}:

{
  gamemode32 = pkgsi686Linux.callPackage ./gamemode32.nix {
    pkgArches = [ pkgsi686Linux ];
    platforms = [ "i686-linux" "x86_64-linux" ];
  };
  gamemode = callPackage ./gamemode.nix {
    pkgArches = [ pkgs ];
    platforms = [ "x86_64-linux" ];
  };
}

64bit

{ stdenv, lib, fetchFromGitHub
, pkgArches
, platforms
, meson
, ninja
, cmake
, pkgconfig
, systemd
, polkit
, dbus
}:

let
  custompkgs = import <custompkgs> {};
in

stdenv.mkDerivation rec {

  pname = "gamemode";
  version = "1.5.1";

  src = fetchFromGitHub {
    owner = "FeralInteractive";
    repo = "gamemode";
    rev = "${version}";
    sha256 = "1gp480c8lqz2i576jibbg7gifibkli3rnhhp1k5yrqsbfbn4qxf7";
  };

  nativeBuildInputs = [ cmake meson ninja pkgconfig ];
  buildInputs = [ systemd dbus custompkgs.inih ];
  propagatedBuildInputs = [ polkit
                            systemd ];

  postPatch = ''
    substituteInPlace daemon/gamemode-tests.c --replace "/usr/bin/gamemoderun" $out/bin/gamemoderun
    '';

  configurePhase = "meson build --prefix=$out -Dwith-systemd-user-unit-dir=$out/lib/systemd/user --libexecdir $out/lib/gamemode";
  buildPhase = "ninja -C build";
  installPhase = ''
    ninja -C build install

    mkdir -p $out/share/doc/${pname}/example
    install -m644 -Dt $out/share/doc/${pname}/example example/gamemode.ini
    '';

  meta = with lib; {
    inherit platforms;
    description = "Optimise Linux system performance on demand.";
  };
}

32bit

{ stdenv, lib, fetchFromGitHub
, pkgArches
, platforms
, meson
, ninja
, cmake
, pkgconfig
, systemd
, polkit
, dbus
}:

let
  custompkgs = import <custompkgs> {};
in

stdenv.mkDerivation rec {

  pname = "gamemode32";
  version = "1.5.1";

  src = fetchFromGitHub {
    owner = "FeralInteractive";
    repo = "gamemode";
    rev = "${version}";
    sha256 = "1gp480c8lqz2i576jibbg7gifibkli3rnhhp1k5yrqsbfbn4qxf7";
  };

  nativeBuildInputs = [ cmake meson ninja pkgconfig ];
  buildInputs = [ systemd dbus custompkgs.inih ];
  propagatedBuildInputs = [ polkit
                            systemd ];

  configurePhase = "meson build --prefix=$out -Dwith-daemon=false -Dwith-examples=false -Dwith-systemd=false -Dwith-util=false --libdir lib32";
  buildPhase = "ninja -C build";
  installPhase = ''
    ninja -C build install
    '';

  meta = with lib; {
    inherit platforms;
    description = "Optimise Linux system performance on demand.";
  };
}

Then I added

systemd.packages = [ custompkgs.gamemode.gamemode ];

and, importantly, deactivated powerManagement.cpuFreqGovernor. Then I could run gamemoded -t and pass all tests. However, there are still some issues with the libraries.

gamemoderun lutris
...
ERROR: ld.so: object '/nix/store/mvcp6y1aq42c0lv51d2pczx3pmwfkcy5-gamemode-1.5.1/$LIB/libgamemodeauto.so.0' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS64): ignored.
...

@nrdxp
Copy link

nrdxp commented Jun 18, 2020

I am also trying to package this. I've noticed that the binary of gamemoded doesn't contain its own derivations lib directory in it's rpath which seems to be the main cause of the issue. Does anyone know how to resolve this? I can manually patch the source to load the library from a specific location, but this would disallow the loading of 32 bit libs dynamically.

I'm sure a package can't depend on itself but there must be some way to get the package to know about it's own lib directory. I'm a bit surprised that this is not default behavior.

@kloenk kloenk mentioned this issue Sep 21, 2020
10 tasks
@stale
Copy link

stale bot commented Dec 15, 2020

I marked this as stale due to inactivity. → More info

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Dec 15, 2020
@Atemu
Copy link
Member

Atemu commented Dec 16, 2020

Still important to me.

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Dec 16, 2020
@TredwellGit TredwellGit mentioned this issue Dec 16, 2020
3 tasks
@stale
Copy link

stale bot commented Jun 16, 2021

I marked this as stale due to inactivity. → More info

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jun 16, 2021
@bryanasdev000
Copy link
Member

bryanasdev000 commented Jun 16, 2021

Closed by #123433.

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jun 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: packaging request Request for a new package to be added
Projects
None yet
Development

No branches or pull requests

5 participants