|
20 | 20 | done <$refs |
21 | 21 | ''; |
22 | 22 |
|
23 | | - mkTest = { name ? "", user ? "root", isLocal ? true, deployArgs }: let |
| 23 | + mkTest = { name ? "", user ? "root", flakes ? true, isLocal ? true, deployArgs }: let |
24 | 24 | nodes = { |
25 | 25 | server = { nodes, ... }: { |
26 | 26 | imports = [ |
27 | 27 | ./server.nix |
28 | | - (import ./common.nix { inherit inputs pkgs; }) |
| 28 | + (import ./common.nix { inherit inputs pkgs flakes; }) |
29 | 29 | ]; |
30 | 30 | virtualisation.additionalPaths = lib.optionals (!isLocal) [ |
31 | 31 | pkgs.hello |
|
35 | 35 | ]; |
36 | 36 | }; |
37 | 37 | client = { nodes, ... }: { |
38 | | - imports = [ (import ./common.nix { inherit inputs pkgs; }) ]; |
| 38 | + imports = [ (import ./common.nix { inherit inputs pkgs flakes; }) ]; |
39 | 39 | environment.systemPackages = [ pkgs.deploy-rs.deploy-rs ]; |
| 40 | + # nix evaluation takes a lot of memory, especially in non-flake usage |
| 41 | + virtualisation.memorySize = lib.mkForce 4096; |
40 | 42 | virtualisation.additionalPaths = lib.optionals isLocal [ |
41 | 43 | pkgs.hello |
42 | 44 | pkgs.figlet |
|
56 | 58 | systems.url = "${inputs.utils.inputs.systems}"; |
57 | 59 | flake-compat.url = "${inputs.flake-compat}"; |
58 | 60 | flake-compat.flake = false; |
| 61 | +
|
| 62 | + enable-flakes.url = "${builtins.toFile "use-flakes" (if flakes then "true" else "false")}"; |
| 63 | + enable-flakes.flake = false; |
59 | 64 | ''; |
60 | 65 |
|
61 | 66 | flake = builtins.toFile "flake.nix" |
62 | 67 | (lib.replaceStrings [ "##inputs##" ] [ flakeInputs ] (builtins.readFile ./deploy-flake.nix)); |
63 | 68 |
|
| 69 | + flakeCompat = builtins.toFile "default.nix" '' |
| 70 | + (import |
| 71 | + ( |
| 72 | + let |
| 73 | + lock = builtins.fromJSON (builtins.readFile ./flake.lock); |
| 74 | + in |
| 75 | + fetchTarball { |
| 76 | + url = "https://not-used-we-fetch-by-hash"; |
| 77 | + sha256 = lock.nodes.flake-compat.locked.narHash; |
| 78 | + } |
| 79 | + ) |
| 80 | + { src = ./.; } |
| 81 | + ).defaultNix |
| 82 | + ''; |
| 83 | + |
64 | 84 | in pkgs.nixosTest { |
65 | 85 | inherit nodes name; |
66 | 86 |
|
|
73 | 93 | # Prepare |
74 | 94 | client.succeed("mkdir tmp && cd tmp") |
75 | 95 | client.succeed("cp ${flake} ./flake.nix") |
| 96 | + client.succeed("cp ${flakeCompat} ./default.nix") |
76 | 97 | client.succeed("cp ${./server.nix} ./server.nix") |
77 | 98 | client.succeed("cp ${./common.nix} ./common.nix") |
78 | 99 | client.succeed("cp ${serverNetworkJSON} ./network.json") |
79 | | - client.succeed("nix flake lock") |
80 | | -
|
| 100 | + client.succeed("nix --extra-experimental-features flakes flake lock") |
81 | 101 |
|
82 | 102 | # Setup SSH key |
83 | 103 | client.succeed("mkdir -m 700 /root/.ssh") |
@@ -136,4 +156,10 @@ in { |
136 | 156 | user = "deploy"; |
137 | 157 | deployArgs = "-s .#profile --ssh-opts '-p 22 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null' -- --offline"; |
138 | 158 | }; |
| 159 | + # Deployment using a non-flake nix |
| 160 | + non-flake-build = mkTest { |
| 161 | + name = "local-build"; |
| 162 | + flakes = false; |
| 163 | + deployArgs = "-s .#server"; |
| 164 | + }; |
139 | 165 | } |
0 commit comments