1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-14 07:09:45 +01:00
home-manager/modules/targets/darwin/fonts.nix
Albert Peschar 6ade7aed90
darwin: fonts: speed up font installation
* Skip font installation if the derivation hasn't changed.
* Use `rsync` instead of `install` to copy font files, to avoid useless
  copying of pre-existent identical files.
2024-04-10 21:27:27 +02:00

26 lines
726 B
Nix

{ config, lib, pkgs, ... }:
with lib;
let
homeDir = config.home.homeDirectory;
fontsEnv = pkgs.buildEnv {
name = "home-manager-fonts";
paths = config.home.packages;
pathsToLink = "/share/fonts";
};
fonts = "${fontsEnv}/share/fonts";
installDir = "${homeDir}/Library/Fonts/HomeManager";
in {
# macOS won't recognize symlinked fonts
config = mkIf pkgs.stdenv.hostPlatform.isDarwin {
home.file."Library/Fonts/.home-manager-fonts-version" = {
text = "${fontsEnv}";
onChange = ''
run mkdir -p ${escapeShellArg installDir}
run ${pkgs.rsync}/bin/rsync $VERBOSE_ARG -acL --chmod=u+w --delete \
${escapeShellArgs [ "${fonts}/" installDir ]}
'';
};
};
}