diff --git a/modules/list.nix b/modules/list.nix index ee8934a..f517734 100644 --- a/modules/list.nix +++ b/modules/list.nix @@ -1 +1,6 @@ -[ ./services/torrent/qbittorrent.nix ./security/mitigations.nix ] +[ + ./services/torrent/qbittorrent.nix + ./security/mitigations.nix + ./services/hardware/wii-u-gc-adapter.nix + ./services/games/gamemode.nix +] diff --git a/modules/services/games/gamemode.nix b/modules/services/games/gamemode.nix new file mode 100644 index 0000000..90d9bcf --- /dev/null +++ b/modules/services/games/gamemode.nix @@ -0,0 +1,36 @@ +{ config, lib, options, pkgs, ... }: + +with lib; + +let cfg = config.services.gamemode; +in { + options.services.gamemode = { + enable = mkOption { + type = types.bool; + default = false; + description = '' + Whether to enable the gamemoded systemd user service. + ''; + }; + }; + + config = mkIf cfg.enable { + environment.systemPackages = [ pkgs.gamemode ]; + + services.dbus.packages = [ pkgs.gamemode ]; + + systemd.user.services.gamemoded = { + description = "gamemoded"; + + serviceConfig = { + Type = "dbus"; + BusName = "com.feralinteractive.GameMode"; + NotifyAccess = "main"; + ExecStart = "${pkgs.gamemode}/bin/gamemoded"; + }; + + wantedBy = [ "graphical-session.target" ]; + partOf = [ "graphical-session.target" ]; + }; + }; +} diff --git a/pkgs/default.nix b/pkgs/default.nix index d4fe75e..4bc8911 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -5,4 +5,6 @@ final: prev: { purs = prev.callPackage ./shells/zsh/purs { }; pure = prev.callPackage ./shells/zsh/pure { }; wii-u-gc-adapter = prev.callPackage ./misc/drivers/wii-u-gc-adapter { }; + libinih = prev.callPackage ./development/libraries/libinih { }; + gamemode = prev.callPackage ./os-specific/linux/gamemode { }; } diff --git a/pkgs/development/libraries/libinih/default.nix b/pkgs/development/libraries/libinih/default.nix new file mode 100644 index 0000000..d9e31ac --- /dev/null +++ b/pkgs/development/libraries/libinih/default.nix @@ -0,0 +1,20 @@ +{ stdenv, meson, ninja, fetchFromGitHub, ... }: + +stdenv.mkDerivation rec { + name = "libinih"; + version = "r50"; + + src = fetchFromGitHub { + owner = "benhoyt"; + repo = "inih"; + rev = "${version}"; + hash = "sha256-GF+TVEysaXJxSBBjMsTr2IQvRKlzdEu3rlPQ88PE3nI="; + }; + + buildInputs = [ meson ninja ]; + + mesonFlags = '' + -Ddefault_library=shared + -Ddistro_install=true + ''; +} diff --git a/pkgs/os-specific/linux/gamemode/default.nix b/pkgs/os-specific/linux/gamemode/default.nix new file mode 100644 index 0000000..4375472 --- /dev/null +++ b/pkgs/os-specific/linux/gamemode/default.nix @@ -0,0 +1,32 @@ +{ stdenv, appstream, meson, ninja, pkgsi686Linux, polkit, pkgconfig, systemd +, dbus, libinih, fetchFromGitHub, ... }: + +stdenv.mkDerivation rec { + pname = "gamemode"; + version = "1.5.1"; + + src = fetchFromGitHub { + owner = "FeralInteractive"; + repo = "gamemode"; + rev = "${version}"; + hash = "sha256-x3VM7HJL4+zLDBdCm0ekc0UX33lrRWlOieJjihhA5L4="; + }; + + prePatch = '' + substituteInPlace daemon/gamemode-tests.c --replace "/usr/bin/gamemoderun" $out/bin/gamemoderun + substituteInPlace daemon/gamemode-gpu.c --replace "/usr/bin/pkexec" ${polkit}/bin/pkexec + substituteInPlace daemon/gamemode-context.c --replace "/usr/bin/pkexec" ${polkit}/bin/pkexec + substituteInPlace lib/gamemode_client.h --replace 'dlopen("' 'dlopen("${ + placeholder "out" + }/lib/' + ''; + + buildInputs = [ meson ninja pkgconfig systemd dbus libinih ]; + + mesonFlags = '' + -Dwith-util=false + -Dwith-examples=false + -Dwith-systemd-user-unit-dir=${placeholder "out"}/lib/systemd/user + ''; + +} diff --git a/profiles/games/default.nix b/profiles/games/default.nix index da7818e..faaa272 100644 --- a/profiles/games/default.nix +++ b/profiles/games/default.nix @@ -1,9 +1,5 @@ { unstablePkgs, ... }: { - imports = [ - ../graphical - ./udev.nix - ../../modules/services/hardware/wii-u-gc-adapter.nix - ]; + imports = [ ../graphical ./udev.nix ]; environment.systemPackages = with unstablePkgs; [ retroarchBare steam @@ -14,6 +10,8 @@ services.wii-u-gc-adapter.enable = true; + services.gamemode.enable = true; + # fps games on laptop need this services.xserver.libinput.disableWhileTyping = false;