summaryrefslogtreecommitdiff
path: root/test.nix
blob: b708c5e8f8424a353d75fbe1c94c675da590d9c0 (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
{ nixpkgs ? import <nixpkgs> {} }:

let inherit (import <nixpkgs/nixos/tests/ssh-keys.nix> nixpkgs)
  snakeOilPrivateKey snakeOilPublicKey snakeOilEd25519PrivateKey snakeOilEd25519PublicKey;
in

nixpkgs.nixosTest {
  name = "git-annex-specialremote-ramarkable2";

  nodes.annex = {

    services.openssh = {
      enable = true;
      settings.PermitEmptyPasswords = true;
      settings.PermitRootLogin = "yes";
    };

    environment.systemPackages = with nixpkgs; [
      openssh
      (callPackage ./default.nix {})
      gitFull
      git-annex
    ];

    users.users.root = {
      openssh.authorizedKeys.keys = [ snakeOilEd25519PublicKey ];
    };

  };

  testScript = ''
    machine.start()

    machine.wait_for_open_port(22)

    machine.succeed("mkdir -p /root/.ssh")
    machine.succeed("echo ${snakeOilEd25519PublicKey} > /root/.ssh/id_ed25519.pub")
    machine.succeed("echo StrictHostKeyChecking no > /root/.ssh/config")
    machine.succeed("cp ${snakeOilEd25519PrivateKey} /root/.ssh/id_ed25519")
    machine.succeed("chmod 600 /root/.ssh/id_ed25519")

    machine.succeed("ssh localhost echo meow")

    machine.succeed("mkdir -p /root/.local/share/remarkable/xochitl")

    machine.succeed("mkdir -p repo && cd repo")
    machine.succeed("git init")
    machine.succeed("git annex init")
    machine.succeed("git annex initremote localhost type=external externaltype=remarkable2 ssh_destination=localhost encryption=none exporttree=yes")

    machine.succeed("git annex testremote -d --fast localhost")
  '';
}