about summary refs log tree commit diff
path: root/nixos/tests/nix-serve-ssh.nix
diff options
context:
space:
mode:
authorArtturin <Artturin@artturin.com>2021-12-03 18:19:42 +0200
committerArtturin <Artturin@artturin.com>2021-12-03 18:40:03 +0200
commitd87d5731d5bcd495d7a4087949b0fbec4841b972 (patch)
treebd1675e5ef3b11d461a19edc44c0878ffd1fdf79 /nixos/tests/nix-serve-ssh.nix
parent2fb77151e8fb0c47509fc879e3df553fba7254b4 (diff)
nixos/tests: fix nix-serve path
nixos/tests: rename nix-ssh-serve to nix-serve-ssh

nixos/tests/nix-serve-ssh: add --experimental-features

nixos-serve: add nix-serve-ssh to passthru.tests
Diffstat (limited to 'nixos/tests/nix-serve-ssh.nix')
-rw-r--r--nixos/tests/nix-serve-ssh.nix45
1 files changed, 45 insertions, 0 deletions
diff --git a/nixos/tests/nix-serve-ssh.nix b/nixos/tests/nix-serve-ssh.nix
new file mode 100644
index 0000000000000..1eb8d5b395b1f
--- /dev/null
+++ b/nixos/tests/nix-serve-ssh.nix
@@ -0,0 +1,45 @@
+import ./make-test-python.nix ({ pkgs, lib, ... }:
+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";
+           };
+         server.nix.package = pkgs.nix;
+         client.nix.package = pkgs.nix;
+       };
+     testScript = ''
+       start_all()
+
+       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")
+
+       client.succeed("nix-store --add /etc/machine-id > mach-id-path")
+
+       server.wait_for_unit("sshd")
+
+       client.fail("diff /root/other-store$(cat mach-id-path) /etc/machine-id")
+       # Currently due to shared store this is a noop :(
+       client.succeed("nix copy --experimental-features 'nix-command' --to ssh-ng://nix-ssh@server $(cat mach-id-path)")
+       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")
+     '';
+   }
+)