at 18.03-beta 1.5 kB view raw
1import ./make-test.nix ({ pkgs, lib, ... }: 2let inherit (import ./ssh-keys.nix pkgs) 3 snakeOilPrivateKey snakeOilPublicKey; 4 ssh-config = builtins.toFile "ssh.conf" '' 5 UserKnownHostsFile=/dev/null 6 StrictHostKeyChecking=no 7 ''; 8in 9 { name = "nix-ssh-serve"; 10 meta.maintainers = [ lib.maintainers.shlevy ]; 11 nodes = 12 { server.nix.sshServe = 13 { enable = true; 14 keys = [ snakeOilPublicKey ]; 15 protocol = "ssh-ng"; 16 }; 17 server.nix.package = pkgs.nixUnstable; 18 client.nix.package = pkgs.nixUnstable; 19 }; 20 testScript = '' 21 startAll; 22 23 $client->succeed("mkdir -m 700 /root/.ssh"); 24 $client->copyFileFromHost("${ssh-config}", "/root/.ssh/config"); 25 $client->succeed("cat ${snakeOilPrivateKey} > /root/.ssh/id_ecdsa"); 26 $client->succeed("chmod 600 /root/.ssh/id_ecdsa"); 27 28 $client->succeed("nix-store --add /etc/machine-id > mach-id-path"); 29 30 $server->waitForUnit("sshd"); 31 32 $client->fail("diff /root/other-store\$(cat mach-id-path) /etc/machine-id"); 33 # Currently due to shared store this is a noop :( 34 $client->succeed("nix copy --to ssh-ng://nix-ssh\@server \$(cat mach-id-path)"); 35 $client->succeed("nix-store --realise \$(cat mach-id-path) --store /root/other-store --substituters ssh-ng://nix-ssh\@server"); 36 $client->succeed("diff /root/other-store\$(cat mach-id-path) /etc/machine-id"); 37 ''; 38 } 39)