mirror of
https://github.com/LnL7/nix-darwin.git
synced 2025-03-13 20:30:02 +00:00
fonts: extracts helpers to top-level let expr
This commit is contained in:
parent
c2d7870587
commit
da886d015c
1 changed files with 14 additions and 14 deletions
|
@ -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 = {
|
||||
|
|
Loading…
Add table
Reference in a new issue