From 4c0e06a9fda5384bf7f7c1c97bbd969c0fb5a750 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20Reyrol?= Date: Fri, 30 Jun 2023 15:09:56 +0200 Subject: [PATCH 1/2] scaphandre: add passthru updateScript & testVersion --- pkgs/servers/scaphandre/default.nix | 33 +++++++++++++++++++---------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/pkgs/servers/scaphandre/default.nix b/pkgs/servers/scaphandre/default.nix index 7abfea74578a..04a3c7fee169 100644 --- a/pkgs/servers/scaphandre/default.nix +++ b/pkgs/servers/scaphandre/default.nix @@ -5,9 +5,12 @@ , pkg-config , openssl , powercap +, nix-update-script , runCommand , dieHook , nixosTests +, testers +, scaphandre }: rustPlatform.buildRustPackage rec { @@ -38,17 +41,25 @@ rustPlatform.buildRustPackage rec { runHook postCheck ''; - passthru.tests = { - stdout = self: runCommand "${pname}-test" { - buildInputs = [ - self - dieHook - ]; - } '' - ${self}/bin/scaphandre stdout -t 4 > $out || die "Scaphandre failed to measure consumption" - [ -s $out ] - ''; - vm = nixosTests.scaphandre; + passthru = { + updateScript = nix-update-script { }; + tests = { + stdout = self: runCommand "${pname}-test" { + buildInputs = [ + self + dieHook + ]; + } '' + ${self}/bin/scaphandre stdout -t 4 > $out || die "Scaphandre failed to measure consumption" + [ -s $out ] + ''; + vm = nixosTests.scaphandre; + version = testers.testVersion { + inherit version; + package = scaphandre; + command = "scaphandre --version"; + }; + }; }; meta = with lib; { From f856229c9af1b59f4573c629578ba52694d02858 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20Reyrol?= Date: Fri, 30 Jun 2023 15:10:38 +0200 Subject: [PATCH 2/2] nixos/prometheus/exporters: adjust scaphandre assertions --- .../modules/services/monitoring/prometheus/exporters.nix | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/nixos/modules/services/monitoring/prometheus/exporters.nix b/nixos/modules/services/monitoring/prometheus/exporters.nix index 9e3109dc0cbd..397125b51230 100644 --- a/nixos/modules/services/monitoring/prometheus/exporters.nix +++ b/nixos/modules/services/monitoring/prometheus/exporters.nix @@ -304,19 +304,19 @@ in 'services.prometheus.exporters.sql.configFile' ''; } { - assertion = cfg.scaphandre.enable -> (pkgs.stdenv.hostPlatform.isx86_64 == true); + assertion = cfg.scaphandre.enable -> (pkgs.stdenv.targetPlatform.isx86_64 == true); message = '' - Only x86_64 host platform architecture is not supported. + Scaphandre only support x86_64 architectures. ''; } { assertion = cfg.scaphandre.enable -> ((lib.kernel.whenHelpers pkgs.linux.version).whenOlder "5.11" true).condition == false; message = '' - A kernel version newer than '5.11' is required. ${pkgs.linux.version} + Scaphandre requires a kernel version newer than '5.11', '${pkgs.linux.version}' given. ''; } { assertion = cfg.scaphandre.enable -> (builtins.elem "intel_rapl_common" config.boot.kernelModules); message = '' - Please enable 'intel_rapl_common' in 'boot.kernelModules'. + Scaphandre needs 'intel_rapl_common' kernel module to be enabled. Please add it in 'boot.kernelModules'. ''; } ] ++ (flip map (attrNames exporterOpts) (exporter: { assertion = cfg.${exporter}.firewallFilter != null -> cfg.${exporter}.openFirewall;