summaryrefslogtreecommitdiffstats
path: root/tests/programs-mas-no-cleanup.nix
blob: ebeeebd2a81d2957fb9245c4f816d6c786656c0a (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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
{
  config,
  pkgs,
  ...
}:

let
  mas =
    pkgs.runCommand "mas-0.0.0" { } ''
          mkdir -p $out/bin
          cat > $out/bin/mas <<'EOF'
      #!/usr/bin/env bash
      exit 0
      EOF
          chmod +x $out/bin/mas
    ''
    // {
      meta.mainProgram = "mas";
    };
in
{
  system.primaryUser = "primary-mas-user";

  programs.mas = {
    enable = true;
    user = "test-mas-user";
    package = mas;
    update = true;
    cleanup = false;
    packages = {
      Xcode = 497799835;
    };
  };

  homebrew.masApps = {
    "KeepFromHomebrew" = 424242;
  };

  test = ''
    echo "checking mas present in systemPackages" >&2
    test -x ${config.out}/sw/bin/mas

    echo "checking mas activation script still installs and updates apps" >&2
    grep 'desiredIds=(' ${config.out}/activate
    grep '497799835' ${config.out}/activate
    grep 'mas install \"$appId\"' ${config.out}/activate
    grep 'mas update' ${config.out}/activate

    echo "checking cleanup-only variables are omitted" >&2
    if grep 'declare -A installedApps' ${config.out}/activate; then
      echo "unexpected installedApps declaration when cleanup is disabled" >&2
      exit 1
    fi

    if grep 'keepIds=(' ${config.out}/activate; then
      echo "unexpected keepIds declaration when cleanup is disabled" >&2
      exit 1
    fi
  '';
}