tests/vmTest: fix and deduplicate code #18
3 changed files with 89 additions and 75 deletions
|
@ -14,6 +14,7 @@
|
||||||
nixpkgsFor = forAllSystems (system: pkgs: import nixpkgs { inherit system; overlays = [ self.overlay ]; });
|
nixpkgsFor = forAllSystems (system: pkgs: import nixpkgs { inherit system; overlays = [ self.overlay ]; });
|
||||||
in rec
|
in rec
|
||||||
{
|
{
|
||||||
|
herculesCI.ciSystems = [ "x86_64-linux" ];
|
||||||
overlay = final: prev: {
|
overlay = final: prev: {
|
||||||
generateApps = flake:
|
generateApps = flake:
|
||||||
let
|
let
|
||||||
|
|
14
tests/vmTest/common.nix
Normal file
14
tests/vmTest/common.nix
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
# Configuration that will be added to both the nixinatee node and the nixinator
|
||||||
|
# node.
|
||||||
|
{ inputs }:
|
||||||
|
{
|
||||||
|
nix = {
|
||||||
|
extraOptions =
|
||||||
|
let empty_registry = builtins.toFile "empty-flake-registry.json" ''{"flakes":[],"version":2}''; in
|
||||||
|
''
|
||||||
|
experimental-features = nix-command flakes
|
||||||
|
flake-registry = ${empty_registry}
|
||||||
|
'';
|
||||||
|
registry.nixpkgs.flake = inputs.nixpkgs;
|
||||||
|
};
|
||||||
|
}
|
|
@ -22,6 +22,8 @@ let
|
||||||
((import (path + "/flake.nix")).outputs (inputs // {self = r;}));
|
((import (path + "/flake.nix")).outputs (inputs // {self = r;}));
|
||||||
in
|
in
|
||||||
r;
|
r;
|
||||||
|
mkNixinateTest = buildOn:
|
||||||
|
let
|
||||||
exampleFlake = pkgs.writeTextFile {
|
exampleFlake = pkgs.writeTextFile {
|
||||||
name = "nixinate-example-flake";
|
name = "nixinate-example-flake";
|
||||||
destination = "/flake.nix";
|
destination = "/flake.nix";
|
||||||
|
@ -38,7 +40,7 @@ let
|
||||||
_module.args.nixinate = {
|
_module.args.nixinate = {
|
||||||
host = "nixinatee";
|
host = "nixinatee";
|
||||||
sshUser = "nixinator";
|
sshUser = "nixinator";
|
||||||
buildOn = "local"; # valid args are "local" or "remote"
|
buildOn = "${buildOn}"; # valid args are "local" or "remote"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
@ -54,32 +56,29 @@ let
|
||||||
};
|
};
|
||||||
deployScript = inputs.self.nixinate.${pkgs.hostPlatform.system} (callLocklessFlake "${exampleFlake}" { nixpkgs = inputs.nixpkgs; });
|
deployScript = inputs.self.nixinate.${pkgs.hostPlatform.system} (callLocklessFlake "${exampleFlake}" { nixpkgs = inputs.nixpkgs; });
|
||||||
exampleSystem = (callLocklessFlake "${exampleFlake}" { nixpkgs = inputs.nixpkgs; }).nixosConfigurations.nixinatee.config.system.build.toplevel;
|
exampleSystem = (callLocklessFlake "${exampleFlake}" { nixpkgs = inputs.nixpkgs; }).nixosConfigurations.nixinatee.config.system.build.toplevel;
|
||||||
mkNixinateTest = buildOn: makeTest {
|
in
|
||||||
|
makeTest {
|
||||||
nodes = {
|
nodes = {
|
||||||
nixinatee = { ... }: {
|
nixinatee = { ... }: {
|
||||||
imports = [
|
imports = [
|
||||||
./nixinateeBase.nix
|
./nixinateeBase.nix
|
||||||
|
(import ./common.nix { inherit inputs; })
|
||||||
];
|
];
|
||||||
virtualisation = {
|
virtualisation = {
|
||||||
writableStore = true;
|
writableStore = true;
|
||||||
|
additionalPaths = [] ++ pkgs.lib.optional (buildOn == "remote") (allDrvOutputs exampleSystem);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
nixinator = { ... }: {
|
nixinator = { ... }: {
|
||||||
|
imports = [
|
||||||
|
(import ./common.nix { inherit inputs; })
|
||||||
|
];
|
||||||
virtualisation = {
|
virtualisation = {
|
||||||
additionalPaths = [
|
additionalPaths = [
|
||||||
(allDrvOutputs exampleSystem)
|
(allDrvOutputs exampleSystem)
|
||||||
]
|
]
|
||||||
++ pkgs.lib.optional (buildOn == "remote") exampleFlake;
|
++ pkgs.lib.optional (buildOn == "remote") exampleFlake;
|
||||||
};
|
};
|
||||||
nix = {
|
|
||||||
extraOptions =
|
|
||||||
let empty_registry = builtins.toFile "empty-flake-registry.json" ''{"flakes":[],"version":2}''; in
|
|
||||||
''
|
|
||||||
experimental-features = nix-command flakes
|
|
||||||
flake-registry = ${empty_registry}
|
|
||||||
'';
|
|
||||||
registry.nixpkgs.flake = inputs.nixpkgs;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
testScript =
|
testScript =
|
||||||
|
|
Loading…
Add table
Reference in a new issue