Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Eval Tests

Eval tests (Tier C in the testing overview) assert configuration properties at Nix evaluation time. They run instantly and catch structural mistakes before anything is built.

For the full test tier map (eval / integration / VM / Rust) see the Testing Overview. This page documents only the eval checks.

How to run

nix flake check --no-build

The --no-build flag skips VM tests so only eval checks execute. Every check is a pkgs.runCommand that prints PASS: or FAIL: for each assertion and exits non-zero on the first failure.

Test fleet

Eval tests run against a minimal test fleet defined in modules/fleet.nix. These hosts exist solely to exercise framework config paths - they are not a real org.

The test fleet is defined in modules/fleet.nix. Key hosts used by eval checks:

HostKey configPurpose
web-01workstation role, impermanence enabledDefault web server, impermanent root
web-02workstation role, impermanence enabledSSH hardening tests
dev-01userName = "alice"Custom user override
edge-01endpoint roleMinimal edge device
srv-01server roleProduction server
agent-testagent enabled, tags, health checksAgent module options

Additional hosts (secrets-test, infra-test, cache-test, microvm-test, backup-restic-test) exercise other subsystems. All hosts share org-level defaults and use isVm = true.

Current checks

CheckHostWhat it asserts
eval-ssh-hardeningweb-02PermitRootLogin == "prohibit-password", PasswordAuthentication == false, firewall enabled
eval-hostspec-defaultsweb-01userName is non-empty, hostName matches "web-01"
eval-username-overrideweb-01, dev-01web-01 uses the shared default user; dev-01 overrides it to a different value
eval-locale-timezoneweb-01timeZone, defaultLocale, console.keyMap are all non-empty
eval-ssh-authorizedweb-01Primary user and root both have at least one SSH authorized key
eval-password-filesweb-01hostSpec exposes hashedPasswordFile and rootHashedPasswordFile options
eval-agent-tags-healthagent-testAgent systemd service has NIXFLEET_TAGS = "web,production", health-checks.json config file exists

Adding a new eval test

  1. Pick (or add) a test fleet host in modules/fleet.nix that exercises the config path you want to verify.

  2. Add a new check in modules/tests/eval.nix following this pattern:

eval-my-check = let
  cfg = nixosCfg "web-01";
in
  mkEvalCheck "my-check" [
    {
      check = cfg.some.option == expectedValue;
      msg = "web-01 some.option should be expectedValue";
    }
  ];
  1. Run nix flake check --no-build to verify the new assertion passes.

The mkEvalCheck helper (from modules/tests/_lib/helpers.nix) takes a check name and a list of { check : bool; msg : string; } assertions. It produces a runCommand derivation that prints each result and fails on the first false.