diff --git a/maintainers/maintainer-list.nix b/maintainers/maintainer-list.nix index b4a64c7ae54c..d70f29745d70 100644 --- a/maintainers/maintainer-list.nix +++ b/maintainers/maintainer-list.nix @@ -5691,6 +5691,16 @@ fingerprint = "0200 3EF8 8D2B CF2D 8F00 FFDC BBB3 E40E 5379 7FD9"; }]; }; + gaelreyrol = { + email = "me@gaelreyrol.dev"; + matrix = "@Zevran:matrix.org"; + name = "Gaƫl Reyrol"; + github = "gaelreyrol"; + githubId = 498465; + keys = [{ + fingerprint = "3492 D8FA ACFF 4C5F A56E 50B7 DFB9 B69A 2C42 7F61"; + }]; + }; GaetanLepage = { email = "gaetan@glepage.com"; github = "GaetanLepage"; diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index bfc6e11025d8..a7179a028e98 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -670,6 +670,7 @@ in { samba = handleTest ./samba.nix {}; samba-wsdd = handleTest ./samba-wsdd.nix {}; sanoid = handleTest ./sanoid.nix {}; + scaphandre = handleTest ./scaphandre.nix {}; schleuder = handleTest ./schleuder.nix {}; sddm = handleTest ./sddm.nix {}; seafile = handleTest ./seafile.nix {}; diff --git a/nixos/tests/scaphandre.nix b/nixos/tests/scaphandre.nix new file mode 100644 index 000000000000..f0a411748503 --- /dev/null +++ b/nixos/tests/scaphandre.nix @@ -0,0 +1,18 @@ +import ./make-test-python.nix { + name = "scaphandre"; + + nodes = { + scaphandre = { pkgs, ... } : { + boot.kernelModules = [ "intel_rapl_common" ]; + + environment.systemPackages = [ pkgs.scaphandre ]; + }; + }; + + testScript = { nodes, ... } : '' + scaphandre.start() + scaphandre.wait_until_succeeds( + "scaphandre stdout -t 4", + ) + ''; +} diff --git a/pkgs/servers/scaphandre/default.nix b/pkgs/servers/scaphandre/default.nix new file mode 100644 index 000000000000..cc01b684e9e1 --- /dev/null +++ b/pkgs/servers/scaphandre/default.nix @@ -0,0 +1,61 @@ +{ stdenv +, lib +, rustPlatform +, fetchFromGitHub +, pkg-config +, openssl +, powercap +, runCommand +, dieHook +, nixosTests +}: + +rustPlatform.buildRustPackage rec { + pname = "scaphandre"; + version = "0.5.0"; + + src = fetchFromGitHub { + owner = "hubblo-org"; + repo = pname; + rev = "v${version}"; + hash = "sha256-cXwgPYTgom4KrL/PH53Fk6ChtALuMYyJ/oTrUKHCrzE="; + }; + + cargoSha256 = "sha256-Vdkq9ShbHWepvIgHPjhKY+LmhjS+Pl84QelgEpen7Qs="; + + nativeBuildInputs = [ pkg-config ]; + buildInputs = [ openssl ]; + + checkPhase = '' + runHook preCheck + + # Work around to pass test due to non existing path + # https://github.com/hubblo-org/scaphandre/blob/v0.5.0/src/sensors/powercap_rapl.rs#L29 + export SCAPHANDRE_POWERCAP_PATH="$(mktemp -d)/scaphandre" + + mkdir -p "$SCAPHANDRE_POWERCAP_PATH" + + 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; + }; + + meta = with lib; { + description = "Electrical power consumption metrology agent"; + homepage = "https://github.com/hubblo-org/scaphandre"; + license = licenses.asl20; + platforms = platforms.linux; + maintainers = with maintainers; [ gaelreyrol ]; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 98efd8134c23..678d6a412b94 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -26551,6 +26551,8 @@ with pkgs; scalr-cli = callPackage ../tools/admin/scalr-cli { }; + scaphandre = callPackage ../servers/scaphandre { }; + shairplay = callPackage ../servers/shairplay { avahi = avahi-compat; }; shairport-sync = callPackage ../servers/shairport-sync { };