aboutsummaryrefslogtreecommitdiff
path: root/modules/files.nix
diff options
context:
space:
mode:
authorRobert Helgesson <robert@rycee.net>2017-11-11 14:16:45 +0100
committerRobert Helgesson <robert@rycee.net>2017-11-11 14:21:11 +0100
commit145aefc9d159ecd0367f887ba0234739fcd8134a (patch)
treebf3820f1d017776de79321acec8d7ade63059f38 /modules/files.nix
parent2b2e20da24a814e244dacc78072f3cc807076afb (diff)
files: simplify cleanup script slightly
The cleanup script now takes relative paths as arguments, not absolute paths into the old generation. This uses a GNU specific feature of find.
Diffstat (limited to 'modules/files.nix')
-rw-r--r--modules/files.nix14
1 files changed, 8 insertions, 6 deletions
diff --git a/modules/files.nix b/modules/files.nix
index 42ef02d8eb8..406fdcf304b 100644
--- a/modules/files.nix
+++ b/modules/files.nix
@@ -116,10 +116,8 @@ in
. ${./lib-bash/color-echo.sh}
newGenFiles="$1"
- oldGenFiles="$2"
- shift 2
- for sourcePath in "$@" ; do
- relativePath="''${sourcePath#$oldGenFiles/}"
+ shift 1
+ for relativePath in "$@" ; do
targetPath="$HOME/$relativePath"
if [[ -e "$newGenFiles/$relativePath" ]] ; then
$VERBOSE_ECHO "Checking $targetPath: exists"
@@ -165,8 +163,12 @@ in
local newGenFiles oldGenFiles
newGenFiles="$(readlink -e "$newGenPath/home-files")"
oldGenFiles="$(readlink -e "$oldGenPath/home-files")"
- find "$oldGenFiles" -type f -print0 -or -type l -print0 \
- | xargs -0 bash ${cleanup} "$newGenFiles" "$oldGenFiles"
+
+ # Apply the cleanup script on each leaf in the old
+ # generation. The find command below will print the
+ # relative path of the entry.
+ find "$oldGenFiles" '(' -type f -or -type l ')' -printf '%P\0' \
+ | xargs -0 bash ${cleanup} "$newGenFiles"
}
if [[ ! -v oldGenPath || "$oldGenPath" != "$newGenPath" ]] ; then