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; };
14 # inherit testsForPackage;
17 testsForPackage = lib.makeOverridable (args: lib.recurseIntoAttrs {
18 legacyNetwork = testLegacyNetwork args;
21 testLegacyNetwork = { nixopsPkg }: pkgs.nixosTest ({
22 name = "nixops-legacy-network";
24 deployer = { config, lib, nodes, pkgs, ... }: {
25 imports = [ ../../modules/installer/cd-dvd/channel.nix ];
26 environment.systemPackages = [ nixopsPkg ];
27 nix.settings.substituters = lib.mkForce [ ];
28 users.users.person.isNormalUser = true;
29 virtualisation.writableStore = true;
30 virtualisation.additionalPaths = [
34 # This includes build dependencies all the way down. Not efficient,
35 # but we do need build deps to an *arbitrary* depth, which is hard to
37 (allDrvOutputs nodes.server.config.system.build.toplevel)
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.config.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;
97 Return a store path with a closure containing everything including
98 derivations and all build dependency outputs, all the way down.
101 let name = "allDrvOutputs-${pkg.pname or pkg.name or "unknown"}";
103 pkgs.runCommand name { refs = pkgs.writeReferencesToFile pkg.drvPath; } ''