2014-04-14 07:26:48 -07:00
|
|
|
{ config, lib, pkgs, ... }:
|
2013-06-27 04:12:45 -07:00
|
|
|
|
2014-04-14 07:26:48 -07:00
|
|
|
with lib;
|
2013-06-27 04:12:45 -07:00
|
|
|
|
|
|
|
let
|
|
|
|
|
2020-09-01 18:59:58 -07:00
|
|
|
cfg = config.fonts.fontDir;
|
|
|
|
|
2018-11-08 02:59:03 -08:00
|
|
|
x11Fonts = pkgs.runCommand "X11-fonts" { preferLocalBuild = true; } ''
|
2020-09-01 01:38:59 -07:00
|
|
|
mkdir -p "$out/share/X11/fonts"
|
2020-10-25 19:45:22 -07:00
|
|
|
font_regexp='.*\.\(ttf\|ttc\|otf\|pcf\|pfa\|pfb\|bdf\)\(\.gz\)?'
|
2020-08-31 10:40:34 -07:00
|
|
|
find ${toString config.fonts.fonts} -regex "$font_regexp" \
|
2020-09-01 01:38:59 -07:00
|
|
|
-exec ln -sf -t "$out/share/X11/fonts" '{}' \;
|
|
|
|
cd "$out/share/X11/fonts"
|
2020-09-01 18:59:58 -07:00
|
|
|
${optionalString cfg.decompressFonts ''
|
2020-09-01 07:38:06 -07:00
|
|
|
${pkgs.gzip}/bin/gunzip -f *.gz
|
|
|
|
''}
|
2016-05-25 10:10:16 -07:00
|
|
|
${pkgs.xorg.mkfontscale}/bin/mkfontscale
|
2020-08-30 13:39:27 -07:00
|
|
|
${pkgs.xorg.mkfontdir}/bin/mkfontdir
|
2016-05-25 10:10:16 -07:00
|
|
|
cat $(find ${pkgs.xorg.fontalias}/ -name fonts.alias) >fonts.alias
|
|
|
|
'';
|
2013-06-27 04:12:45 -07:00
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
options = {
|
2020-09-01 07:35:13 -07:00
|
|
|
fonts.fontDir = {
|
2013-06-27 04:12:45 -07:00
|
|
|
|
2020-09-01 07:35:13 -07:00
|
|
|
enable = mkOption {
|
2020-04-27 00:04:07 -07:00
|
|
|
type = types.bool;
|
2013-06-27 04:12:45 -07:00
|
|
|
default = false;
|
|
|
|
description = ''
|
|
|
|
Whether to create a directory with links to all fonts in
|
2020-09-01 01:38:59 -07:00
|
|
|
<filename>/run/current-system/sw/share/X11/fonts</filename>.
|
2013-06-27 04:12:45 -07:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2020-09-01 07:38:06 -07:00
|
|
|
decompressFonts = mkOption {
|
|
|
|
type = types.bool;
|
2020-09-01 18:59:58 -07:00
|
|
|
default = config.programs.xwayland.enable;
|
2020-09-01 07:38:06 -07:00
|
|
|
description = ''
|
|
|
|
Whether to decompress fonts in
|
|
|
|
<filename>/run/current-system/sw/share/X11/fonts</filename>.
|
|
|
|
'';
|
|
|
|
};
|
2013-06-27 04:12:45 -07:00
|
|
|
|
2020-09-01 07:35:13 -07:00
|
|
|
};
|
2013-06-27 04:12:45 -07:00
|
|
|
};
|
|
|
|
|
2020-09-01 18:59:58 -07:00
|
|
|
config = mkIf cfg.enable {
|
2013-06-27 04:12:45 -07:00
|
|
|
|
|
|
|
environment.systemPackages = [ x11Fonts ];
|
2021-10-05 23:52:39 -07:00
|
|
|
environment.pathsToLink = [ "/share/X11/fonts" ];
|
2013-06-27 04:12:45 -07:00
|
|
|
|
2020-09-01 01:38:59 -07:00
|
|
|
services.xserver.filesSection = ''
|
|
|
|
FontPath "${x11Fonts}/share/X11/fonts"
|
|
|
|
'';
|
2016-05-25 10:10:16 -07:00
|
|
|
|
2013-06-27 04:12:45 -07:00
|
|
|
};
|
|
|
|
|
2020-09-01 07:35:13 -07:00
|
|
|
imports = [
|
|
|
|
(mkRenamedOptionModule [ "fonts" "enableFontDir" ] [ "fonts" "fontDir" "enable" ])
|
|
|
|
];
|
|
|
|
|
2013-06-27 04:12:45 -07:00
|
|
|
}
|