diff options
Diffstat (limited to 'nixos/lib/make-disk-image.nix')
-rw-r--r-- | nixos/lib/make-disk-image.nix | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/nixos/lib/make-disk-image.nix b/nixos/lib/make-disk-image.nix index d641d1289fe44..db53bb98ee4ef 100644 --- a/nixos/lib/make-disk-image.nix +++ b/nixos/lib/make-disk-image.nix @@ -402,11 +402,16 @@ let format' = format; in let done else mkdir -p $root/$(dirname $target) - if ! [ -e $root/$target ]; then - rsync $rsync_flags $source $root/$target - else + if [ -e $root/$target ]; then echo "duplicate entry $target -> $source" exit 1 + elif [ -d $source ]; then + # Append a slash to the end of source to get rsync to copy the + # directory _to_ the target instead of _inside_ the target. + # (See `man rsync`'s note on a trailing slash.) + rsync $rsync_flags $source/ $root/$target + else + rsync $rsync_flags $source $root/$target fi fi done |