From d36d2e631e4baceed0a8c0c00859ebb2ab8cb82f Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 13 Nov 2026 21:28:11 +0100 Subject: populate: drop the shell implementation Populate is the program in Rust only. pkgs.populate checks its arguments, and returns a script running the program with them as JSON. The arguments it took for the shell implementation, dash, jq, and implementation, stay accepted and unused, so overrides setting them keep working. Copying flakes to remote targets using sudo gets refused during evaluation, as before, by checks.nix, and by the program for specs from elsewhere. The jq test goes with the jq programs; the program's unit tests cover their equivalents. --- pkgs/populate/checks.nix | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'pkgs/populate/checks.nix') diff --git a/pkgs/populate/checks.nix b/pkgs/populate/checks.nix index 7eab15b..22b45c9 100644 --- a/pkgs/populate/checks.nix +++ b/pkgs/populate/checks.nix @@ -49,4 +49,18 @@ with import ../../lib; throw "krops: sources draw inputs from each other: ${toString sorted.cycle}" else true); + + # nix copy logs in as the target's user, so populate can't copy flakes to + # remote targets using sudo, which flake and flake-input sources without + # fetchOnTarget do. + checkCopyingWithSudo = target: source: let + copies = name: let s = source.${name}; in + elem s.type [ "flake" "flake-input" ] && + !(s.${s.type}.fetchOnTarget or false); + name = findFirst copies null (attrNames source); + in + if name != null && target.sudo or false && !isLocalTarget target then + throw "krops: source ${target.path}/${name}: copying flakes to targets with sudo is not supported" + else + true; } -- cgit v1.3.1