1
0
Fork 0
mirror of https://github.com/LnL7/nix-darwin.git synced 2025-03-13 20:30:02 +00:00

fonts: adds enableFontDir flag

For NixOS compatibility reasons we're using enableFontDir flag that
in turn enables/disables font management in /Library/Fonts directory.
This commit is contained in:
Piotr Limanowski 2018-10-05 22:16:00 +02:00
parent da886d015c
commit 2a53ac278f
2 changed files with 15 additions and 5 deletions

View file

@ -21,22 +21,29 @@ let
in {
options = {
fonts = {
enableFontDir = mkOption {
default = false;
description = ''
Whether to enable font directory management.
Important: enabling font directory management removes all manually-added fonts.
'';
};
fonts = mkOption {
type = types.listOf types.path;
default = [];
example = literalExample "[ pkgs.dejavu_fonts ]";
description = "List of primary font paths. Important: Manually added fonts will be removed upon rebuild.";
description = "List of primary font paths.";
};
};
};
config = {
system.build.fonts = pkgs.buildEnv {
system.build.fonts = mkIf cfg.enableFontDir (pkgs.buildEnv {
name = "system-fonts";
paths = cfg.fonts;
pathsToLink = "/share/fonts";
};
system.activationScripts.fonts.text = ''
});
system.activationScripts.fonts.text = "" + optionalString cfg.enableFontDir ''
# Set up fonts.
echo "resetting fonts..." >&2
fontrestore default -n 2>&1 | grep -o '/Library/Fonts/.*' | tr '\n' '\0' | xargs -0 rm || true

View file

@ -3,7 +3,10 @@
let
fonts = pkgs.runCommand "fonts-0.0.0" {} "mkdir -p $out";
in {
fonts.fonts = [ pkgs.dejavu_fonts ];
fonts = {
enableFontDir = true;
fonts = [ pkgs.dejavu_fonts ];
};
test = ''
echo checking installed fonts >&2