integration-tests/flakes: Switch to direct flake evaluation (experimental)
This commit is contained in:
parent
0a836dc251
commit
45ca75bcea
3 changed files with 39 additions and 9 deletions
|
@ -8,8 +8,18 @@
|
||||||
apply-local = import ./apply-local { inherit pkgs; };
|
apply-local = import ./apply-local { inherit pkgs; };
|
||||||
build-on-target = import ./build-on-target { inherit pkgs; };
|
build-on-target = import ./build-on-target { inherit pkgs; };
|
||||||
exec = import ./exec { inherit pkgs; };
|
exec = import ./exec { inherit pkgs; };
|
||||||
flakes = import ./flakes { inherit pkgs; };
|
|
||||||
flakes-streaming = import ./flakes { inherit pkgs; evaluator = "streaming"; };
|
# FIXME: The old evaluation method doesn't work purely with Nix 2.21+
|
||||||
|
flakes = import ./flakes {
|
||||||
|
inherit pkgs;
|
||||||
|
extraApplyFlags = "--experimental-flake-eval";
|
||||||
|
};
|
||||||
|
flakes-impure = import ./flakes {
|
||||||
|
inherit pkgs;
|
||||||
|
pure = false;
|
||||||
|
};
|
||||||
|
#flakes-streaming = import ./flakes { inherit pkgs; evaluator = "streaming"; };
|
||||||
|
|
||||||
parallel = import ./parallel { inherit pkgs; };
|
parallel = import ./parallel { inherit pkgs; };
|
||||||
|
|
||||||
allow-apply-all = import ./allow-apply-all { inherit pkgs; };
|
allow-apply-all = import ./allow-apply-all { inherit pkgs; };
|
||||||
|
|
|
@ -1,13 +1,29 @@
|
||||||
{ pkgs
|
{ pkgs
|
||||||
, evaluator ? "chunked"
|
, evaluator ? "chunked"
|
||||||
|
, extraApplyFlags ? ""
|
||||||
|
, pure ? true
|
||||||
}:
|
}:
|
||||||
|
|
||||||
let
|
let
|
||||||
|
inherit (pkgs) lib;
|
||||||
|
|
||||||
tools = pkgs.callPackage ../tools.nix {
|
tools = pkgs.callPackage ../tools.nix {
|
||||||
targets = [ "alpha" ];
|
targets = [ "alpha" ];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
applyFlags = "--evaluator ${evaluator} ${extraApplyFlags}"
|
||||||
|
+ lib.optionalString (!pure) "--impure";
|
||||||
|
|
||||||
|
# From integration-tests/nixpkgs.nix
|
||||||
|
colmenaFlakeInputs = pkgs._inputs;
|
||||||
in tools.runTest {
|
in tools.runTest {
|
||||||
name = "colmena-flakes-${evaluator}";
|
name = "colmena-flakes-${evaluator}"
|
||||||
|
+ lib.optionalString (!pure) "-impure";
|
||||||
|
|
||||||
|
nodes.deployer = {
|
||||||
|
virtualisation.additionalPaths =
|
||||||
|
lib.mapAttrsToList (k: v: v.outPath) colmenaFlakeInputs;
|
||||||
|
};
|
||||||
|
|
||||||
colmena.test = {
|
colmena.test = {
|
||||||
bundle = ./.;
|
bundle = ./.;
|
||||||
|
@ -16,12 +32,13 @@ in tools.runTest {
|
||||||
import re
|
import re
|
||||||
|
|
||||||
deployer.succeed("sed -i 's @nixpkgs@ path:${pkgs._inputs.nixpkgs.outPath}?narHash=${pkgs._inputs.nixpkgs.narHash} g' /tmp/bundle/flake.nix")
|
deployer.succeed("sed -i 's @nixpkgs@ path:${pkgs._inputs.nixpkgs.outPath}?narHash=${pkgs._inputs.nixpkgs.narHash} g' /tmp/bundle/flake.nix")
|
||||||
|
deployer.succeed("sed -i 's @colmena@ path:${tools.colmena.src} g' /tmp/bundle/flake.nix")
|
||||||
|
|
||||||
with subtest("Lock flake dependencies"):
|
with subtest("Lock flake dependencies"):
|
||||||
deployer.succeed("cd /tmp/bundle && nix --extra-experimental-features \"nix-command flakes\" flake lock")
|
deployer.succeed("cd /tmp/bundle && nix --extra-experimental-features \"nix-command flakes\" flake lock")
|
||||||
|
|
||||||
with subtest("Deploy with a plain flake without git"):
|
with subtest("Deploy with a plain flake without git"):
|
||||||
deployer.succeed("cd /tmp/bundle && ${tools.colmenaExec} apply --on @target --evaluator ${evaluator}")
|
deployer.succeed("cd /tmp/bundle && ${tools.colmenaExec} apply --on @target ${applyFlags}")
|
||||||
alpha.succeed("grep FIRST /etc/deployment")
|
alpha.succeed("grep FIRST /etc/deployment")
|
||||||
|
|
||||||
with subtest("Deploy with a git flake"):
|
with subtest("Deploy with a git flake"):
|
||||||
|
@ -29,21 +46,22 @@ in tools.runTest {
|
||||||
|
|
||||||
# don't put probe.nix in source control - should fail
|
# 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")
|
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}")
|
logs = deployer.fail("cd /tmp/bundle && run-copy-stderr ${tools.colmenaExec} apply --on @target ${applyFlags}")
|
||||||
assert re.search(r"probe.nix.*No such file or directory", logs)
|
assert re.search(r"probe.nix.*No such file or directory", logs)
|
||||||
|
|
||||||
# now it should succeed
|
# now it should succeed
|
||||||
deployer.succeed("cd /tmp/bundle && git add probe.nix")
|
deployer.succeed("cd /tmp/bundle && git add probe.nix")
|
||||||
deployer.succeed("cd /tmp/bundle && ${tools.colmenaExec} apply --on @target --evaluator ${evaluator}")
|
deployer.succeed("cd /tmp/bundle && ${tools.colmenaExec} apply --on @target ${applyFlags}")
|
||||||
alpha.succeed("grep SECOND /etc/deployment")
|
alpha.succeed("grep SECOND /etc/deployment")
|
||||||
|
|
||||||
|
'' + lib.optionalString pure ''
|
||||||
with subtest("Check that impure expressions are forbidden"):
|
with subtest("Check that impure expressions are forbidden"):
|
||||||
deployer.succeed("sed -i 's|SECOND|''${builtins.readFile /etc/hostname}|g' /tmp/bundle/probe.nix")
|
deployer.succeed("sed -i 's|SECOND|''${builtins.readFile /etc/hostname}|g' /tmp/bundle/probe.nix")
|
||||||
logs = deployer.fail("cd /tmp/bundle && run-copy-stderr ${tools.colmenaExec} apply --on @target --evaluator ${evaluator}")
|
logs = deployer.fail("cd /tmp/bundle && run-copy-stderr ${tools.colmenaExec} apply --on @target ${applyFlags}")
|
||||||
assert re.search(r"access to absolute path.*forbidden in pure eval mode", logs)
|
assert re.search(r"access to absolute path.*forbidden in pure eval mode", logs)
|
||||||
|
|
||||||
with subtest("Check that impure expressions can be allowed with --impure"):
|
with subtest("Check that impure expressions can be allowed with --impure"):
|
||||||
deployer.succeed("cd /tmp/bundle && ${tools.colmenaExec} apply --on @target --evaluator ${evaluator} --impure")
|
deployer.succeed("cd /tmp/bundle && ${tools.colmenaExec} apply --on @target ${applyFlags} --impure")
|
||||||
alpha.succeed("grep deployer /etc/deployment")
|
alpha.succeed("grep deployer /etc/deployment")
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
|
@ -3,13 +3,15 @@
|
||||||
|
|
||||||
inputs = {
|
inputs = {
|
||||||
nixpkgs.url = "@nixpkgs@";
|
nixpkgs.url = "@nixpkgs@";
|
||||||
|
colmena.url = "@colmena@";
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs = { self, nixpkgs }: let
|
outputs = { self, nixpkgs, colmena }: let
|
||||||
pkgs = import nixpkgs {
|
pkgs = import nixpkgs {
|
||||||
system = "x86_64-linux";
|
system = "x86_64-linux";
|
||||||
};
|
};
|
||||||
in {
|
in {
|
||||||
colmena = import ./hive.nix { inherit pkgs; };
|
colmena = import ./hive.nix { inherit pkgs; };
|
||||||
|
colmenaHive = colmena.lib.makeHive self.outputs.colmena;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue