6 # TODO: uncomment stable
7 # - Blocked on https://github.com/NixOS/nixpkgs/issues/138584 which has a
8 # PR in staging: https://github.com/NixOS/nixpkgs/pull/139986
9 # - Alternatively, blocked on a NixOps 2 release
10 # https://github.com/NixOS/nixops/issues/1242
11 # stable = testsLegacyNetwork { nixopsPkg = pkgs.nixops; };
12 unstable = testsForPackage { nixopsPkg = pkgs.nixops_unstable_minimal; };
14 # inherit testsForPackage;
19 lib.recurseIntoAttrs {
20 legacyNetwork = testLegacyNetwork args;
21 passthru.override = args': testsForPackage (args // args');
26 pkgs.testers.nixosTest ({
27 name = "nixops-legacy-network";
38 imports = [ ../../modules/installer/cd-dvd/channel.nix ];
39 environment.systemPackages = [ nixopsPkg ];
40 nix.settings.substituters = lib.mkForce [ ];
41 users.users.person.isNormalUser = true;
42 virtualisation.writableStore = true;
43 virtualisation.additionalPaths = [
47 virtualisation.memorySize = 2048;
49 # TODO: make this efficient, https://github.com/NixOS/nixpkgs/issues/180529
50 system.includeBuildDependencies = true;
55 imports = [ ./legacy/base-configuration.nix ];
62 deployerSetup = pkgs.writeScript "deployerSetup" ''
63 #!${pkgs.runtimeShell}
65 cp --no-preserve=mode -r ${./legacy} unicorn
66 cp --no-preserve=mode ${../ssh-keys.nix} unicorn/ssh-keys.nix
68 cp ${snakeOilPrivateKey} ~/.ssh/id_ed25519
69 chmod 0400 ~/.ssh/id_ed25519
71 serverNetworkJSON = pkgs.writeText "server-network.json" (
72 builtins.toJSON nodes.server.system.build.networkConfig
79 cmd = shlex.quote(cmd)
80 return deployer.succeed(f"su person -l -c {cmd} &>/dev/console")
84 deployer_do("cat /etc/hosts")
86 deployer_do("${deployerSetup}")
87 deployer_do("cp ${serverNetworkJSON} unicorn/server-network.json")
89 # Establish that ssh works, regardless of nixops
90 # Easy way to accept the server host key too.
91 server.wait_for_open_port(22)
92 deployer.wait_for_unit("network.target")
94 # Put newlines on console, to flush the console reader's line buffer
95 # in case nixops' last output did not end in a newline, as is the case
96 # with a status line (if implemented?)
97 deployer.succeed("while sleep 60s; do echo [60s passed]; done >&2 &")
99 deployer_do("cd ~/unicorn; ssh -oStrictHostKeyChecking=accept-new root@server echo hi")
102 deployer_do("cd ~/unicorn; nixops create")
104 deployer_do("cd ~/unicorn; nixops deploy --confirm")
106 deployer_do("cd ~/unicorn; nixops ssh server 'hello | figlet'")
110 inherit (import ../ssh-keys.nix pkgs) snakeOilPrivateKey snakeOilPublicKey;