summaryrefslogtreecommitdiffstats
path: root/nixos/tests/dconf.nix
blob: 195c56702e2b65f654018c543aa538dd8a47ce0d (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
37
38
39
40
41
42
{ lib, ... }:
{
  name = "dconf";

  meta.maintainers = with lib.maintainers; [
    linsui
  ];

  nodes.machine =
    {
      config,
      pkgs,
      lib,
      ...
    }:
    {
      users.extraUsers.alice = {
        isNormalUser = true;
      };
      programs.dconf = with lib.gvariant; {
        enable = true;
        profiles.user.databases = [
          {
            settings = {
              "test/not".locked = mkInt32 1;
              "test/is".locked = "locked";
            };
            locks = [
              "/test/is/locked"
            ];
          }
        ];
      };
    };

  testScript = ''
    machine.succeed("test $(dconf read -d /test/not/locked) == 1")
    machine.succeed("test $(dconf read -d /test/is/locked) == \"'locked'\"")
    machine.fail("sudo -u alice dbus-run-session -- dconf write /test/is/locked \"@s 'unlocked'\"")
    machine.succeed("sudo -u alice dbus-run-session -- dconf write /test/not/locked \"@i 2\"")
  '';
}