|
2 | 2 |
|
3 | 3 | let |
4 | 4 | hibernateCfg = config.smind.power-management.hibernate; |
5 | | - fanControlCfg = config.smind.desktop.gnome.framework-fan-control; |
6 | | - batteryHealthCfg = config.smind.desktop.gnome.battery-health-charging; |
7 | 5 | kanataSwitcherCfg = config.smind.keyboard.super-remap.kanata-switcher; |
8 | 6 | extCfg = config.smind.desktop.gnome.extensions; |
9 | 7 |
|
|
18 | 16 | hibernateExtensionPatched = patchGnomeExtension pkgs.gnomeExtensions.hibernate-status-button; |
19 | 17 | roundedWindowCornersRebornPatched = patchGnomeExtension pkgs.gnomeExtensions.rounded-window-corners-reborn; |
20 | 18 |
|
21 | | - # Patch battery-health-charging to use NixOS paths instead of /usr/local/bin |
22 | | - batteryHealthChargingPatched = pkgs.gnomeExtensions.battery-health-charging.overrideAttrs (old: { |
23 | | - postPatch = (old.postPatch or "") + '' |
24 | | - # Replace hardcoded /usr/local/bin path with NixOS system path |
25 | | - substituteInPlace lib/driver.js \ |
26 | | - --replace-fail '/usr/local/bin/batteryhealthchargingctl-''${user}' \ |
27 | | - '/run/current-system/sw/bin/batteryhealthchargingctl' |
28 | | - ''; |
29 | | - }); |
30 | | - |
31 | 19 | ghosttyCfg = config.smind.desktop.gnome.ghostty-toggle; |
32 | 20 |
|
33 | 21 | extensions = with pkgs; [ |
|
57 | 45 | ++ lib.optional extCfg.no-overview.enable pkgs.gnomeExtensions.no-overview |
58 | 46 | ++ lib.optional hibernateCfg.enable hibernateExtensionPatched |
59 | 47 | ++ lib.optional config.smind.desktop.gnome.sticky-keys.enable gnomeExtensions.keyboard-modifiers-status |
60 | | - ++ lib.optional fanControlCfg.enable gnomeExtensions.framework-fan-control |
61 | | - ++ lib.optional batteryHealthCfg.enable batteryHealthChargingPatched |
62 | 48 | ++ lib.optional kanataSwitcherCfg.enable config.services.kanata-switcher.gnomeExtension.package; |
63 | 49 | in |
64 | 50 | { |
65 | 51 | options = { |
66 | | - smind.desktop.gnome.framework-fan-control.enable = lib.mkEnableOption "Framework fan control GNOME extension for Framework laptops"; |
67 | | - |
68 | | - smind.desktop.gnome.battery-health-charging.enable = lib.mkEnableOption "Battery Health Charging GNOME extension for laptops"; |
69 | | - |
70 | 52 | smind.desktop.gnome.allow-local-extensions = lib.mkEnableOption "local installation of GNOME Shell extensions (non-declaratively). When false, extension settings are locked via dconf"; |
71 | 53 |
|
72 | 54 | smind.desktop.gnome.extensions = { |
|
100 | 82 |
|
101 | 83 | config = lib.mkIf config.smind.desktop.gnome.enable { |
102 | 84 |
|
103 | | - environment.systemPackages = extensions |
104 | | - # Battery Health Charging extension control script (patched for NixOS) |
105 | | - # The original script's CHECKINSTALLATION tries to compare polkit rules files |
106 | | - # which don't exist on NixOS (we use security.polkit.extraConfig instead) |
107 | | - ++ lib.optional batteryHealthCfg.enable (pkgs.runCommand "batteryhealthchargingctl" { } '' |
108 | | - mkdir -p $out/bin |
109 | | - cp ${batteryHealthChargingPatched}/share/gnome-shell/extensions/Battery-Health-Charging@maniacx.github.com/resources/batteryhealthchargingctl $out/bin/batteryhealthchargingctl |
110 | | - chmod +x $out/bin/batteryhealthchargingctl |
111 | | - # Patch CHECKINSTALLATION case to always succeed on NixOS |
112 | | - # We configure polkit declaratively, so no need to check file-based rules |
113 | | - # Only replace the call site, not the function definition |
114 | | - sed -i '/^ CHECKINSTALLATION)$/,/^ ;;$/{ |
115 | | - s/check_installation/echo "NixOS: polkit configured declaratively"; exit 0/ |
116 | | - }' $out/bin/batteryhealthchargingctl |
117 | | - ''); |
| 85 | + environment.systemPackages = extensions; |
118 | 86 |
|
119 | 87 | # Polkit rules for GNOME extensions |
120 | | - security.polkit.extraConfig = lib.mkMerge [ |
121 | | - '' |
122 | | - // Allow any local session to claim sensors from iio-sensor-proxy (ALS) |
123 | | - polkit.addRule(function(action, subject) { |
124 | | - if (action.id == "net.hadess.SensorProxy.claim-sensor") { |
125 | | - return polkit.Result.YES; |
126 | | - } |
127 | | - }); |
128 | | - '' |
129 | | - (lib.mkIf batteryHealthCfg.enable '' |
130 | | - // Allow Battery Health Charging extension to set thresholds |
131 | | - // Note: Don't check subject.active - after suspend/resume it may not be set immediately |
132 | | - polkit.addRule(function(action, subject) { |
133 | | - if (action.id == "org.freedesktop.policykit.exec" && |
134 | | - action.lookup("program") == "/run/current-system/sw/bin/batteryhealthchargingctl" && |
135 | | - subject.local && subject.isInGroup("wheel")) |
136 | | - { |
137 | | - return polkit.Result.YES; |
138 | | - } |
139 | | - }); |
140 | | - '') |
141 | | - ]; |
142 | | - |
143 | | - # Enable fw-fanctrl service for Framework fan control extension |
144 | | - hardware.fw-fanctrl.enable = lib.mkIf fanControlCfg.enable true; |
145 | | - hardware.fw-fanctrl.disableBatteryTempCheck = lib.mkIf fanControlCfg.enable true; |
| 88 | + security.polkit.extraConfig = '' |
| 89 | + // Allow any local session to claim sensors from iio-sensor-proxy (ALS) |
| 90 | + polkit.addRule(function(action, subject) { |
| 91 | + if (action.id == "net.hadess.SensorProxy.claim-sensor") { |
| 92 | + return polkit.Result.YES; |
| 93 | + } |
| 94 | + }); |
| 95 | + ''; |
146 | 96 |
|
147 | 97 | programs.dconf = { |
148 | 98 | enable = true; |
|
161 | 111 | "org/gnome/shell/extensions/run-or-raise" = { |
162 | 112 | dbus = true; |
163 | 113 | }; |
164 | | - } ++ lib.optional batteryHealthCfg.enable { |
165 | | - # Tell Battery Health Charging extension that polkit is installed |
166 | | - "org/gnome/shell/extensions/Battery-Health-Charging" = { |
167 | | - polkit-status = "installed"; |
168 | | - }; |
169 | 114 | } ++ lib.optional (extCfg.dash-to-dock.enable && extCfg.dash-to-dock.unity-like-config.enable) { |
170 | 115 | "org/gnome/shell/extensions/dash-to-dock" = { |
171 | 116 | dock-position = "LEFT"; |
|
0 commit comments