aboutsummaryrefslogtreecommitdiff
path: root/nix/tests/default.nix
diff options
context:
space:
mode:
authorstuebinm2024-05-15 23:04:09 +0200
committerstuebinm2024-06-12 13:38:22 +0200
commitd3b11225fcb129ccb5e07b716b7484a93e68771d (patch)
treece46f44631c22b844377a7ae7fa458b3ec5b866e /nix/tests/default.nix
parentd5f4b0fabb0374cc122b9880315a874fda09f08a (diff)
test for non-flake build regressions
this adds a nixos vm test doing a deploy on a nix which does not have flakes enabled, to guard against this breaking as it has done before [1]. The existing test infrastructure is changed slightly to make enabling flakes configurable inside the vm's config. [1] https://github.com/serokell/deploy-rs/pull/272
Diffstat (limited to 'nix/tests/default.nix')
-rw-r--r--nix/tests/default.nix36
1 files changed, 31 insertions, 5 deletions
diff --git a/nix/tests/default.nix b/nix/tests/default.nix
index 7fe8628..218bbd8 100644
--- a/nix/tests/default.nix
+++ b/nix/tests/default.nix
@@ -20,12 +20,12 @@ let
done <$refs
'';
- mkTest = { name ? "", user ? "root", isLocal ? true, deployArgs }: let
+ mkTest = { name ? "", user ? "root", flakes ? true, isLocal ? true, deployArgs }: let
nodes = {
server = { nodes, ... }: {
imports = [
./server.nix
- (import ./common.nix { inherit inputs pkgs; })
+ (import ./common.nix { inherit inputs pkgs flakes; })
];
virtualisation.additionalPaths = lib.optionals (!isLocal) [
pkgs.hello
@@ -35,8 +35,10 @@ let
];
};
client = { nodes, ... }: {
- imports = [ (import ./common.nix { inherit inputs pkgs; }) ];
+ imports = [ (import ./common.nix { inherit inputs pkgs flakes; }) ];
environment.systemPackages = [ pkgs.deploy-rs.deploy-rs ];
+ # nix evaluation takes a lot of memory, especially in non-flake usage
+ virtualisation.memorySize = lib.mkForce 4096;
virtualisation.additionalPaths = lib.optionals isLocal [
pkgs.hello
pkgs.figlet
@@ -56,11 +58,29 @@ let
systems.url = "${inputs.utils.inputs.systems}";
flake-compat.url = "${inputs.flake-compat}";
flake-compat.flake = false;
+
+ enable-flakes.url = "${builtins.toFile "use-flakes" (if flakes then "true" else "false")}";
+ enable-flakes.flake = false;
'';
flake = builtins.toFile "flake.nix"
(lib.replaceStrings [ "##inputs##" ] [ flakeInputs ] (builtins.readFile ./deploy-flake.nix));
+ flakeCompat = builtins.toFile "default.nix" ''
+ (import
+ (
+ let
+ lock = builtins.fromJSON (builtins.readFile ./flake.lock);
+ in
+ fetchTarball {
+ url = "https://not-used-we-fetch-by-hash";
+ sha256 = lock.nodes.flake-compat.locked.narHash;
+ }
+ )
+ { src = ./.; }
+ ).defaultNix
+ '';
+
in pkgs.nixosTest {
inherit nodes name;
@@ -73,11 +93,11 @@ let
# Prepare
client.succeed("mkdir tmp && cd tmp")
client.succeed("cp ${flake} ./flake.nix")
+ client.succeed("cp ${flakeCompat} ./default.nix")
client.succeed("cp ${./server.nix} ./server.nix")
client.succeed("cp ${./common.nix} ./common.nix")
client.succeed("cp ${serverNetworkJSON} ./network.json")
- client.succeed("nix flake lock")
-
+ client.succeed("nix --extra-experimental-features flakes flake lock")
# Setup SSH key
client.succeed("mkdir -m 700 /root/.ssh")
@@ -136,4 +156,10 @@ in {
user = "deploy";
deployArgs = "-s .#profile --ssh-opts '-p 22 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null' -- --offline";
};
+ # Deployment using a non-flake nix
+ non-flake-build = mkTest {
+ name = "local-build";
+ flakes = false;
+ deployArgs = "-s .#server";
+ };
}