From fe79e21268973b9dcebe428fe17482e20b5c6154 Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 14 Nov 2026 04:29:02 +0000 Subject: tests: pure evaluation pure-lib evaluates krops' lib from a flake whose inputs are krops' sources and nixpkgs' lib, checking that mkTarget leaves the user and the host null, and evaluating sources of each type. pure-deploy, which is exhaustive, deploys with writeDeploy from a flake whose inputs are krops' and nixpkgs' sources, evaluating nixpkgs, with a target string. The inputs are the sources in the store, without .git, copied there during the tests' evaluation, which the VM shares with the host. The flakes lock them as tarballs, by their hashes, so Nix uses the store paths, without fetching them, or reading them, which a path: input would, all of nixpkgs on every evaluation. The VM can't build what writeDeploy makes, which needs building populate, so pure-deploy runs what the host built of the same arguments, evaluated alike, failing if pure evaluation makes another derivation. nixpkgs is a flake with lib and legacyPackages, without nixpkgs' configuration and overlays, which pure evaluation can't read, and the host's evaluation could. pure-lib is in the smoke test. --- tests/scenarios.nix | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'tests/scenarios.nix') diff --git a/tests/scenarios.nix b/tests/scenarios.nix index 0e90284..0f7a0f8 100644 --- a/tests/scenarios.nix +++ b/tests/scenarios.nix @@ -130,4 +130,40 @@ in }]; })) (if targetKind == "sudo" then [ false ] else [ false true ])) targetKinds; + + # Pure evaluation, as flakes evaluate by default: of krops' lib, and of + # writeDeploy, deploying what that makes, with a target string, which + # makes the same derivation as evaluating on the host, which builds it. + # That evaluates nixpkgs, so it's exhaustive. + pure = [ + (scenario { + name = "pure-lib"; + targetKind = "local"; + phases = [{ + sources.x.file = "/fixtures/alt"; + deploy.pure = "lib"; + }]; + }) + (scenario { + name = "pure-deploy"; + targetKind = "remote"; + exhaustive = true; + prepare = '' + rm -f /tmp/nixos-rebuild.log /etc/nixos/flake.nix + ''; + phases = [{ + sources.x.file = "/fixtures/alt"; + deploy = { + pure = "deploy"; + target = "root@${remoteHost}/var/krops/pure-deploy"; + }; + check = '' + test -e "$T"/x/flake.nix || fail "x/flake.nix missing" + expect_eq NIX_PATH "$(sed -n 2p /tmp/nixos-rebuild.log)" "$T" + expect_eq arguments "$(sed -n 3p /tmp/nixos-rebuild.log)" switch + ''; + }]; + }) + ]; + } -- cgit v1.3.1