miku: Use upstream gamemode

This commit is contained in:
PapaTutuWawa 2021-10-22 21:40:21 +02:00
parent 466c8752b1
commit 80450caa7a
5 changed files with 44 additions and 105 deletions

View File

@ -9,7 +9,8 @@ in mkHost config {
overlays = [ "nur" "unstable" "simple" "custom" "emacs" ];
hardwareImports = [ "amdgpu" "amd" ];
programImports = [
"zsh" "git" "mpv" "tmux" "emacs" "firefox" "gnome-terminal" "gnome" "i18n" "gamemode"
"zsh" "git" "mpv" "tmux" "emacs" "firefox" "i18n" "gamemode" #"gnome-terminal" "gnome"
"alacritty" "sway" "waybar" "kanshi"
"distributed-build/builder.nix"
"music"
];
@ -32,10 +33,10 @@ in mkHost config {
emacsPgtkGcc
gajim
virt-manager unstable.qemu scream
gamemode # Custom package
#gamemode # Custom package
key-mapper # Custom package
replaysorcery # Custom package
evdev-proxy # Custom package
#evdev-proxy # Custom package
vfio-isolate # Custom Package
steam-wrapped
discord-wrapped # Custom package
@ -45,6 +46,7 @@ in mkHost config {
anime-dl trackma # Custom package
unstable.thunderbird
multimc-wrapped # Custom package
nwg-launchers
];
extraOptions = old: {
system.autoUpgrade.channel = "https://nixos.org/channels/nixos-unstable";
@ -52,6 +54,7 @@ in mkHost config {
programs = {
mpv.primaryScreen = "C27F398";
adb.enable = true;
sway.enable = true;
};
boot = {
@ -77,12 +80,21 @@ in mkHost config {
"kvm.report_ignored_msrs=N"
"fbcon=rotate:1"
"quiet"
"tsc=unstable"
];
extraModulePackages = [ pkgs.linuxPackages.vendor-reset ];
extraModulePackages = [ pkgs.linuxPackages_xanmod.vendor-reset ];
#extraModulePackages = [ pkgs.linuxPackages.vendor-reset ];
# NOTE: A regression appears to have happend between 5.10 and 5.12
# which leads to the RX590 to have the fence fallback timer on
# sdma0 time out (whatever this means). Maybe bisect?
#kernelPackages = pkgs.linuxPackages_zen;
kernelPackages = pkgs.linuxPackages_xanmod;
};
xdg.portal = {
enable = true;
extraPortals = [
pkgs.xdg-desktop-portal-wlr
];
};
services = {
ratbagd.enable = true;
@ -91,23 +103,15 @@ in mkHost config {
connman.extraConfig = ''
WriteResolvConf=false
'';
udev.packages = with pkgs; [ key-mapper ];
};
security = {
pam.loginLimits = [
{
domain = "@gamemode";
item = "-";
type = "nice";
value = "-10";
}
];
wrappers = {
gamemoded = {
source = "${pkgs.gamemode}/bin/gamemoded";
capabilities = "cap_sys_nice+ep";
};
udev = {
packages = with pkgs; [ key-mapper ];
extraRules = ''
KERNEL=="uinput", GROUP="input", MODE="0660"
'';
};
xserver.displayManager.gdm = {
enable = true;
wayland = true;
};
};
@ -152,22 +156,6 @@ in mkHost config {
Restart = "always";
};
};
# TODO: Remove once in stable or I decide to use unstable
gamemode = {
description = "A daemon/lib combo for Linux that allows games to request a set of optimisations be temporarily applied to the host OS.";
wantedBy = [ "default.target" ];
environment.PATH = lib.mkForce (pkgs.linkFarm "pkexec" [
{
name = "pkexec";
path = "${config.security.wrapperDir}/pkexec";
}
]);
serviceConfig = {
Type = "simple";
ExecStart = "${config.security.wrapperDir}/gamemoded";
Restart = "always";
};
};
superpaper = {
description = "A cross-platform multi monitor wallpaper manager.";
wantedBy = [ "default.target" ];

View File

@ -1,7 +1,21 @@
{ ... }:
{
home-manager.users.alexander.xdg.configFile = {
"gamemode/gamemode.ini".source = ./gamemode.ini;
config.programs.gamemode = {
enable = true;
enableRenice = true;
settings = {
general = {
reaper_freq = 5;
desiredgov = "performance";
igpu_desiredgov = "powersave";
igpu_power_threshold = 0.3;
softrealtime = "on";
renice = 0;
ioprio = 0;
inhibit_screensaver = 1;
};
};
};
}

View File

@ -7,13 +7,11 @@ let
discord-system-electron = pkgs.callPackage ./applications/networking/instant-messengers/discord {
# Wayland
# NOTE: electron under Wayland has no window titlebars
#extraStartupArgs = "--enable-features=UseOzonePlatform --ozone-platform=wayland";
#extraStartupArgs = "--enable-features=UseOzonePlatform --ozone-platform=wayland --enable-features=WebRTCPipeWireCapturer";
extraStartupArgs = "--enable-features=UseOzonePlatform --ozone-platform=wayland";
#extraStartupArgs = "--enable-features=UseOzonePlatform --ozone-platform=wayland --enable-features=WebRTCPipeWireCapturer";
};
wrapInSandbox = pkgs.callPackage ./sandbox.nix {};
in {
gamemode = pkgs.callPackage ./tools/games/gamemode { };
key-mapper = pkgs.callPackage ./tools/games/key-mapper {};
vfio-isolate = pkgs.callPackage ./tools/virtualisation/vfio-isolate {};
mopidy-funkwhale = pkgs.callPackage ./applications/audio/mopidy/funkwhale.nix {};
@ -40,6 +38,7 @@ in {
discord-wrapped = wrapInSandbox {
name = "discord";
package = pkgs.unstable.discord;
#package = discord-system-electron;
binaryName = "discord";
mountInHome = [ ".config/discord" ".config/BetterDiscord" ];
additionalBlacklist = [ "/mnt" ];

View File

@ -1,50 +0,0 @@
{ stdenv, lib,
meson, ninja, dbus, systemd, pkgconfig, cmake, inih,
fetchFromGitHub, fetchpatch }:
stdenv.mkDerivation rec {
pname = "gamemode";
version = "1.6.1";
src = fetchFromGitHub {
owner = "FeralInteractive";
repo = pname;
rev = version;
sha256 = "17dck7dzkmzq52f2yrs930fdg2inr7nipvnwpd0jqrwgk2fhwk9z";
};
patches = [
(fetchpatch {
url = "https://github.com/FeralInteractive/gamemode/commit/be44b7091baa33be6dda60392e4c06c2f398ee72.patch";
sha256 = "TlDUETs4+N3pvrVd0FQGlGmC+6ByhJ2E7gKXa7suBtE=";
})
./preload-nix-workaround.patch
];
nativeBuildInputs = [
meson ninja pkgconfig cmake
];
buildInputs = [
dbus systemd inih
];
mesonFlags = [
"-Dwith-systemd-user-unit-dir=${placeholder "out"}/lib/systemd/user"
];
postPatch = ''
substituteInPlace data/gamemoderun \
--subst-var-by libraryPath ${lib.makeLibraryPath ([
(placeholder "lib")
])}
'';
meta = with lib; {
description = "Optimise Linux system performance on demand";
homepage = "https://github.com/FeralInteractive/gamemode";
license = licenses.bsd3;
maintainers = [ ];
platforms = platforms.linux;
};
}

View File

@ -1,12 +0,0 @@
diff --git a/data/gamemoderun b/data/gamemoderun
index 573b3e4..6f2799e 100755
--- a/data/gamemoderun
+++ b/data/gamemoderun
@@ -5,5 +5,6 @@ GAMEMODEAUTO_NAME="libgamemodeauto.so.0"
# ld will find the right path to load the library, including for 32-bit apps.
LD_PRELOAD="${GAMEMODEAUTO_NAME}${LD_PRELOAD:+:$LD_PRELOAD}"
+LD_LIBRARY_PATH="@libraryPath@${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
-exec env LD_PRELOAD="${LD_PRELOAD}" $GAMEMODERUNEXEC "$@"
+exec env LD_PRELOAD="${LD_PRELOAD}" LD_LIBRARY_PATH="${LD_LIBRARY_PATH}" $GAMEMODERUNEXEC "$@"