summaryrefslogtreecommitdiff
path: root/modules/fonts
diff options
context:
space:
mode:
authorPiotr Limanowski <piotr@codearsonist.com>2018-10-04 13:03:21 +0200
committerPiotr Limanowski <piotr@codearsonist.com>2018-10-04 13:14:45 +0200
commit8fe33a584eb2844b179d83c627c369383fbad9e9 (patch)
tree770f3070b96fc602ac56063f2e25a88984534382 /modules/fonts
parent6d0cf2d8420824af56a00eecfdc48f719c2d3196 (diff)
adds recursive font searching
Diffstat (limited to 'modules/fonts')
-rw-r--r--modules/fonts/default.nix16
1 files changed, 11 insertions, 5 deletions
diff --git a/modules/fonts/default.nix b/modules/fonts/default.nix
index eecef97..ed65e8c 100644
--- a/modules/fonts/default.nix
+++ b/modules/fonts/default.nix
@@ -4,8 +4,16 @@ with lib;
let
cfg = config.fonts;
- fontFiles = env: with builtins;
- filter (n: match ".*\\.ttf" n != null) (attrNames (readDir "${env}/share/fonts/truetype/"));
+ printLinks = dir: with builtins;
+ let readDirsRec = path: 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 flatten list;
+ fontFiles = dir: filter (name: hasSuffix ".ttf" name) (readDirsRec dir);
+ print = font: "ln -fn '${font}' '/Library/Fonts/${baseNameOf font}'";
+ in concatMapStringsSep "\n" print (fontFiles dir);
in {
options = {
fonts = {
@@ -29,10 +37,8 @@ in {
echo "resetting fonts..." >&2
fontrestore default -n 2>&1 | grep -o '/Library/Fonts/.*' | tr '\n' '\0' | xargs -0 rm || true
echo "updating fonts..." >&2
- ${concatMapStrings (font: "ln -fn '${config.system.build.fonts}/share/fonts/truetype/${font}' '/Library/Fonts/${font}'\n")
- (fontFiles config.system.build.fonts)}
+ ${printLinks config.system.build.fonts}
'';
environment.pathsToLink = [ "/share/fonts" ];
};
-
}