diff options
| author | tv <tv@krebsco.de> | 2026-11-14 04:29:02 +0000 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-11-14 06:26:16 +0100 |
| commit | 87e5304d39ddf3a0c052cc13fcfdc2b36c3dad68 (patch) | |
| tree | 5b7ccfcc44527024a2c9a091eb8d84fdc7e5f786 /tests/default.nix | |
| parent | 41833dc11d75718c279e682593580a46dcec0c73 (diff) | |
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.
Diffstat (limited to 'tests/default.nix')
| -rw-r--r-- | tests/default.nix | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/tests/default.nix b/tests/default.nix index 08f95a6..6c3bc59 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -1,10 +1,10 @@ # NixOS VM tests for krops, with the VM machinery and the scenarios of # populate's tests, in ../pkgs/populate/tests: deploy, for writeDeploy's -# arguments to nixos-rebuild, and populate, for pkgs.populate, running +# arguments to nixos-rebuild, populate, for pkgs.populate, running # populate's scenarios that expect populate to refuse its arguments, which # pkgs.populate does during evaluation here, and the scenarios of # populate's smoke test, with target attribute sets as mkTarget returns -# them. Build all with nix-build tests, or one with, e.g., nix-build tests +# them, and pure, for pure evaluation, see ./pure.nix. Build all with nix-build tests, or one with, e.g., nix-build tests # -A deploy. The exhaustive tests add the combinations of options that no # code path tells apart from the ones the others cover; build them with # nix-build tests -A exhaustive. The smoke test runs a few scenarios of @@ -38,8 +38,12 @@ let }; }; + pure = import ./pure.nix { inherit pkgs; }; + # A phase runs pkgs.populate, or writeDeploy with a stand-in for - # nixos-rebuild. + # nixos-rebuild, or, if deploy's pure is set, a pure evaluation: of + # krops' lib, if it's lib, or of writeDeploy, if it's deploy, running + # what that makes. run = { source, backup, force, prune, deploy, targetKind, targetPath, }: let @@ -47,10 +51,13 @@ let inherit source backup force prune; target = targets.${targetKind} targetPath; }; + deployArgs = args // { useNixOutputMonitor = false; } // deploy; in if deploy == null then pkgs.populate args - else pkgs.krops.writeDeploy "deploy" - (args // { useNixOutputMonitor = false; } // deploy); + else if deploy.pure or null == "lib" then pure.lib + else if deploy.pure or null == "deploy" then + pure.deploy (removeAttrs deployArgs [ "pure" ]) + else pkgs.krops.writeDeploy "deploy" deployArgs; builderArgs = { inherit lib run; @@ -70,13 +77,14 @@ let # Names of the scenarios of the smoke test, besides populate's. smokeNames = import (populateTests + "/smoke.nix") ++ [ + "pure-lib" "deploy-local-buildTarget0-etcFlake0-flakefile-targetString0" "deploy-remote-buildTarget0-etcFlake0-flakenone-targetString1" "deploy-sudo-allocateTTY" ]; scenarios = { - inherit (kropsScenarios) deploy; + inherit (kropsScenarios) deploy pure; populate = builtins.filter (scenario: scenario.refusals || builtins.elem scenario.name smokeNames) populateScenarios; |
