colmena/integration-tests/flakes/default.nix

41 lines
1.5 KiB
Nix
Raw Normal View History

{ pkgs ? import ../nixpkgs.nix
, evaluator ? "chunked"
}:
2021-12-05 10:14:12 +01:00
let
tools = pkgs.callPackage ../tools.nix {
2021-12-05 10:14:12 +01:00
targets = [ "alpha" ];
};
in tools.makeTest {
name = "colmena-flakes-${evaluator}";
2021-12-05 10:14:12 +01:00
bundle = ./.;
testScript = ''
import re
deployer.succeed("sed -i \"s @nixpkgs@ $(readlink /nixpkgs) g\" /tmp/bundle/flake.nix")
2021-12-05 10:14:12 +01:00
with subtest("Lock flake dependencies"):
# --impure required for path:/nixpkgs which is a symlink to a store path
deployer.succeed("cd /tmp/bundle && nix --experimental-features \"nix-command flakes\" flake lock --impure")
with subtest("Deploy with a plain flake without git"):
deployer.succeed("cd /tmp/bundle && ${tools.colmenaExec} apply --on @target --evaluator ${evaluator}")
2021-12-05 10:14:12 +01:00
alpha.succeed("grep FIRST /etc/deployment")
with subtest("Deploy with a git flake"):
deployer.succeed("sed -i s/FIRST/SECOND/g /tmp/bundle/probe.nix")
# don't put probe.nix in source control - should fail
deployer.succeed("cd /tmp/bundle && git init && git add flake.nix flake.lock hive.nix tools.nix")
logs = deployer.fail("cd /tmp/bundle && run-copy-stderr ${tools.colmenaExec} apply --on @target --evaluator ${evaluator}")
2021-12-05 10:14:12 +01:00
assert re.search(r"probe.nix.*No such file or directory", logs)
# now it should succeed
deployer.succeed("cd /tmp/bundle && git add probe.nix")
deployer.succeed("cd /tmp/bundle && ${tools.colmenaExec} apply --on @target --evaluator ${evaluator}")
2021-12-05 10:14:12 +01:00
alpha.succeed("grep SECOND /etc/deployment")
'';
}