summaryrefslogtreecommitdiffstats
path: root/nixos/tests/geoclue2.nix
blob: 0b836c5699c23035c616203f584e61c7fe4e59eb (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
36
{ config, lib, ... }:
{
  name = "geoclue2";
  meta = {
    maintainers = with lib.maintainers; [ rhendric ];
  };

  nodes.machine = {
    imports = [ common/user-account.nix ];

    location = {
      latitude = 12.345;
      longitude = -67.890;
    };

    services.geoclue2 = {
      enable = true;
      enableDemoAgent = true;
      enableStatic = true;
      staticAltitude = 123.45;
      staticAccuracy = 1000;
    };
  };

  testScript =
    let
      inherit (config.node) pkgs;
    in
    ''
      whereAmI = machine.succeed('machinectl shell alice@.host ${pkgs.geoclue2}/libexec/geoclue-2.0/demos/where-am-i -t 5')
      assert ("Latitude:    12.345000°" in whereAmI), f"Incorrect latitude in:\n{whereAmI}"
      assert ("Longitude:   -67.890000°" in whereAmI), f"Incorrect longitude in:\n{whereAmI}"
      assert ("Altitude:    123.450000 meters" in whereAmI), f"Incorrect altitude in:\n{whereAmI}"
      assert ("Accuracy:    1000 meters" in whereAmI), f"Incorrect accuracy in:\n{whereAmI}"
    '';
}