mirror of
https://github.com/LnL7/nix-darwin.git
synced 2024-09-11 12:49:18 +03:00
add tests for fonts
This commit is contained in:
parent
b10e114e33
commit
6d0cf2d842
@ -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" ];
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -114,6 +114,7 @@ let
|
||||
tests.system-path-fish = makeTest ./tests/system-path-fish.nix;
|
||||
tests.system-shells = makeTest ./tests/system-shells.nix;
|
||||
tests.users-groups = makeTest ./tests/users-groups.nix;
|
||||
tests.fonts = makeTest ./tests/fonts.nix;
|
||||
|
||||
}
|
||||
// (mapTestOn (packagePlatforms packageSet));
|
||||
|
14
tests/fonts.nix
Normal file
14
tests/fonts.nix
Normal file
@ -0,0 +1,14 @@
|
||||
{ config, pkgs, ... }:
|
||||
|
||||
let
|
||||
fonts = pkgs.runCommand "fonts-0.0.0" {} "mkdir -p $out";
|
||||
in {
|
||||
fonts.fonts = [ pkgs.dejavu_fonts ];
|
||||
|
||||
test = ''
|
||||
echo checking installed fonts >&2
|
||||
grep -o "fontrestore default -n" ${config.out}/activate
|
||||
grep -o "/share/fonts/truetype/DejaVuSans.ttf /Library/Fonts/DejaVuSans.ttf" ${config.out}/activate
|
||||
'';
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user