aboutsummaryrefslogtreecommitdiffstats
path: root/pkgs/populate
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-13 04:49:28 +0000
committertv <tv@krebsco.de>2026-11-13 04:49:28 +0000
commitb3c671bed4e785c732fdd881cf1cc39d852eb3bb (patch)
tree136d29e5b909638cc8245df9b9c69b18f7911bad /pkgs/populate
parent400006448a470d7f71393aaa461542b4764df4dd (diff)
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.
Diffstat (limited to 'pkgs/populate')
-rw-r--r--pkgs/populate/default.nix17
1 files changed, 12 insertions, 5 deletions
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