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.
This commit is contained in:
Martin Weinelt 2022-12-08 22:33:03 +01:00
parent a49feed255
commit fdcc9e8202
No known key found for this signature in database
GPG key ID: 87C1E9888F856759

View file

@ -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}
'';