From c7ec9892418f7f02799bc0dc74249c93f85e7a1b Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 13 Nov 2026 15:46:17 +0000 Subject: populate: deliver sources other than flakes with the Rust program The program delivers derivation, file, git, pass, passage, pipe, and symlink sources, makes backups, and prunes, as the shell implementation does, with the same messages. Commands on the target are fixed shell snippets in src/sh.rs, which get values as positional parameters, run directly for local targets and over ssh, sharing one master connection, for remote ones. rsync's transfers and its check for .rsync-filter files it can't read are in src/rsync.rs. Given flake or flake-input sources, or sources drawing inputs from others, the program fails before changing anything, saying that these aren't implemented yet. SIGHUP, SIGINT, and SIGTERM make populate stop once the command it waits for ends, stop the ssh master, remove its temporary directory, and exit with 128 plus the signal's number. The spec's target gets local, which rust.nix sets during evaluation, like the other functions of krops decide, and which the program decides when it runs if it's null. The spec comes on file descriptor 3, so the commands populate runs keep standard input, and the tools populate runs come first in PATH. --- pkgs/populate/rust.nix | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'pkgs/populate/rust.nix') diff --git a/pkgs/populate/rust.nix b/pkgs/populate/rust.nix index cbf6fad..f6ece25 100644 --- a/pkgs/populate/rust.nix +++ b/pkgs/populate/rust.nix @@ -26,18 +26,22 @@ let port = if target.port or null == null then null else toString target.port; sudo = target.sudo or false; extraOptions = target.extraOptions or []; + # Decided during evaluation, like the other functions of krops do. + local = isLocalTarget target; }; }; in writers.writeDash "populate.${target.host}" /* sh */ '' set -efu echo + "$0" >&2 + # The tools populate depends on, in front of others of the same name. PATH=${makeBinPath [ - coreutils findutils git jq nix openssh pass passage rsync + rsync openssh git nix pass passage jq findutils coreutils ]}''${PATH:+:$PATH} export PATH - # The JSON is a single line, which can't be the delimiter. - exec ${program}/bin/populate - <<'EOF' + # On a file descriptor of its own, so the commands populate runs keep + # standard input. The JSON is a single line, which can't be the delimiter. + exec ${program}/bin/populate /dev/fd/3 3<<'EOF' ${spec} EOF '' -- cgit v1.3.1