diff --git a/modules/fonts/default.nix b/modules/fonts/default.nix index f218cbe..195edd6 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 + rsync -az --inplace "$f" /Library/Fonts + } fi done diff --git a/tests/fonts.nix b/tests/fonts.nix index be48527..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 'ln -fn ".*" /Library/Fonts' ${config.out}/activate || grep 'rsync -az --inplace ".*" /Library/Fonts' ${config.out}/activate grep 'rm "/Library/Fonts/.*"' ${config.out}/activate ''; }