80 lines
2.2 KiB
Nix
80 lines
2.2 KiB
Nix
# refactor-smoke — headless VM boot test for autonomous refactor runs
|
|
#
|
|
# The "closed environment" for aggressive refactors is the *worktree* at
|
|
# ~/nixos-refactor/ plus the lack of sudo (so `omni-rebuild switch`
|
|
# can't activate on bohm). This test gives Claude an objective
|
|
# success/fail signal it can iterate against without a human in the loop.
|
|
#
|
|
# Run from a worktree of /etc/nixos:
|
|
# nix build .#checks.x86_64-linux.refactor-smoke -L
|
|
#
|
|
# Or as part of the full check suite:
|
|
# nix flake check --keep-going -L
|
|
#
|
|
# Extension points (the starter is intentionally minimal):
|
|
# - Add `imports` to `nodes.machine` as you bring more modules under
|
|
# test. Mind: graphical bits (Hyprland, greetd) are skipped — they
|
|
# need a real display and aren't easy to assert against in QEMU.
|
|
# - Add assertions to `testScript` as you pin more behavior. Useful
|
|
# idioms:
|
|
# machine.succeed("systemctl is-active <unit>.service")
|
|
# machine.succeed("test -f /etc/<path>")
|
|
# machine.succeed("grep -q '<line>' /etc/<file>")
|
|
{
|
|
nixpkgs,
|
|
system ? "x86_64-linux",
|
|
...
|
|
}:
|
|
|
|
let
|
|
pkgs = import nixpkgs {
|
|
inherit system;
|
|
config.allowUnfree = true;
|
|
};
|
|
in
|
|
pkgs.testers.runNixOSTest {
|
|
name = "omni-refactor-smoke";
|
|
|
|
nodes.machine =
|
|
{
|
|
config,
|
|
pkgs,
|
|
lib,
|
|
...
|
|
}:
|
|
{
|
|
# Match the real machine's primary user so home-managed paths
|
|
# resolve identically when the test grows to exercise them.
|
|
users.users.padreug = {
|
|
isNormalUser = true;
|
|
uid = 1000;
|
|
extraGroups = [ "wheel" ];
|
|
};
|
|
|
|
# Tools the refactor surface should always ship. Mirror this list
|
|
# to whatever your CLAUDE.md / dev-env claims is installed.
|
|
environment.systemPackages = with pkgs; [
|
|
git
|
|
pnpm
|
|
neovim
|
|
];
|
|
|
|
system.stateVersion = "24.11";
|
|
};
|
|
|
|
testScript = ''
|
|
machine.start()
|
|
machine.wait_for_unit("multi-user.target")
|
|
|
|
# Boot reached multi-user.
|
|
machine.succeed("uptime")
|
|
|
|
# Primary user exists with expected uid.
|
|
machine.succeed("test $(id -u padreug) -eq 1000")
|
|
|
|
# Key tools functional, not just present on PATH.
|
|
machine.succeed("git --version")
|
|
machine.succeed("pnpm --version")
|
|
machine.succeed("nvim --version | head -1")
|
|
'';
|
|
}
|