about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGaël Reyrol <me@gaelreyrol.dev>2023-06-26 19:41:28 +0200
committerGitHub <noreply@github.com>2023-06-26 19:41:28 +0200
commitc7bb191426b5d3676e389954b38683ec8c0458d3 (patch)
treedee6c7dd3e34d8b7fba6d3f48f990b88c3de303a
parent3d50c1d076e0203b66b42503f9719bcd752e19c2 (diff)
downloadnixlib-c7bb191426b5d3676e389954b38683ec8c0458d3.tar
nixlib-c7bb191426b5d3676e389954b38683ec8c0458d3.tar.gz
nixlib-c7bb191426b5d3676e389954b38683ec8c0458d3.tar.bz2
nixlib-c7bb191426b5d3676e389954b38683ec8c0458d3.tar.lz
nixlib-c7bb191426b5d3676e389954b38683ec8c0458d3.tar.xz
nixlib-c7bb191426b5d3676e389954b38683ec8c0458d3.tar.zst
nixlib-c7bb191426b5d3676e389954b38683ec8c0458d3.zip
scaphandre: init at 0.5.0 (#238462)
* scaphandre: init at 0.5.0

* Update pkgs/servers/scaphandre/default.nix

---------

Co-authored-by: Pol Dellaiera <pol.dellaiera@protonmail.com>
-rw-r--r--maintainers/maintainer-list.nix10
-rw-r--r--nixos/tests/all-tests.nix1
-rw-r--r--nixos/tests/scaphandre.nix18
-rw-r--r--pkgs/servers/scaphandre/default.nix61
-rw-r--r--pkgs/top-level/all-packages.nix2
5 files changed, 92 insertions, 0 deletions
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 { };