2024-04-14 15:41:06 +02:00
|
|
|
{
|
2024-05-10 07:25:12 +02:00
|
|
|
mkNixBuildTest =
|
|
|
|
{ name, expressionFile, extraMachineConfig ? {}, testScriptPre ? "", testScriptPost ? "" }:
|
2024-04-14 15:41:06 +02:00
|
|
|
{ lib, pkgs, ... }:
|
|
|
|
{
|
|
|
|
inherit name;
|
|
|
|
|
|
|
|
nodes.machine = {
|
|
|
|
imports = [extraMachineConfig];
|
|
|
|
nix.nixPath = ["nixpkgs=${pkgs.path}"];
|
|
|
|
nix.settings.substituters = lib.mkForce [];
|
|
|
|
virtualisation.additionalPaths = [
|
|
|
|
expressionFile
|
|
|
|
(pkgs.callPackage expressionFile {}).inputDerivation
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
testScript = { nodes }: ''
|
|
|
|
start_all()
|
|
|
|
|
2024-05-10 07:25:12 +02:00
|
|
|
${testScriptPre}
|
|
|
|
|
2024-04-14 15:41:06 +02:00
|
|
|
machine.succeed('nix-build --expr "let pkgs = import <nixpkgs> {}; in pkgs.callPackage ${expressionFile} {}"')
|
2024-05-10 07:25:12 +02:00
|
|
|
|
|
|
|
${testScriptPost}
|
2024-04-14 15:41:06 +02:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
}
|