2019-11-23 23:13:45 +00:00
|
|
|
import ./make-test-python.nix ({ pkgs, lib, ... }:
|
2018-02-28 21:55:00 +00:00
|
|
|
let inherit (import ./ssh-keys.nix pkgs)
|
|
|
|
snakeOilPrivateKey snakeOilPublicKey;
|
|
|
|
ssh-config = builtins.toFile "ssh.conf" ''
|
|
|
|
UserKnownHostsFile=/dev/null
|
|
|
|
StrictHostKeyChecking=no
|
|
|
|
'';
|
|
|
|
in
|
|
|
|
{ name = "nix-ssh-serve";
|
|
|
|
meta.maintainers = [ lib.maintainers.shlevy ];
|
|
|
|
nodes =
|
|
|
|
{ server.nix.sshServe =
|
|
|
|
{ enable = true;
|
|
|
|
keys = [ snakeOilPublicKey ];
|
|
|
|
protocol = "ssh-ng";
|
|
|
|
};
|
2018-10-01 21:01:38 +00:00
|
|
|
server.nix.package = pkgs.nix;
|
|
|
|
client.nix.package = pkgs.nix;
|
2018-02-28 21:55:00 +00:00
|
|
|
};
|
|
|
|
testScript = ''
|
2019-11-23 23:13:45 +00:00
|
|
|
start_all()
|
2018-02-28 21:55:00 +00:00
|
|
|
|
2019-11-23 23:13:45 +00:00
|
|
|
client.succeed("mkdir -m 700 /root/.ssh")
|
|
|
|
client.succeed(
|
|
|
|
"cat ${ssh-config} > /root/.ssh/config"
|
|
|
|
)
|
|
|
|
client.succeed(
|
|
|
|
"cat ${snakeOilPrivateKey} > /root/.ssh/id_ecdsa"
|
|
|
|
)
|
|
|
|
client.succeed("chmod 600 /root/.ssh/id_ecdsa")
|
2018-02-28 21:55:00 +00:00
|
|
|
|
2019-11-23 23:13:45 +00:00
|
|
|
client.succeed("nix-store --add /etc/machine-id > mach-id-path")
|
2018-02-28 21:55:00 +00:00
|
|
|
|
2019-11-23 23:13:45 +00:00
|
|
|
server.wait_for_unit("sshd")
|
2018-02-28 21:55:00 +00:00
|
|
|
|
2019-11-23 23:13:45 +00:00
|
|
|
client.fail("diff /root/other-store$(cat mach-id-path) /etc/machine-id")
|
2018-02-28 21:55:00 +00:00
|
|
|
# Currently due to shared store this is a noop :(
|
2021-12-03 16:19:42 +00:00
|
|
|
client.succeed("nix copy --experimental-features 'nix-command' --to ssh-ng://nix-ssh@server $(cat mach-id-path)")
|
2019-11-23 23:13:45 +00:00
|
|
|
client.succeed(
|
|
|
|
"nix-store --realise $(cat mach-id-path) --store /root/other-store --substituters ssh-ng://nix-ssh@server"
|
|
|
|
)
|
|
|
|
client.succeed("diff /root/other-store$(cat mach-id-path) /etc/machine-id")
|
2018-02-28 21:55:00 +00:00
|
|
|
'';
|
|
|
|
}
|
|
|
|
)
|