From b3c671bed4e785c732fdd881cf1cc39d852eb3bb Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 13 Nov 2026 04:49:28 +0000 Subject: populate: name the target's user in messages unless it's root Messages naming the target, i.e. pruning's lines and the errors about the sentinel, name the user as well, as user@host:path, unless the user is root, the usual one, so deploying as another user, e.g. with sudo, shows. --- pkgs/populate/default.nix | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'pkgs/populate/default.nix') diff --git a/pkgs/populate/default.nix b/pkgs/populate/default.nix index ae61aec..1a44044 100644 --- a/pkgs/populate/default.nix +++ b/pkgs/populate/default.nix @@ -78,9 +78,16 @@ let ''; # The path on the target, as populate names it in what it prints: - # prefixed by the host if the target isn't local. + # prefixed by the host if the target isn't local, and by the user as well + # if that isn't root. targetName = target: path: - optionalString (!isLocalTarget target) "${target.host}:" + path; + optionalString (!isLocalTarget target) ( + optionalString + (!elem target.user [ null "" "root" ]) + "${target.user}@" + + "${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 @@ -92,14 +99,14 @@ let removeOthers = { dir, names, log ? null }: /* sh */ '' find ${dir} -mindepth 1 -maxdepth 1 \ ${concatMapStringsSep " " (name: "! -name ${quote name}") names} \ - -exec sh -c ' + -exec sh -c ${quote /* sh */ '' ${optionalString (log != null) /* sh */ '' log=$1 shift ''} for path; do ${optionalString (log != null) /* sh */ '' - >&2 printf "pruning %s/%s\n" "$log" "''${path##*/}" + >&2 printf "pruning '%s/%s'...\n" "$log" "''${path##*/}" ''} ${if log != null then /* sh */ '' rm -fR "$path" @@ -113,7 +120,7 @@ let fi ''} done - ' sh ${optionalString (log != null) log} {} + + ''} sh ${optionalString (log != null) log} {} + ''; # Shell code that removes a symlink at path, saying so, because the link -- cgit v1.3.1