From 9a38e9f614ede47b9a5c9548b9b98f576c6d5f62 Mon Sep 17 00:00:00 2001 From: moons Date: Sat, 29 Aug 2026 16:14:32 +0900 Subject: [PATCH] gpu settings --- flake.lock | 6 ++-- modules/applications/chrome/home/nixos.nix | 35 ++++++++++++++---- modules/applications/discord/home.nix | 17 ++++----- .../vesktop-webrtc-ip-handling-policy.patch | 36 ------------------- modules/hardwares/nvidia/nixos.nix | 5 +-- 5 files changed, 39 insertions(+), 60 deletions(-) delete mode 100644 modules/applications/discord/vesktop-webrtc-ip-handling-policy.patch diff --git a/flake.lock b/flake.lock index e60d78d..20e1a97 100644 --- a/flake.lock +++ b/flake.lock @@ -1093,11 +1093,11 @@ }, "nixpkgs-unstable": { "locked": { - "lastModified": 1787394516, - "narHash": "sha256-pRGOQSClnXNI2iLUG6DYpsGvYcuw0drOutVZFTJNw90=", + "lastModified": 1787814960, + "narHash": "sha256-PYZq1qzCJXC2zGI0mH07vrZBsw6DRBAOX0jN1pPtqOQ=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "c8f90650c15282fa8656a041bfbbd2403997a9a7", + "rev": "c27cdad491a991b11ed731760aa2ef8db0cb0410", "type": "github" }, "original": { diff --git a/modules/applications/chrome/home/nixos.nix b/modules/applications/chrome/home/nixos.nix index e2d33b5..d2c2fb7 100644 --- a/modules/applications/chrome/home/nixos.nix +++ b/modules/applications/chrome/home/nixos.nix @@ -1,19 +1,40 @@ -_: { +{ + config, + lib, + pkgs, + ... +}: +let + chrome = pkgs.google-chrome.overrideAttrs (old: { + nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ pkgs.makeWrapper ]; + + postFixup = (old.postFixup or "") + '' + wrapProgram $out/bin/google-chrome-stable \ + --set LIBVA_DRIVER_NAME nvidia \ + --set NVD_BACKEND direct + ''; + }); + + features = [ + "MiddleClickAutoscroll" + "AcceleratedVideoDecoder" + "AcceleratedVideoDecodeLinuxGL" + "PlatformHEVCDecoderSupport" + ] + ++ lib.optional config.my.hardwares.nvidia.enable "VaapiOnNvidiaGPUs"; +in +{ programs.google-chrome = { enable = true; + package = if config.my.hardwares.nvidia.enable then chrome else pkgs.google-chrome; commandLineArgs = [ - "--enable-features=MiddleClickAutoscroll,AcceleratedVideoDecoder,AcceleratedVideoDecodeLinuxGL,VaapiOnNvidiaGPUs,PlatformHEVCDecoderSupport" + "--enable-features=${lib.concatStringsSep "," features}" "--use-gl=angle" "--use-angle=gl" ]; }; - home.sessionVariables = { - LIBVA_DRIVER_NAME = "nvidia"; - NVD_BACKEND = "direct"; - }; - xdg.mimeApps = { enable = true; diff --git a/modules/applications/discord/home.nix b/modules/applications/discord/home.nix index 08a87e9..ff376d4 100644 --- a/modules/applications/discord/home.nix +++ b/modules/applications/discord/home.nix @@ -1,18 +1,15 @@ { - lib, + inputs, pkgs, ... -}: { +}: +let + unstable = inputs.nixpkgs-unstable.legacyPackages.${pkgs.stdenv.hostPlatform.system}; +in +{ programs.vesktop = { enable = true; - - package = - if pkgs.stdenv.hostPlatform.isLinux then - pkgs.vesktop.overrideAttrs (old: { - patches = (old.patches or [ ]) ++ [ ./vesktop-webrtc-ip-handling-policy.patch ]; - }) - else - pkgs.vesktop; + package = unstable.vesktop; settings = { discordBranch = "stable"; diff --git a/modules/applications/discord/vesktop-webrtc-ip-handling-policy.patch b/modules/applications/discord/vesktop-webrtc-ip-handling-policy.patch deleted file mode 100644 index f661836..0000000 --- a/modules/applications/discord/vesktop-webrtc-ip-handling-policy.patch +++ /dev/null @@ -1,36 +0,0 @@ -diff --git a/src/main/index.ts b/src/main/index.ts -index 2f4c399a4..0c81512a4 100644 ---- a/src/main/index.ts -+++ b/src/main/index.ts -@@ -158,3 +158,15 @@ app.on("open-url", (_, url) => { - app.on("window-all-closed", () => { - if (process.platform !== "darwin") app.quit(); - }); -+ -+// Sets the WebRTC IP handling policy for all current and future windows. -+// Switching to "default_public_and_private_interfaces" may fix calls stuck at "DTLS Connecting" when using VPNs, Tailscale, etc. -+// https://github.com/Vencord/Vesktop/issues/876 -+app.on("web-contents-created", (_event, contents) => { -+ contents.setWebRTCIPHandlingPolicy(Settings.store.webRTCIPHandlingPolicy ?? "default"); -+}); -+Settings.addChangeListener("webRTCIPHandlingPolicy", () => { -+ for (const win of BrowserWindow.getAllWindows()) { -+ win.webContents.setWebRTCIPHandlingPolicy(Settings.store.webRTCIPHandlingPolicy ?? "default"); -+ } -+}); -diff --git a/src/shared/settings.d.ts b/src/shared/settings.d.ts -index 5b8fd6fff..b127f6def 100644 ---- a/src/shared/settings.d.ts -+++ b/src/shared/settings.d.ts -@@ -9,6 +9,11 @@ import type { Rectangle } from "electron"; - export interface Settings { - discordBranch?: "stable" | "canary" | "ptb"; - transparencyOption?: "none" | "mica" | "tabbed" | "acrylic"; -+ webRTCIPHandlingPolicy?: -+ | "default" -+ | "default_public_interface_only" -+ | "default_public_and_private_interfaces" -+ | "disable_non_proxied_udp"; - tray?: boolean; - minimizeToTray?: boolean; - autoStartMinimized?: boolean; diff --git a/modules/hardwares/nvidia/nixos.nix b/modules/hardwares/nvidia/nixos.nix index b093068..f4b8283 100644 --- a/modules/hardwares/nvidia/nixos.nix +++ b/modules/hardwares/nvidia/nixos.nix @@ -5,10 +5,7 @@ modesetting.enable = true; open = true; - powerManagement = { - enable = true; - kernelSuspendNotifier = true; - }; + powerManagement.enable = true; moduleParams.nvidia.NVreg_TemporaryFilePath = "/var/tmp";