From 400006448a470d7f71393aaa461542b4764df4dd Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 13 Nov 2026 04:47:52 +0000 Subject: populate prune: name the target by its host, like populate's messages Pruning names the target as user@host:path, like rsync's destination, but nothing else populate prints names the user: the errors about the sentinel name the host, and the commands it runs on the target name the host, with the user as ssh's option. Pruning names the target like those do, as host:path, and the errors about the sentinel use the same function for it. --- pkgs/populate/default.nix | 37 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-) (limited to 'pkgs/populate') diff --git a/pkgs/populate/default.nix b/pkgs/populate/default.nix index d6b3a37..ae61aec 100644 --- a/pkgs/populate/default.nix +++ b/pkgs/populate/default.nix @@ -77,14 +77,10 @@ let fi ''; - # The path on the target, as rsync names it: prefixed by the user and host - # if the target isn't local. + # The path on the target, as populate names it in what it prints: + # prefixed by the host if the target isn't local. targetName = target: path: - optionalString (!isLocalTarget target) ( - (optionalString (target.user != "") "${target.user}@") + - "${target.host}:" - ) + - path; + optionalString (!isLocalTarget target) "${target.host}:" + path; # Shell code that removes the entries of the directory dir, a shell word, # that aren't named names. find, unlike a loop reading names, copes with @@ -221,10 +217,8 @@ let in runShell target /* sh */ '' # Before anything touches it, which would touch what it points to. if test -L ${quote sentinelFile}; then - >&2 printf 'error: sentinel file is a symlink: %s\n' ${quote ( - optionalString (!isLocalTarget target) "${target.host}:" + - sentinelFile - )} + >&2 printf 'error: sentinel file is a symlink: %s\n' \ + ${quote (targetName target sentinelFile)} exit 1 fi ${optionalString force /* sh */ '' @@ -234,10 +228,8 @@ let fi ''} if ! test -e ${quote sentinelFile}; then - >&2 printf 'error: missing sentinel file: %s\n' ${quote ( - optionalString (!isLocalTarget target) "${target.host}:" + - sentinelFile - )} + >&2 printf 'error: missing sentinel file: %s\n' \ + ${quote (targetName target sentinelFile)} exit 1 fi ''; @@ -248,10 +240,8 @@ let runShell target /* sh */ '' ${useState sentinelFile []} if ! test -d ${quote sentinelFile}; then - >&2 printf 'error: sentinel file is not a directory: %s\n' ${quote ( - optionalString (!isLocalTarget target) "${target.host}:" + - sentinelFile - )} + >&2 printf 'error: sentinel file is not a directory: %s\n' \ + ${quote (targetName target sentinelFile)} exit 1 fi rsync >&2 \ @@ -707,7 +697,6 @@ let ${removeOthers { dir = "."; names = attrNames sources ++ [ ".populate" ]; - # Like populating names the target. log = quote (targetName target target.path); }} roots=.populate/flake-inputs @@ -1398,7 +1387,13 @@ let -rlptD \ ${optionalString config.deleteExcluded /* sh */ "--delete-excluded"} \ "$source_path" \ - ${quote (targetName target target.path)} \ + ${quote ( + optionalString (!isLocalTarget target) ( + (optionalString (target.user != "") "${target.user}@") + + "${target.host}:" + ) + + target.path + )} \ >&2 ''; -- cgit v1.3.1