From e8655a01cafb14f3e1bf3bd7013f4c44b5d6d4a0 Mon Sep 17 00:00:00 2001 From: Ihar Hrachyshka Date: Thu, 17 Sep 2026 20:48:29 -0400 Subject: [PATCH 1/4] openipmi: improve sim packaging This patch includes SDR files that are necessary to run the sim. It also fixes one ordering bug in the command file, as well as a bug in set_sensor_value command. These changes unlock the next patch in the series where we utilize the sim for prometheus ipmi exporter validation. --- pkgs/by-name/op/openipmi/package.nix | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/pkgs/by-name/op/openipmi/package.nix b/pkgs/by-name/op/openipmi/package.nix index 99bb16107d7e..d403edc65700 100644 --- a/pkgs/by-name/op/openipmi/package.nix +++ b/pkgs/by-name/op/openipmi/package.nix @@ -1,6 +1,7 @@ { stdenv, buildPackages, + fetchpatch, fetchurl, popt, ncurses, @@ -19,6 +20,20 @@ stdenv.mkDerivation (finalAttrs: { sha256 = "sha256-xi049dp99Cmaw6ZSUI6VlTd1JEAYHjTHayrs69fzAbk="; }; + patches = [ + # Fix broken command order in shipped ipmisim1: + (fetchpatch { + url = "https://github.com/cminyard/openipmi/commit/07adcedd824496d69be469101a7be1bbe371741a.patch"; + hash = "sha256-zAbnyliZr5HV9dYlyse4ff1lYJty+/74aqmXHWJM13c="; + }) + + # Sensors not marked ready after set_sensor_value. + (fetchpatch { + url = "https://github.com/cminyard/openipmi/commit/2325cc63727bab6a0f29fca2db4ba7d69c11e3b9.patch"; + hash = "sha256-ZbxV7ThFDbI5vxlLLavMrAZzCj3gPnR0sRcyHub5S30="; + }) + ]; + postConfigure = lib.optionalString (!stdenv.buildPlatform.canExecute stdenv.hostPlatform) '' substituteInPlace lanserv/Makefile \ --replace-fail "sdrcomp/sdrcomp_build -o" "${buildPackages.openipmi}/bin/sdrcomp -o" @@ -42,6 +57,13 @@ stdenv.mkDerivation (finalAttrs: { "BUILD_CC=${stdenv.cc.targetPrefix}cc" ]; + # Include SDR files; ipmi-sim requires .bsdr (installed as sdr.20.main) to + # advertise its sensor names. + postInstall = '' + install -Dm444 lanserv/ipmisim1.sdrs $out/share/openipmi/ipmisim1.sdrs + install -Dm444 lanserv/ipmisim1.bsdr $out/share/openipmi/ipmisim1.bsdr + ''; + outputs = [ "out" "lib" From 399c830cae63b58be890cf7f8d8a5552bb69c05a Mon Sep 17 00:00:00 2001 From: Ihar Hrachyshka Date: Thu, 17 Sep 2026 21:14:51 -0400 Subject: [PATCH 2/4] nixos/tests/prometheus-exporters: test IPMI sensors (lan) Previous version of the test wasn't utilizing IPMI datapath, merely checking that the exporter started. Here, we start ipmi_sim from `openipmi` and scrape its sensor value. Assisted-by: Codex, gpt-5.6-sol high --- nixos/tests/prometheus-exporters.nix | 59 +++++++++++++++++++++++++++- 1 file changed, 58 insertions(+), 1 deletion(-) diff --git a/nixos/tests/prometheus-exporters.nix b/nixos/tests/prometheus-exporters.nix index 3a87fe348c9d..9af1233a49f7 100644 --- a/nixos/tests/prometheus-exporters.nix +++ b/nixos/tests/prometheus-exporters.nix @@ -600,16 +600,73 @@ let ipmi = { pkgs, ... }: + let + exporterConfig = pkgs.writeText "ipmi-exporter.yml" '' + modules: + default: + user: ipmiusr + pass: test + privilege: admin + driver: LAN_2_0 + timeout: 2000 + # necessary for openipmi bmc, per ipmi-sensors(8) + workaround_flags: + - opensesspriv + collectors: + - ipmi + ''; + simulatorConfig = pkgs.writeText "ipmi-simulator.conf" '' + name "ipmisim1" + + startlan 1 + addr 192.168.1.1 623 + priv_limit admin + guid a123456789abcdefa123456789abcdef + endlan + + user 2 true "ipmiusr" "test" admin 10 + ''; + simulatorCommands = "${pkgs.openipmi}/etc/ipmi/ipmisim1.emu"; + in { maintainers = pkgs.freeipmi.meta.maintainers; exporterConfig = { enable = true; + configFile = exporterConfig; + }; + metricProvider = { + networking.firewall.allowedUDPPorts = [ 623 ]; + systemd.services.ipmi-simulator = { + wantedBy = [ "multi-user.target" ]; + after = [ "network.target" ]; + preStart = '' + # ipmi_sim expects specific name for its SDR. + ${pkgs.coreutils}/bin/install -Dm600 \ + ${pkgs.openipmi}/share/openipmi/ipmisim1.bsdr \ + /run/ipmi-simulator/ipmi_sim/ipmisim1/sdr.20.main + ''; + serviceConfig = { + ExecStart = '' + ${pkgs.openipmi}/bin/ipmi_sim -n \ + -c ${simulatorConfig} \ + -f ${simulatorCommands} \ + -s /run/ipmi-simulator + ''; + RuntimeDirectory = "ipmi-simulator"; + }; + }; }; exporterTest = '' + wait_for_unit("ipmi-simulator.service") + wait_until_succeeds("ss -lunp | grep -F '192.168.1.1:623'") wait_for_unit("prometheus-ipmi-exporter.service") wait_for_open_port(9290) + + # ipmi_sim command file sets MBTemp = 0x60 (96). succeed( - "curl -sSf http://localhost:9290/metrics | grep 'ipmi_scrape_duration_seconds'" + "curl -sSf 'http://localhost:9290/ipmi?target=192.168.1.1' > /tmp/ipmi-metrics", + "grep -F 'ipmi_up{collector=\"ipmi\"} 1' /tmp/ipmi-metrics", + "grep -F 'ipmi_temperature_celsius{id=\"3\",name=\"MBTemp\"} 96' /tmp/ipmi-metrics", ) ''; }; From 709c64ef61977568e40819af48443b80c01b23f8 Mon Sep 17 00:00:00 2001 From: Ihar Hrachyshka Date: Thu, 17 Sep 2026 23:33:27 -0400 Subject: [PATCH 3/4] freeipmi: add ipmi exporter nixos test to passthru.tests --- pkgs/by-name/fr/freeipmi/package.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkgs/by-name/fr/freeipmi/package.nix b/pkgs/by-name/fr/freeipmi/package.nix index 6c78125668c9..423225cfc444 100644 --- a/pkgs/by-name/fr/freeipmi/package.nix +++ b/pkgs/by-name/fr/freeipmi/package.nix @@ -7,6 +7,7 @@ libgcrypt, readline, libgpg-error, + nixosTests, }: stdenv.mkDerivation (finalAttrs: { @@ -44,6 +45,8 @@ stdenv.mkDerivation (finalAttrs: { doCheck = true; + passthru.tests = { inherit (nixosTests.prometheus-exporters) ipmi; }; + meta = { description = "Implementation of the Intelligent Platform Management Interface"; From 0cec004e133d7fe641d21e3c8361fa140c6b0749 Mon Sep 17 00:00:00 2001 From: Ihar Hrachyshka Date: Fri, 18 Sep 2026 21:35:32 -0400 Subject: [PATCH 4/4] openipmi: add ipmi exporter nixos test to passthru.tests ipmi_sim is now used in prometheus exporter test as metrics provider. --- pkgs/by-name/op/openipmi/package.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkgs/by-name/op/openipmi/package.nix b/pkgs/by-name/op/openipmi/package.nix index d403edc65700..cc3ff64a0062 100644 --- a/pkgs/by-name/op/openipmi/package.nix +++ b/pkgs/by-name/op/openipmi/package.nix @@ -8,6 +8,7 @@ python3, readline, lib, + nixosTests, openssl, }: @@ -71,6 +72,8 @@ stdenv.mkDerivation (finalAttrs: { "man" ]; + passthru.tests = { inherit (nixosTests.prometheus-exporters) ipmi; }; + meta = { homepage = "https://openipmi.sourceforge.io/"; description = "User-level library that provides a higher-level abstraction of IPMI and generic services";