fluffychat: 1.22.1 -> 1.23.0 (#364091)
[NixPkgs.git] / pkgs / by-name / sc / scaphandre / package.nix
blob31146c669722366efb39c0a90422c5e2ce532c27
2   lib,
3   rustPlatform,
4   fetchFromGitHub,
5   pkg-config,
6   openssl,
7   nix-update-script,
8   runCommand,
9   dieHook,
10   nixosTests,
11   testers,
12   scaphandre,
15 rustPlatform.buildRustPackage rec {
16   pname = "scaphandre";
17   version = "0.5.0";
19   src = fetchFromGitHub {
20     owner = "hubblo-org";
21     repo = pname;
22     rev = "v${version}";
23     hash = "sha256-cXwgPYTgom4KrL/PH53Fk6ChtALuMYyJ/oTrUKHCrzE=";
24   };
26   cargoHash = "sha256-Vdkq9ShbHWepvIgHPjhKY+LmhjS+Pl84QelgEpen7Qs=";
28   nativeBuildInputs = [ pkg-config ];
29   buildInputs = [ openssl ];
31   checkPhase = ''
32     runHook preCheck
34     # Work around to pass test due to non existing path
35     # https://github.com/hubblo-org/scaphandre/blob/v0.5.0/src/sensors/powercap_rapl.rs#L29
36     export SCAPHANDRE_POWERCAP_PATH="$(mktemp -d)/scaphandre"
38     mkdir -p "$SCAPHANDRE_POWERCAP_PATH"
40     runHook postCheck
41   '';
43   passthru = {
44     updateScript = nix-update-script { };
45     tests = {
46       stdout =
47         self:
48         runCommand "${pname}-test"
49           {
50             buildInputs = [
51               self
52               dieHook
53             ];
54           }
55           ''
56             ${self}/bin/scaphandre stdout -t 4 > $out  || die "Scaphandre failed to measure consumption"
57             [ -s $out ]
58           '';
59       vm = nixosTests.scaphandre;
60       version = testers.testVersion {
61         inherit version;
62         package = scaphandre;
63         command = "scaphandre --version";
64       };
65     };
66   };
68   meta = with lib; {
69     description = "Electrical power consumption metrology agent";
70     homepage = "https://github.com/hubblo-org/scaphandre";
71     license = licenses.asl20;
72     platforms = [ "x86_64-linux" ];
73     maintainers = with maintainers; [ gaelreyrol ];
74     mainProgram = "scaphandre";
75   };