From fdcc9e8202c95eed45cd673afa880171330bb1a9 Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Thu, 8 Dec 2022 22:33:03 +0100 Subject: [PATCH] nixos/prometheus.exporters.smartctl: Simplify DeviceAllow logic Setting up the DeviceAllow list with explicitly configured devices was a nice idea, but sometimes a configured device (`/dev/nvme0n1` an NVMe namespace) has a parent device (`/dev/nvme0`) that smartctl needs to access to query metrics. Falling back to the block and character definitions is probably a valid fallback. --- .../monitoring/prometheus/exporters/smartctl.nix | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/nixos/modules/services/monitoring/prometheus/exporters/smartctl.nix b/nixos/modules/services/monitoring/prometheus/exporters/smartctl.nix index 302b1d5202cd..0c5648c14149 100644 --- a/nixos/modules/services/monitoring/prometheus/exporters/smartctl.nix +++ b/nixos/modules/services/monitoring/prometheus/exporters/smartctl.nix @@ -46,15 +46,11 @@ in { "CAP_SYS_ADMIN" ]; DevicePolicy = "closed"; - DeviceAllow = lib.mkOverride 50 ( - if cfg.devices != [] then - cfg.devices - else [ - "block-blkext rw" - "block-sd rw" - "char-nvme rw" - ] - ); + DeviceAllow = lib.mkOverride 50 [ + "block-blkext rw" + "block-sd rw" + "char-nvme rw" + ]; ExecStart = '' ${pkgs.prometheus-smartctl-exporter}/bin/smartctl_exporter ${args} '';