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;
17 testsForPackage = args: lib.recurseIntoAttrs {
18 legacyNetwork = testLegacyNetwork args;
19 passthru.override = args': testsForPackage (args // args');
22 testLegacyNetwork = { nixopsPkg, ... }: pkgs.testers.nixosTest ({
23 name = "nixops-legacy-network";
25 deployer = { config, lib, nodes, pkgs, ... }: {
26 imports = [ ../../modules/installer/cd-dvd/channel.nix ];
27 environment.systemPackages = [ nixopsPkg ];
28 nix.settings.substituters = lib.mkForce [ ];
29 users.users.person.isNormalUser = true;
30 virtualisation.writableStore = true;
31 virtualisation.additionalPaths = [
35 virtualisation.memorySize = 2048;
37 # TODO: make this efficient, https://github.com/NixOS/nixpkgs/issues/180529
38 system.includeBuildDependencies = true;
40 server = { lib, ... }: {
41 imports = [ ./legacy/base-configuration.nix ];
45 testScript = { nodes }:
47 deployerSetup = pkgs.writeScript "deployerSetup" ''
48 #!${pkgs.runtimeShell}
50 cp --no-preserve=mode -r ${./legacy} unicorn
51 cp --no-preserve=mode ${../ssh-keys.nix} unicorn/ssh-keys.nix
53 cp ${snakeOilPrivateKey} ~/.ssh/id_ed25519
54 chmod 0400 ~/.ssh/id_ed25519
56 serverNetworkJSON = pkgs.writeText "server-network.json"
57 (builtins.toJSON nodes.server.system.build.networkConfig);
63 cmd = shlex.quote(cmd)
64 return deployer.succeed(f"su person -l -c {cmd} &>/dev/console")
68 deployer_do("cat /etc/hosts")
70 deployer_do("${deployerSetup}")
71 deployer_do("cp ${serverNetworkJSON} unicorn/server-network.json")
73 # Establish that ssh works, regardless of nixops
74 # Easy way to accept the server host key too.
75 server.wait_for_open_port(22)
76 deployer.wait_for_unit("network.target")
78 # Put newlines on console, to flush the console reader's line buffer
79 # in case nixops' last output did not end in a newline, as is the case
80 # with a status line (if implemented?)
81 deployer.succeed("while sleep 60s; do echo [60s passed]; done >&2 &")
83 deployer_do("cd ~/unicorn; ssh -oStrictHostKeyChecking=accept-new root@server echo hi")
86 deployer_do("cd ~/unicorn; nixops create")
88 deployer_do("cd ~/unicorn; nixops deploy --confirm")
90 deployer_do("cd ~/unicorn; nixops ssh server 'hello | figlet'")
94 inherit (import ../ssh-keys.nix pkgs) snakeOilPrivateKey snakeOilPublicKey;