From 397d2637e9280ff3459534e8b81fd1ffdcb365df Mon Sep 17 00:00:00 2001 From: Piotr Limanowski Date: Thu, 4 Oct 2018 13:46:28 +0200 Subject: [PATCH] looks for fonts with both otf and ttf extensions --- modules/fonts/default.nix | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/modules/fonts/default.nix b/modules/fonts/default.nix index ed65e8c..75738fe 100644 --- a/modules/fonts/default.nix +++ b/modules/fonts/default.nix @@ -9,9 +9,13 @@ let home = readDir path; list = mapAttrsToList (name: type: let newPath = "${path}/${name}"; - in if (type == "directory" || type == "symlink") && !(hasSuffix ".ttf" name) then readDirsRec newPath else [ newPath ]) home; + in if (type == "directory" || type == "symlink") && !(isFont name) then readDirsRec newPath else [ newPath ]) home; in flatten list; - fontFiles = dir: filter (name: hasSuffix ".ttf" name) (readDirsRec dir); + isFont = name: let + fontExt = [ ".ttf" ".otf" ]; + hasExt = exts: name: foldl' (acc: ext: (hasSuffix ext name) || acc) false exts; + in hasExt fontExt name; + fontFiles = dir: filter isFont (readDirsRec dir); print = font: "ln -fn '${font}' '/Library/Fonts/${baseNameOf font}'"; in concatMapStringsSep "\n" print (fontFiles dir); in {