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