diff options
| author | Piotr Limanowski <piotr@codearsonist.com> | 2018-09-30 19:42:00 +0200 |
|---|---|---|
| committer | Piotr Limanowski <piotr@codearsonist.com> | 2018-10-02 19:59:23 +0200 |
| commit | 6d0cf2d8420824af56a00eecfdc48f719c2d3196 (patch) | |
| tree | 2b2e8e9ab8963279958f0de3e0eb6e934caed224 /modules | |
| parent | b10e114e330ebdb23619b0a4c797a69ce9857e9a (diff) | |
add tests for fonts
Diffstat (limited to 'modules')
| -rw-r--r-- | modules/fonts/default.nix | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/modules/fonts/default.nix b/modules/fonts/default.nix index c330d3c..eecef97 100644 --- a/modules/fonts/default.nix +++ b/modules/fonts/default.nix @@ -4,16 +4,11 @@ with lib; let cfg = config.fonts; + fontFiles = env: with builtins; + filter (n: match ".*\\.ttf" n != null) (attrNames (readDir "${env}/share/fonts/truetype/")); in { options = { fonts = { - enableFontDir = mkOption { - default = false; - description = '' - Whether to create a directory with links to all fonts in - <filename>/run/current-system/sw/share/fonts</filename>. - ''; - }; fonts = mkOption { type = types.listOf types.path; default = []; @@ -27,15 +22,17 @@ in { system.build.fonts = pkgs.buildEnv { name = "system-fonts"; paths = cfg.fonts; - pathsToLink = "/share/fonts/truetype"; + pathsToLink = "/share/fonts"; }; - system.activationScripts.fonts.text = optionalString cfg.enableFontDir '' + system.activationScripts.fonts.text = '' # Set up fonts. - echo "setting up fonts..." >&2 - fontrestore default -n 2>&1 | grep -o '/Library/Fonts/.*' | tr '\n' '\0' | xargs -0 sudo rm - /bin/ln -hf ${config.system.build.fonts}/share/fonts/truetype/* /Library/Fonts/ - ''; - environment.pathsToLink = [ "/share/fonts/truetype" ]; + 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)} + ''; + environment.pathsToLink = [ "/share/fonts" ]; }; } |
