From 656cd70ea8ab36bf9ba25fd43cfabe1b14e131db Mon Sep 17 00:00:00 2001 From: WORLDofPEACE Date: Tue, 6 Oct 2020 01:58:51 -0400 Subject: [PATCH] nixos/gnome3: add realtime-scheduling option This adds an option services.gnome3.experimental-features.realtime-scheduling See this comment for the motivation [0]. Having gnome-shell launched with capability seemed harmless at first, but it caused these issues [1] [2] for people who aren't even using the feature. It makes more sense to make this optional. [0]: https://github.com/NixOS/nixpkgs/issues/90201#issuecomment-683304279 [1]: https://github.com/NixOS/nixpkgs/issues/90201 [2]: https://github.com/NixOS/nixpkgs/issues/86730 --- .../services/x11/desktop-managers/gnome3.nix | 73 ++++++++++++++----- 1 file changed, 53 insertions(+), 20 deletions(-) diff --git a/nixos/modules/services/x11/desktop-managers/gnome3.nix b/nixos/modules/services/x11/desktop-managers/gnome3.nix index ae1fde555a9c..95dc6353d000 100644 --- a/nixos/modules/services/x11/desktop-managers/gnome3.nix +++ b/nixos/modules/services/x11/desktop-managers/gnome3.nix @@ -68,6 +68,38 @@ in core-shell.enable = mkEnableOption "GNOME Shell services"; core-utilities.enable = mkEnableOption "GNOME core utilities"; games.enable = mkEnableOption "GNOME games"; + + experimental-features = { + realtime-scheduling = mkOption { + type = types.bool; + default = false; + description = '' + Makes mutter (which propagates to gnome-shell) request a low priority real-time + scheduling which is only available on the wayland session. + To enable this experimental feature it requires a restart of the compositor. + Note that enabling this option only enables the capability + for realtime-scheduling to be used. It doesn't automatically set the gsetting + so that mutter actually uses realtime-scheduling. This would require adding + rt-scheduler to /org/gnome/mutter/experimental-features + with dconf-editor. You cannot use extraGSettingsOverrides because that will only + change the default value of the setting. + + Please be aware of these known issues with the feature in nixos: + + + + NixOS/nixpkgs#90201 + + + + + NixOS/nixpkgs#86730 + + + + ''; + }; + }; }; services.xserver.desktopManager.gnome3 = { @@ -289,26 +321,6 @@ in source-sans-pro ]; - ## Enable soft realtime scheduling, only supported on wayland ## - - security.wrappers.".gnome-shell-wrapped" = { - source = "${pkgs.gnome3.gnome-shell}/bin/.gnome-shell-wrapped"; - capabilities = "cap_sys_nice=ep"; - }; - - systemd.user.services.gnome-shell-wayland = let - gnomeShellRT = with pkgs.gnome3; pkgs.runCommand "gnome-shell-rt" {} '' - mkdir -p $out/bin/ - cp ${gnome-shell}/bin/gnome-shell $out/bin - sed -i "s@${gnome-shell}/bin/@${config.security.wrapperDir}/@" $out/bin/gnome-shell - ''; - in { - # Note we need to clear ExecStart before overriding it - serviceConfig.ExecStart = ["" "${gnomeShellRT}/bin/gnome-shell"]; - # Do not use the default environment, it provides a broken PATH - environment = mkForce {}; - }; - # Adapt from https://gitlab.gnome.org/GNOME/gnome-build-meta/blob/gnome-3-36/elements/core/meta-gnome-core-shell.bst environment.systemPackages = with pkgs.gnome3; [ adwaita-icon-theme @@ -333,6 +345,27 @@ in ]; }) + # Enable soft realtime scheduling, only supported on wayland + (mkIf serviceCfg.experimental-features.realtime-scheduling { + security.wrappers.".gnome-shell-wrapped" = { + source = "${pkgs.gnome3.gnome-shell}/bin/.gnome-shell-wrapped"; + capabilities = "cap_sys_nice=ep"; + }; + + systemd.user.services.gnome-shell-wayland = let + gnomeShellRT = with pkgs.gnome3; pkgs.runCommand "gnome-shell-rt" {} '' + mkdir -p $out/bin/ + cp ${gnome-shell}/bin/gnome-shell $out/bin + sed -i "s@${gnome-shell}/bin/@${config.security.wrapperDir}/@" $out/bin/gnome-shell + ''; + in { + # Note we need to clear ExecStart before overriding it + serviceConfig.ExecStart = ["" "${gnomeShellRT}/bin/gnome-shell"]; + # Do not use the default environment, it provides a broken PATH + environment = mkForce {}; + }; + }) + # Adapt from https://gitlab.gnome.org/GNOME/gnome-build-meta/blob/gnome-3-36/elements/core/meta-gnome-core-utilities.bst (mkIf serviceCfg.core-utilities.enable { environment.systemPackages = (with pkgs.gnome3; removePackagesByName [