From 50a2b8f9628bacdc8f13848e98b909e7be44c640 Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 13 Nov 2026 16:23:34 +0100 Subject: populate: add a Rust implementation, selectable for the tests pkgs.populate takes implementation: "shell", the default, generates a script from populate's arguments, and "rust" passes them as JSON to the program in pkgs/populate, built from the crate there by program.nix. The program checks the spec as checks.nix does during evaluation, with the same messages, and reports that delivering sources isn't implemented yet. rustProgram replaces the program, e.g. with one built some other way. checks.nix holds the checks of populate's arguments during evaluation. Both implementations check the names of sources and the target path with it, and the Rust one's wrapper also checks drawing inputs, which the shell implementation checks where it draws them. nix-build tests --argstr implementation rust runs the scenarios with the Rust implementation. They expect it to refuse copying flakes to targets using sudo when it runs, not during evaluation, because only then it decides whether the target is local. --- tests/default.nix | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'tests/default.nix') diff --git a/tests/default.nix b/tests/default.nix index f7ffa71..189e573 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -8,8 +8,9 @@ # The smoke test runs a few scenarios covering each source type and each kind # of target in a single VM test, for checking changes quickly; build it with # nix-build tests -A smoke. jq runs populate's jq programs for flakes without -# VMs. -{ pkgs ? import ../pkgs {} }: +# VMs. implementation selects populate's implementation, e.g. nix-build +# tests --argstr implementation rust -A smoke. +{ pkgs ? import ../pkgs {}, implementation ? "shell" }: let # HEAD of /fixtures/gitsrc, which fixtures.sh creates deterministically, @@ -24,11 +25,13 @@ let (pkgs.callPackage ./rsync.nix {}); # The scenarios, with populate using rsync. - scenariosWith = rsync: import ./scenarios.nix { + scenariosWith = rsync: let + populate = pkgs.populate.override { inherit implementation rsync; }; + in import ./scenarios.nix { inherit (pkgs) lib; krops = import ../lib; - populate = pkgs.populate.override { inherit rsync; }; - inherit (pkgs.krops) writeDeploy; + inherit implementation populate; + inherit (pkgs.krops.override { inherit populate; }) writeDeploy; url = "http://deployer:8000"; gitUrl = "git://deployer/gitsrc.git"; remoteHost = "target"; -- cgit v1.3.1