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. --- pkgs/populate/program.nix | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 pkgs/populate/program.nix (limited to 'pkgs/populate/program.nix') diff --git a/pkgs/populate/program.nix b/pkgs/populate/program.nix new file mode 100644 index 0000000..06cfa07 --- /dev/null +++ b/pkgs/populate/program.nix @@ -0,0 +1,24 @@ +# The program delivering sources, built from the crate in this directory. +{ rustPlatform }: + +let + cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml); +in + +rustPlatform.buildRustPackage { + pname = cargoToml.package.name; + inherit (cargoToml.package) version; + # Only what cargo builds from, so changes to the Nix files or the docs + # don't rebuild the program. + src = builtins.path { + name = "populate-src"; + path = ./.; + filter = path: type: let + relative = builtins.substring + (builtins.stringLength (toString ./.) + 1) (-1) (toString path); + in + builtins.elem relative [ "Cargo.toml" "Cargo.lock" "src" ] || + builtins.substring 0 4 relative == "src/"; + }; + cargoLock.lockFile = ./Cargo.lock; +} -- cgit v1.3.1