From a5d863ee64e429a3918589f0e708dc8a97026d8f Mon Sep 17 00:00:00 2001 From: Thibault Gagnaux Date: Tue, 22 Oct 2019 08:24:13 +0200 Subject: [PATCH 1/3] fonts: Adds support if Nix is on another filesystem. On Catalina, the default way is to install Nix on a new volume which breaks hardlinking the font files. If that is the case I just copy them. --- modules/fonts/default.nix | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/modules/fonts/default.nix b/modules/fonts/default.nix index f218cbe..a072df2 100644 --- a/modules/fonts/default.nix +++ b/modules/fonts/default.nix @@ -45,10 +45,12 @@ in find -L "$systemConfig/Library/Fonts" -type f -print0 | while IFS= read -rd "" l; do font=''${l##*/} f=$(readlink -f "$l") - if [ ! -e "/Library/Fonts/$font" ] || [ $(stat -c '%i' "$f") != $(stat -c '%i' "/Library/Fonts/$font") ]; then + if [ ! -e "/Library/Fonts/$font" ]; then echo "updating font $font..." >&2 - # FIXME: hardlink, won't work if nix is on a dedicated filesystem. - ln -fn "$f" /Library/Fonts + ln -fn -- "$f" /Library/Fonts 2>/dev/null || { + echo "Could not create hard link. Nix is probably on another filesystem. Copying the font instead..." >&2 + cp -fP "$f" /Library/Fonts + } fi done From f5dd95983298c68b91daf3305c0563b720880eba Mon Sep 17 00:00:00 2001 From: Thibault Gagnaux Date: Mon, 28 Oct 2019 09:06:25 +0100 Subject: [PATCH 2/3] Fixes the failing font test --- tests/fonts.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/fonts.nix b/tests/fonts.nix index be48527..007c652 100644 --- a/tests/fonts.nix +++ b/tests/fonts.nix @@ -17,7 +17,7 @@ in echo "checking activation of fonts in /activate" >&2 grep "fontrestore default -n 2>&1" ${config.out}/activate - grep 'ln -fn ".*" /Library/Fonts' ${config.out}/activate + grep 'ln -fn ".*" /Library/Fonts' ${config.out}/activate || grep 'cp -fP ".*" /Library/Fonts' ${config.out}/activate grep 'rm "/Library/Fonts/.*"' ${config.out}/activate ''; } From 547ccd60b416e0f15e8bbdb01887dd89cb2531da Mon Sep 17 00:00:00 2001 From: Thibault Gagnaux Date: Sun, 22 Dec 2019 22:31:34 +0100 Subject: [PATCH 3/3] Replaces cp with rsync to prevent partial copies across filesystems. --- modules/fonts/default.nix | 2 +- tests/fonts.nix | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/fonts/default.nix b/modules/fonts/default.nix index a072df2..195edd6 100644 --- a/modules/fonts/default.nix +++ b/modules/fonts/default.nix @@ -49,7 +49,7 @@ in echo "updating font $font..." >&2 ln -fn -- "$f" /Library/Fonts 2>/dev/null || { echo "Could not create hard link. Nix is probably on another filesystem. Copying the font instead..." >&2 - cp -fP "$f" /Library/Fonts + rsync -az --inplace "$f" /Library/Fonts } fi done diff --git a/tests/fonts.nix b/tests/fonts.nix index 007c652..ff29957 100644 --- a/tests/fonts.nix +++ b/tests/fonts.nix @@ -17,7 +17,7 @@ in echo "checking activation of fonts in /activate" >&2 grep "fontrestore default -n 2>&1" ${config.out}/activate - grep 'ln -fn ".*" /Library/Fonts' ${config.out}/activate || grep 'cp -fP ".*" /Library/Fonts' ${config.out}/activate + grep 'ln -fn ".*" /Library/Fonts' ${config.out}/activate || grep 'rsync -az --inplace ".*" /Library/Fonts' ${config.out}/activate grep 'rm "/Library/Fonts/.*"' ${config.out}/activate ''; }