11.stylix/stylix/testbed/default.nix
NAHO 1adb93fcbc
flake: add Flake Parts tree into testbed environment
Add the Flake Parts tree into the testbed environment, enabling
realistic testing interactions.

Flake Parts is chosen over Stylix to reduce cache invalidations, and
over other flake inputs as the smallest tree.
2025-07-24 16:58:27 +02:00

69 lines
1.9 KiB
Nix

{
pkgs,
inputs,
lib,
modules ? import ./autoload.nix { inherit pkgs lib; },
testbedFieldSeparator ? ":",
}:
let
makeTestbed =
name: testbed:
let
system = lib.nixosSystem {
inherit (pkgs) system;
modules =
[
(lib.modules.importApply ./modules/flake-parts.nix inputs)
./modules/common.nix
./modules/enable.nix
./modules/application.nix
inputs.self.nixosModules.stylix
inputs.home-manager.nixosModules.home-manager
testbed
]
++ map (name: import ./graphical-environments/${name}.nix) (
import ./available-graphical-environments.nix { inherit lib; }
)
++
lib.mapAttrsToList
(
target:
lib.optionalAttrs (
lib.hasPrefix "testbed${testbedFieldSeparator}${target}" name
)
)
{
inherit (inputs.nixvim.nixosModules) nixvim;
inherit (inputs.spicetify-nix.nixosModules) spicetify;
nvf = inputs.nvf.nixosModules.default;
zen-browser = {
home-manager.sharedModules = [
inputs.zen-browser.homeModules.default
];
};
};
};
in
pkgs.writeShellApplication {
inherit name;
text = ''
cleanup() {
if rm --recursive "$directory"; then
printf '%s\n' 'Virtualisation disk image removed.'
fi
}
# We create a temporary directory rather than a temporary file, since
# temporary files are created empty and are not valid disk images.
directory="$(mktemp --directory)"
trap cleanup EXIT
NIX_DISK_IMAGE="$directory/nixos.qcow2" \
${lib.getExe system.config.system.build.vm}
'';
};
in
builtins.mapAttrs makeTestbed modules