mirror of
https://github.com/ryan4yin/nix-config.git
synced 2026-11-13 12:13:36 +01:00
refactor(power-monitoring): grant RAPL read access from a udev rule
The boot-time oneshot only fixed the zones present when it ran, and node_exporter had to Require it. A powercap add rule covers every zone whenever it appears; the collector reads at scrape time, so no ordering is needed. Assisted-by: Claude Code (claude-opus-5-5)
This commit is contained in:
1 parent
42341491f3
commit
f8ca25a03b
5 files changed
+10
-35
No files matched your search
@@ -41,7 +41,7 @@ in
|
||||
name:
|
||||
configs.${name}.config.modules.powerMonitoring.enable
|
||||
&& builtins.elem "rapl" configs.${name}.config.services.prometheus.exporters.node.enabledCollectors
|
||||
&& configs.${name}.config.systemd.services ? rapl-permissions
|
||||
&& lib.hasInfix "chgrp rapl" configs.${name}.config.services.udev.extraRules
|
||||
);
|
||||
serverRaplReaderOnly = lib.all (
|
||||
name:
|
||||
@@ -51,9 +51,9 @@ in
|
||||
desktopRaplDisabled =
|
||||
!configs.ai-niri.config.modules.powerMonitoring.enable
|
||||
&& !(builtins.elem "rapl" configs.ai-niri.config.services.prometheus.exporters.node.enabledCollectors)
|
||||
&& !(configs.ai-niri.config.systemd.services ? rapl-permissions);
|
||||
guestsHaveNoRapl = lib.all (name: !(configs.${name}.config.systemd.services ? rapl-permissions)) (
|
||||
lib.subtractLists physicalHosts (builtins.attrNames configs)
|
||||
);
|
||||
&& !(lib.hasInfix "chgrp rapl" configs.ai-niri.config.services.udev.extraRules);
|
||||
guestsHaveNoRapl = lib.all (
|
||||
name: !(lib.hasInfix "chgrp rapl" configs.${name}.config.services.udev.extraRules)
|
||||
) (lib.subtractLists physicalHosts (builtins.attrNames configs));
|
||||
desktopBatteryReporting = configs.ai-niri.config.services.upower.enable;
|
||||
}
|
||||
@@ -82,7 +82,7 @@ in
|
||||
) cfg.environment.systemPackages;
|
||||
gpuMetricsExported = builtins.elem "drm" cfg.services.prometheus.exporters.node.enabledCollectors;
|
||||
raplMetricsExported = builtins.elem "rapl" cfg.services.prometheus.exporters.node.enabledCollectors;
|
||||
raplPermissionsExposed = cfg.systemd.services ? rapl-permissions;
|
||||
raplPermissionsExposed = lib.hasInfix "chgrp rapl" cfg.services.udev.extraRules;
|
||||
# node_exporter rejects a repeated flag, and this list merges with the base
|
||||
# module's entries, so a duplicate restart-loops the unit.
|
||||
collectorFlagsUnique =
|
||||
|
||||
@@ -34,9 +34,6 @@ in
|
||||
};
|
||||
|
||||
privilegedOneshot = {
|
||||
rapl-permissions = privilegedOneshot // {
|
||||
CapabilityBoundingSet = [ "CAP_CHOWN" ];
|
||||
};
|
||||
hdd-no-spindown = privilegedOneshot // {
|
||||
CapabilityBoundingSet = [ "CAP_SYS_RAWIO" ];
|
||||
DeviceAllow = [ "block-sd rw" ];
|
||||
|
||||
@@ -38,7 +38,6 @@ units "youko" [
|
||||
// units "aquamarine" [ "whisper-asr" ]
|
||||
// {
|
||||
privilegedOneshot = {
|
||||
rapl-permissions = privilegedUnit "aquamarine" "rapl-permissions";
|
||||
hdd-no-spindown = privilegedUnit "youko" "hdd-no-spindown";
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user