flake: add machine tests

This commit is contained in:
raf 2024-05-06 16:13:38 +03:00
parent a777941eed
commit 3aa02e8524
No known key found for this signature in database
GPG key ID: 02D1DD3FA08B6B29
5 changed files with 97 additions and 0 deletions

View file

@ -14,6 +14,8 @@
imports = [
# add lib to module args
{_module.args = {inherit (nixpkgs) lib;};}
./flake/tests # machine tests for nvf
./flake/apps.nix
./flake/legacyPackages.nix
./flake/overlays.nix

View file

@ -0,0 +1,28 @@
{
inputs,
nixosTest,
homeManagerModules,
...
}:
nixosTest {
name = "home-manager-test";
nodes.machine = {
imports = [
inputs.home-manager.nixosModules.home-manager
../profiles/minimal.nix
];
home-manager = {
sharedModules = [
homeManagerModules.nvf
];
users.test = {
programs.nvf.enable = true;
};
};
};
testScript = "";
}

View file

@ -0,0 +1,19 @@
{
nixosTest,
nixosModules,
...
}:
nixosTest {
name = "home-manager-test";
nodes.machine = {
imports = [
nixosModules.nvf
../profiles/minimal.nix
];
programs.nvf.enable = true;
};
testScript = "";
}

31
flake/tests/default.nix Normal file
View file

@ -0,0 +1,31 @@
{
inputs,
config,
lib,
...
}: {
perSystem = {
pkgs,
self',
...
}: let
inherit (lib.filesystem) packagesFromDirectoryRecursive;
inherit (lib.customisation) callPackageWith;
inherit (lib.attrsets) recursiveUpdate;
defaultInherits = {
inherit (config.flake) homeManagerModules nixosModules;
inherit inputs;
};
callPackage = callPackageWith (recursiveUpdate pkgs defaultInherits);
in {
checks = packagesFromDirectoryRecursive {
inherit callPackage;
directory = ./checks;
};
# expose checks as packages to be built
packages.test = self'.checks.home-manager-test.driverInteractive;
};
}

View file

@ -0,0 +1,17 @@
{
# he's a thicc boi
virtualisation = {
cores = 2;
memorySize = 2048;
qemu.options = ["-vga none -enable-kvm -device virtio-gpu-pci,xres=720,yres=1440"];
};
users.users.test = {
isNormalUser = true;
password = "";
};
home-manager.sharedModules = [
{home.stateVersion = "24.05";}
];
}