summaryrefslogtreecommitdiffstats
path: root/nixos/tests/hddtemp.nix
blob: dad1ca52262143fc4212a1c2b5071cb2451a8d9c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
{ pkgs, ... }: {
  name = "hddtemp";
  meta = {
    inherit (pkgs.hddtemp.meta) maintainers;
  };

  nodes.machine =
    { config, pkgs, ... }:
    {
      virtualisation.qemu.options = [
        "-drive file=${pkgs.emptyFile},format=raw,if=ide,media=disk,snapshot=on"
      ];

      environment.systemPackages = [ pkgs.netcat ];

      hardware.sensor.hddtemp = {
        enable = true;
        drives = [
          "/dev/sda"
        ];
        extraArgs = [ "--listen=127.0.0.1" ];
        dbEntries = [
          # custom SMART decoding rule for QEMU disk
          ''"QEMU HARDDISK"   190 C "QEMU hard disk"''
        ];
      };
    };

  testScript = ''
    machine.start()
    machine.wait_for_unit("hddtemp.service")
    output = machine.succeed("nc -w1 localhost 7634")
    assert output == "|/dev/sda|QEMU HARDDISK|31|C|", output
  '';
}