diff --git a/modules/targets/darwin/default.nix b/modules/targets/darwin/default.nix index 961c8667e..b971e18d2 100644 --- a/modules/targets/darwin/default.nix +++ b/modules/targets/darwin/default.nix @@ -19,7 +19,7 @@ let writableDefaults = filterAttrs (domain: attrs: attrs != { }) nonNullDefaults; activationCmds = mapAttrsToList toActivationCmd writableDefaults; in { - imports = [ ./keybindings.nix ./linkapps.nix ./search.nix ]; + imports = [ ./fonts.nix ./keybindings.nix ./linkapps.nix ./search.nix ]; options.targets.darwin.defaults = mkOption { type = types.submodule ./options.nix; diff --git a/modules/targets/darwin/fonts.nix b/modules/targets/darwin/fonts.nix new file mode 100644 index 000000000..bc4042a8d --- /dev/null +++ b/modules/targets/darwin/fonts.nix @@ -0,0 +1,27 @@ +{ 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"; +in { + # macOS won't recognize symlinked fonts + config.home.activation.copyFonts = hm.dag.entryAfter [ "writeBoundary" ] '' + copyFonts() { + rm -rf ${homeDir}/Library/Fonts/HomeManager || : + + local f + find -L "${fonts}" -type f -printf '%P\0' | while IFS= read -rd "" f; do + $DRY_RUN_CMD install $VERBOSE_ARG -Dm644 -T \ + "${fonts}/$f" "${homeDir}/Library/Fonts/HomeManager/$f" + done + } + copyFonts + ''; +}