diff options
| author | Piotr Limanowski <piotr@codearsonist.com> | 2018-10-05 19:17:43 +0200 |
|---|---|---|
| committer | Piotr Limanowski <piotr@codearsonist.com> | 2018-10-05 19:17:43 +0200 |
| commit | da886d015c3ed9047878d3618a73ca6eafae51f5 (patch) | |
| tree | d7e843126193f26775b705ee4680c9641266c230 /modules | |
| parent | c2d78705877b0261f32abcb6690b2da46d17f816 (diff) | |
fonts: extracts helpers to top-level let expr
Diffstat (limited to 'modules')
| -rw-r--r-- | modules/fonts/default.nix | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/modules/fonts/default.nix b/modules/fonts/default.nix index 479c510..4c0d4e8 100644 --- a/modules/fonts/default.nix +++ b/modules/fonts/default.nix @@ -1,23 +1,23 @@ { config, lib, pkgs, ... }: with lib; +with builtins; let cfg = config.fonts; - 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") && !(isFont name) then readDirsRec newPath else [ newPath ]) home; - in flatten list; - 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); + readDirsRec = path: let + home = readDir path; + list = mapAttrsToList (name: type: + let newPath = "${path}/${name}"; + in if (type == "directory" || type == "symlink") && !(isFont name) then readDirsRec newPath else [ newPath ]) home; + in flatten list; + 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}'"; + printLinks = dir: concatMapStringsSep "\n" print (fontFiles dir); in { options = { fonts = { |
